[gcjx] Patch: FYI: create utf8const objects

Tom Tromey tromey@redhat.com
Sun Feb 13 11:18:00 GMT 2005


I'm checking this in on the gcjx branch.

This fixes initialization of the global type_utf8const and changes
the builtins class to actually create utf8const objects.  This code
is still buggy but this is a step forward.

Tom

# 
# patch "gcc/gcc/java/ChangeLog"
#  from [8ebb8343e656970715e655d3652a0a57e501ec67]
#    to [87aea9eea4a774631225e6351a9ebb7e310b8ae2]
# 
# patch "gcc/gcc/java/builtins.cc"
#  from [cca8ac8d41e018def9c0c39a573624ad4f2ee865]
#    to [e28b9606674cef00ef1027bb0fbdef98033a7b72]
# 
# patch "gcc/gcc/java/decl.cc"
#  from [38f321a6937eb5e84e73033677b7e0982b7645fd]
#    to [5c4c43652fe62e9b1a1114cfbdcea99d73901049]
# 
--- gcc/gcc/java/ChangeLog
+++ gcc/gcc/java/ChangeLog
@@ -1,5 +1,9 @@
 2005-02-10  Tom Tromey  <tromey@redhat.com>
 
+	* decl.cc (build_utf8_record): Correctly initialize global
+	type_utf8const.
+	* builtins.cc (map_utf8const): Wrote.
+
 	* classobj.hh (class_object_creator::create_one_field_record):
 	Declare.
 	* classobj.cc (create_method_array): Wrote.
--- gcc/gcc/java/builtins.cc
+++ gcc/gcc/java/builtins.cc
@@ -376,8 +376,20 @@
   std::map<std::string, tree>::const_iterator it = utf8map.find (value);
   if (it == utf8map.end ())
     {
-      // FIXME
-      utf8map[value] = NULL;
+      record_creator utf (type_utf8const);
+      utf.set_field ("hash", build_int_cst (type_jushort, 0)); // FIXME
+      utf.set_field ("length", build_int_cst (type_jushort, value.length ()));
+
+      tree str = build_string (value.length (), value.c_str ());
+      tree strtype = build_index_type (build_int_cst (type_jushort,
+						      value.length ()));
+      TREE_TYPE (str) = strtype;
+      TREE_CONSTANT (str) = 1;
+      TREE_READONLY (str) = 1;
+      TREE_STATIC (str) = 1;
+      utf.set_field ("data", str);
+
+      utf8map[value] = build_address_of (utf.finish_record ());
     }
   return utf8map[value];
 }
--- gcc/gcc/java/decl.cc
+++ gcc/gcc/java/decl.cc
@@ -206,7 +206,7 @@
 build_utf8_record ()
 {
   tree field = NULL_TREE;
-  tree type_utf8const = make_node (RECORD_TYPE);
+  type_utf8const = make_node (RECORD_TYPE);
   push_field (type_utf8const, field, "hash", type_jushort);
   push_field (type_utf8const, field, "length", type_jushort);
   push_field (type_utf8const, field, "data",



More information about the Java-patches mailing list