PATCH: various small java patches

Per Bothner bothner@cygnus.com
Sat Jan 16 11:00:00 GMT 1999


I checked this into egcs.

Fri Jan 15 20:16:20 1999  Per Bothner  <bothner@cygnus.com>

	* expr.c (process_jvm_instruction):  Coerce to correct Throwable
	sub-type the result of the call that gets the exception value.

	* parse.y (java_complete_expand_methods):  If flags_syntax_only,
	don't call finish_class.

	* parse.y (java_check_regular_methods):  If METHOD_PRIVATE,
	clear found before continuing.

	* verify.c (verify_jvm_instructions):  On an array load, allow
	and handle top of stack to be TYPE_NULL.

	* gjavah.c (generate_access):  Translate Java package private or
	protected access to C++ public, but with a comment.

Index: expr.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/expr.c,v
retrieving revision 1.21
diff -u -p -r1.21 expr.c
--- expr.c	1999/01/13 06:13:32	1.21
+++ expr.c	1999/01/16 17:50:15
@@ -2197,8 +2197,8 @@ process_jvm_instruction (PC, byte_ops, l
      replace the top of the stack with the thrown object reference */
   if (instruction_bits [PC] & BCODE_EXCEPTION_TARGET)
     {
-      pop_value (ptr_type_node);
-      push_value (soft_exceptioninfo_call_node);
+      tree type = pop_type (ptr_type_node);
+      push_value (build1 (NOP_EXPR, type, soft_exceptioninfo_call_node));
     }
 
   switch (byte_ops[PC++])
Index: parse.y
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/parse.y,v
retrieving revision 1.41
diff -u -p -r1.41 parse.y
--- parse.y	1999/01/13 06:13:37	1.41
+++ parse.y	1999/01/16 17:50:16
@@ -4523,8 +4523,13 @@ java_check_regular_methods (class_decl)
       found = lookup_argument_method (super_class, DECL_NAME (method), sig);
 
       /* Nothing overrides or it's a private method. */
-      if (!found || (found && METHOD_PRIVATE (found)))
+      if (!found)
 	continue;
+      if (METHOD_PRIVATE (found))
+	{
+	  found = NULL_TREE;
+	  continue;
+	}
 
       /* If found wasn't verified, it's DECL_NAME won't be set properly. 
 	 We set it temporarily for the sake of the error report. */
@@ -5672,7 +5677,7 @@ java_complete_expand_methods ()
 	{
 	  if (flag_emit_class_files)
 	    write_classfile (current_class);
-	  else
+	  else if (! flag_syntax_only)
 	    finish_class (current_class);
 	}
     }
Index: verify.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/verify.c,v
retrieving revision 1.6
diff -u -p -r1.6 verify.c
--- verify.c	1998/12/23 10:46:45	1.6
+++ verify.c	1999/01/16 17:50:16
@@ -882,10 +882,12 @@ verify_jvm_instructions (jcf, byte_ops, 
 	case OPCODE_saload: type = promote_type (short_type_node); goto aload;
         aload:
 	  pop_type (int_type_node);
-	  type = pop_type (ptr_type_node);
-	  if (! is_array_type_p (type))
+	  tmp = pop_type (ptr_type_node);
+	  if (is_array_type_p (tmp))
+	    type = TYPE_ARRAY_ELEMENT (TREE_TYPE (tmp));
+	  else if (tmp != TYPE_NULL)
 	    VERIFICATION_ERROR ("array load from non-array type");
-	  push_type (TYPE_ARRAY_ELEMENT (TREE_TYPE (type)));
+	  push_type (type);
 	  break;
 
 	case OPCODE_anewarray:
Index: gjavah.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/java/gjavah.c,v
retrieving revision 1.14
diff -u -p -r1.14 gjavah.c
--- gjavah.c	1999/01/10 13:36:44	1.14
+++ gjavah.c	1999/01/16 17:50:16
@@ -250,19 +250,15 @@ generate_access (stream, flags)
      FILE *stream;
      JCF_u2 flags;
 {
-  /* FIXME: Java's "protected" and "no access specifier" modes don't
-     actually map to C++ "protected".  That's how we map them for now,
-     though.  */
-
-  if (! (flags & ACC_VISIBILITY))
-    flags = ACC_PROTECTED;
-
   if ((flags & ACC_VISIBILITY) == last_access)
     return;
   last_access = (flags & ACC_VISIBILITY);
 
   switch (last_access)
     {
+    case 0:
+      fputs ("public: // actually package-private\n", stream);
+      break;
     case ACC_PUBLIC:
       fputs ("public:\n", stream);
       break;
@@ -270,7 +266,7 @@ generate_access (stream, flags)
       fputs ("private:\n", stream);
       break;
     case ACC_PROTECTED:
-      fputs ("protected:\n", stream);
+      fputs ("public:  // actually protected\n", stream);
       break;
     default:
       found_error = 1;
@@ -840,7 +836,7 @@ DEFUN(process_file, (jcf, out),
 
   current_jcf = main_jcf = jcf;
 
-  last_access = 0;
+  last_access = -1;
 
   if (jcf_parse_preamble (jcf) != 0)
     {



More information about the Gcc-patches mailing list