[gcjx] Patch: FYI: more field/method updates

Tom Tromey tromey@redhat.com
Sun Feb 13 14:01:00 GMT 2005


I'm checking this in on the gcjx branch.

This updates the code that creates reflection data for fields and
methods.  It removes some globals that weren't needed, and creates the
array types on the fly so that the sizes come out right.

This is the last of my saved-up patches.

At this point, gcjx can compile very simple classes and write out
what appears to be correct assembly.  Name mangling seems to work.
As Class generation is still not working, I haven't actually tested
the generated code.

Tom

# 
# patch "gcc/gcc/java/ChangeLog"
#  from [87aea9eea4a774631225e6351a9ebb7e310b8ae2]
#    to [9af48a5a51e6d4e8769d4a7ce4e6335a446e1cff]
# 
# patch "gcc/gcc/java/classobj.cc"
#  from [0c61a248624f126f8ce0b00be8399b9e8cd0e9ae]
#    to [e245d85d2f26006f8e170aeb09d0b3e8a9a90c25]
# 
# patch "gcc/gcc/java/decl.cc"
#  from [5c4c43652fe62e9b1a1114cfbdcea99d73901049]
#    to [561a0ad828601647758b9b0a293fe636ca636ffd]
# 
# patch "gcc/gcc/java/hooks.hh"
#  from [cc4ab8ee4035b2ef31b70f5c91ca1ac8461b5287]
#    to [2474ed4c234a79d7c37310a401a68678dab3ba3d]
# 
--- gcc/gcc/java/ChangeLog
+++ gcc/gcc/java/ChangeLog
@@ -1,5 +1,13 @@
 2005-02-10  Tom Tromey  <tromey@redhat.com>
 
+	* hooks.hh (type_method_array): Removed.
+	(type_field_array): Likewise.
+	* decl.cc (type_field_array): Removed.
+	(type_method_array): Likewise.
+	(start_type_initialization): Updated.
+	* classobj.cc (create_field_array): Fixed initialization.
+	(create_one_field_record): Fixed value of "type" field.
+
 	* decl.cc (build_utf8_record): Correctly initialize global
 	type_utf8const.
 	* builtins.cc (map_utf8const): Wrote.
--- gcc/gcc/java/classobj.cc
+++ gcc/gcc/java/classobj.cc
@@ -105,7 +105,8 @@
 
   inst.set_field ("name", builtins->map_utf8const (field->get_name ()));
   // FIXME: ABI difference here.
-  inst.set_field ("type", builtins->map_type (field->type ()));
+  inst.set_field ("type",
+		  builtins->map_utf8const (field->type ()->get_descriptor ()));
   inst.set_field ("accflags", build_int_cst (type_jint,
 					     field->get_modifiers ()));
   inst.set_field ("bsize", TYPE_SIZE_UNIT (TREE_TYPE (fdecl)));
@@ -136,13 +137,17 @@
 
   num_fields = 0;
   num_static_fields = 0;
+  if (fields.size () == 0)
+    return null_pointer_node;
+
+  int index = 0;
   tree field_array = NULL_TREE;
   for (std::list<ref_field>::const_iterator i = fields.begin ();
        i != fields.end ();
-       ++i)
+       ++i, ++index)
     {
       tree elt = create_one_field_record ((*i).get ());
-      field_array = tree_cons (NULL_TREE, // FIXME
+      field_array = tree_cons (build_int_cst (type_jint, index),
 			       elt, field_array);
       if ((*i)->static_p ())
 	++num_static_fields;
@@ -150,11 +155,13 @@
 	++num_fields;
     }
 
-  if (field_array == NULL_TREE)
-    return null_pointer_node;
   field_array = nreverse (field_array);
 
-  return make_decl (type_field_array, field_array);
+  tree fa_type
+    = build_array_type (type_field,
+			build_index_type (build_int_cst (type_jint,
+							 index - 1)));
+  return make_decl (fa_type, build_constructor (fa_type, field_array));
 }
 
 tree
--- gcc/gcc/java/decl.cc
+++ gcc/gcc/java/decl.cc
@@ -46,9 +46,6 @@
 tree type_method;
 tree type_method_ptr;
 
-// Array of _Jv_Method objects.
-tree type_method_array;
-
 // Type of a _Jv_Field and a pointer to it.
 tree type_field;
 tree type_field_ptr;
@@ -56,9 +53,6 @@
 // Union used in field reflection info.
 tree type_field_info_union;
 
-// Array of _Jv_Field objects.
-tree type_field_array;
-
 // Type of _Jv_Constants structure.
 tree type_constants;
 
@@ -197,7 +191,6 @@
   type_class_ptr = build_pointer_type (type_class);
   type_method = make_node (RECORD_TYPE);
   type_method_ptr = build_pointer_type (type_method);
-  type_method_array = build_array_type (type_method, type_jint);
   type_field = make_node (RECORD_TYPE);
   type_field_ptr = build_pointer_type (type_field);
 }
--- gcc/gcc/java/hooks.hh
+++ gcc/gcc/java/hooks.hh
@@ -32,11 +32,9 @@
 extern GTY (()) tree type_method_symbol_array;
 extern GTY (()) tree type_method;
 extern GTY (()) tree type_method_ptr;
-extern GTY (()) tree type_method_array;
 extern GTY (()) tree type_field;
 extern GTY (()) tree type_field_ptr;
 extern GTY (()) tree type_field_info_union;
-extern GTY (()) tree type_field_array;
 extern GTY (()) tree type_constants;
 extern GTY (()) tree type_object;
 extern GTY (()) tree type_object_ptr;



More information about the Java-patches mailing list