This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: New C++ ABI: patches.



Mark Mitchell writes:

> ?  You know best -- this code only fires for Java types...

Right, I need that if I want to check the C++ patch ASAP. Here's what
I'd like to commit.

./A

2001-01-07  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
	* decl2.c (acceptable_java_type): Allow references too. 
	* init.c (build_java_class_ref): When using the new ABI, search
	`class$' and have it mangled with `mangle_decl.'
	* mangle.c (write_java_integer_type_codes): New function.
	(write_builtin_type): Detect and mangle Java integer and real
	types.
 
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.422
diff -u -p -r1.422 decl2.c
--- decl2.c	2001/01/08 01:58:54	1.422
+++ decl2.c	2001/01/10 17:26:11
@@ -1350,7 +1350,7 @@ acceptable_java_type (type)
 {
   if (TREE_CODE (type) == VOID_TYPE || TYPE_FOR_JAVA (type))
     return 1;
-  if (TREE_CODE (type) == POINTER_TYPE)
+  if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
     {
       type = TREE_TYPE (type);
       if (TREE_CODE (type) == RECORD_TYPE)
Index: init.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/init.c,v
retrieving revision 1.224
diff -u -p -r1.224 init.c
--- init.c	2001/01/03 03:28:50	1.224
+++ init.c	2001/01/10 17:26:19
@@ -2206,7 +2206,23 @@ build_java_class_ref (type)
 	fatal("call to Java constructor, while `jclass' undefined");
       jclass_node = TREE_TYPE (jclass_node);
     }
-  name = build_static_name (type, CL_suffix);
+
+  /* Mangle the class$ field, new and old ABI */
+  if (flag_new_abi)
+    {
+      tree field;
+      for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+	if (DECL_NAME (field) == CL_suffix)
+	  {
+	    name = mangle_decl (field);
+	    break;
+	  }
+      if (!field)
+	fatal ("Can't find class$");
+    }
+  else
+    name = build_static_name (type, CL_suffix);
+
   class_decl = IDENTIFIER_GLOBAL_VALUE (name);
   if (class_decl == NULL_TREE)
     {
Index: mangle.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/mangle.c,v
retrieving revision 1.23
diff -u -p -r1.23 mangle.c
--- mangle.c	2000/12/04 17:00:03	1.23
+++ mangle.c	2001/01/10 17:26:24
@@ -189,6 +189,10 @@ static inline void start_mangling PARAMS
 static inline const char *finish_mangling PARAMS ((void));
 static tree mangle_special_for_type PARAMS ((tree, const char *));
 
+/* Foreign language functions. */
+
+static void write_java_integer_type_codes PARAMS ((tree));
+
 /* Append a single character to the end of the mangled
    representation.  */
 #define write_char(CHAR)                                              \
@@ -1446,6 +1450,8 @@ write_builtin_type (type)
 	 integer_type_nodes.  */
       if (type == wchar_type_node)
 	write_char ('w');
+      if (TYPE_FOR_JAVA (type))
+	write_java_integer_type_codes (type);
       else
 	{
 	  size_t itk;
@@ -1473,9 +1479,11 @@ write_builtin_type (type)
       break;
 
     case REAL_TYPE:
-      if (type == float_type_node)
+      if (type == float_type_node
+	  || type == java_float_type_node)
 	write_char ('f');
-      else if (type == double_type_node)
+      else if (type == double_type_node
+	       || type == java_double_type_node)
 	write_char ('d');
       else if (type == long_double_type_node)
 	write_char ('e');
@@ -2280,3 +2288,30 @@ mangle_guard_variable (variable)
   write_name (variable, /*ignore_local_scope=*/0);
   return get_identifier (finish_mangling ());
 }
+
+
+
+/* Foreign language type mangling section.  */
+
+/* How to write the type codes for the integer Java type.  */
+
+static void
+write_java_integer_type_codes (type)
+     tree type;
+{
+  if (type == java_int_type_node)
+    write_char ('i');
+  else if (type == java_short_type_node)
+    write_char ('s');
+  else if (type == java_byte_type_node)
+    write_char ('c');
+  else if (type == java_char_type_node)
+    write_char ('w');
+  else if (type == java_long_type_node)
+    write_char ('x');
+  else if (type == java_boolean_type_node)
+    write_char ('b');
+  else
+    my_friendly_abort (20001207);
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]