OSDN Git Service

* java-tree.h, class.c, expr.c, jcf-parse.c, parse.y,
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Jun 2002 20:32:08 +0000 (20:32 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Jun 2002 20:32:08 +0000 (20:32 +0000)
typeck.c, verify.c: Remove all #if JAVA_USE_HANDLES blocks,
all mention of CLASS_TO_HANDLE_TYPE or HANDLE_TO_CLASS_TYPE,
and all now-pointless local variables.  Rename other local
variables to reflect their not being handles.

* java-tree.h, jcf-dump.c, jcf-io.c: Remove all
#if JCF_USE_STDIO blocks.

* parse.y: Add missing semicolon at end of rule.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54261 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/expr.c
gcc/java/java-tree.h
gcc/java/jcf-dump.c
gcc/java/jcf-io.c
gcc/java/jcf-parse.c
gcc/java/parse.y
gcc/java/typeck.c
gcc/java/verify.c

index 5a7fc58..9241ec8 100644 (file)
@@ -1,3 +1,16 @@
+2002-06-04  Zack Weinberg  <zack@codesourcery.com>
+
+       * java-tree.h, class.c, expr.c, jcf-parse.c, parse.y,
+       typeck.c, verify.c: Remove all #if JAVA_USE_HANDLES blocks,
+       all mention of CLASS_TO_HANDLE_TYPE or HANDLE_TO_CLASS_TYPE,
+       and all now-pointless local variables.  Rename other local
+       variables to reflect their not being handles.
+
+       * java-tree.h, jcf-dump.c, jcf-io.c: Remove all
+       #if JCF_USE_STDIO blocks.
+
+       * parse.y: Add missing semicolon at end of rule.
+
 2002-06-03  Geoffrey Keating  <geoffk@redhat.com>
 
        * check-init.c (attach_initialized_static_class): Delete, unused.
@@ -7,7 +20,7 @@
        (struct lang_decl_func): Use htab_t, set up for gengtype.
        (struct init_test_hash_entry): Delete.
        (struct treetreehash_entry): New.
-       (java_treetreehash_find): New 
+       (java_treetreehash_find): New
        (java_treetreehash_new): New prototype.
        (java_treetreehash_create): New prototype.
        (java_mark_tree): Delete prototype.
        * jcf.h (JCF_USE_SCANDIR): Define.
        * parse.y (java_expand_classes): Write the class files in reverse
        order.
-       
+
 2002-05-16  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
 
        * Make-lang.in: Allow for PWDCMD to override hardcoded pwd.
 
 2002-05-08  Mark Mitchell  <mark@codesourcery.com>
 
-       * jcf-write.c (write_classfile): Write the file to a 
+       * jcf-write.c (write_classfile): Write the file to a
        temporary file and then rename it.
 
 2002-05-07  Tom Tromey  <tromey@redhat.com>
 
 2002-05-07  Andreas Jaeger  <aj@suse.de>
 
-        * parse.y (finish_for_loop): Fix if statement.
+       * parse.y (finish_for_loop): Fix if statement.
 
 2002-05-06  Tom Tromey  <tromey@redhat.com>
 
 
 2002-04-19  Andrew Haley  <aph@redhat.com>
 
-        * jcf-write.c (push_long_const): lo, hi: New variables.
-        Use rshift_double to extract the high part of a 64-bit long.
-        Use WORD_TO_INT to extract the low part.
+       * jcf-write.c (push_long_const): lo, hi: New variables.
+       Use rshift_double to extract the high part of a 64-bit long.
+       Use WORD_TO_INT to extract the low part.
 
-        * jcf-parse.c (get_constant): CONSTANT_Integer: Use an unsigned
-        HOST_WIDE_INT for num.  Use JPOOL_UINT to get it.
-        CONSTANT_Double: Use JPOOL_UINT to get both halve of a double.
+       * jcf-parse.c (get_constant): CONSTANT_Integer: Use an unsigned
+       HOST_WIDE_INT for num.  Use JPOOL_UINT to get it.
+       CONSTANT_Double: Use JPOOL_UINT to get both halve of a double.
 
 2002-04-18  Neil Booth  <neil@daikokuya.demon.co.uk>
 
index 0b9c6a9..f5c5597 100644 (file)
@@ -282,21 +282,7 @@ make_class ()
 {
   tree type;
   type = make_node (RECORD_TYPE);
-#ifdef JAVA_USE_HANDLES
-  tree field1 = build_decl (FIELD_DECL, get_identifier ("obj"),
-                           build_pointer_type (type));
-  tree field2 = build_decl (FIELD_DECL, get_identifier ("methods"),
-                           methodtable_ptr_type);
-  tree handle_type = make_node (RECORD_TYPE);
-  TREE_CHAIN (field1) = field2;
-  TYPE_FIELDS (handle_type) = field1;
-  TYPE_BINFO (type) = make_tree_vec (7);
-  TYPE_BINFO (handle_type) = make_tree_vec (7);
-  BINFO_HANDLE (TYPE_BINFO (handle_type)) = type;
-  BINFO_HANDLE (TYPE_BINFO (type)) = handle_type;
-#else
   TYPE_BINFO (type) = make_tree_vec (6);
-#endif
   MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
 
   return type;
@@ -353,15 +339,6 @@ push_class (class_type, class_name)
   DECL_ARTIFICIAL (decl) = 1;
 
   pushdecl_top_level (decl);
-#ifdef JAVA_USE_HANDLES
-  {
-    tree handle_name = identifier_subst (class_name,
-                                        "Handle$", '.', '.', "");
-    tree handle_decl = build_decl (TYPE_DECL, handle_name,
-                                  CLASS_TO_HANDLE_TYPE (class_type));
-    pushdecl (handle_decl);
-  }
-#endif
 
   return decl;
 }
@@ -618,12 +595,12 @@ build_java_method_type (fntype, this_class, access_flags)
 {
   if (access_flags & ACC_STATIC)
     return fntype;
-  return build_method_type (CLASS_TO_HANDLE_TYPE (this_class), fntype);
+  return build_method_type (this_class, fntype);
 }
 
 tree
-add_method_1 (handle_class, access_flags, name, function_type)
-     tree handle_class;
+add_method_1 (this_class, access_flags, name, function_type)
+     tree this_class;
      int access_flags;
      tree name;
      tree function_type;
@@ -631,10 +608,10 @@ add_method_1 (handle_class, access_flags, name, function_type)
   tree method_type, fndecl;
 
   method_type = build_java_method_type (function_type,
-                                       handle_class, access_flags);
+                                       this_class, access_flags);
 
   fndecl = build_decl (FUNCTION_DECL, name, method_type);
-  DECL_CONTEXT (fndecl) = handle_class;
+  DECL_CONTEXT (fndecl) = this_class;
 
   DECL_LANG_SPECIFIC (fndecl)
     = (struct lang_decl *) ggc_alloc_cleared (sizeof (struct lang_decl));
@@ -653,15 +630,15 @@ add_method_1 (handle_class, access_flags, name, function_type)
   /* Initialize the static method invocation compound list */
   DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl) = NULL_TREE;
 
-  TREE_CHAIN (fndecl) = TYPE_METHODS (handle_class);
-  TYPE_METHODS (handle_class) = fndecl;
+  TREE_CHAIN (fndecl) = TYPE_METHODS (this_class);
+  TYPE_METHODS (this_class) = fndecl;
 
   /* Notice that this is a finalizer and update the class type
      accordingly. This is used to optimize instance allocation. */
   if (name == finalize_identifier_node
       && TREE_TYPE (function_type) == void_type_node
       && TREE_VALUE (TYPE_ARG_TYPES (function_type)) == void_type_node)
-    HAS_FINALIZER_P (handle_class) = 1;
+    HAS_FINALIZER_P (this_class) = 1;
 
   if (access_flags & ACC_PUBLIC) METHOD_PUBLIC (fndecl) = 1;
   if (access_flags & ACC_PROTECTED) METHOD_PROTECTED (fndecl) = 1;
@@ -694,7 +671,6 @@ add_method (this_class, access_flags, name, method_sig)
      tree name;
      tree method_sig;
 {
-  tree handle_class = CLASS_TO_HANDLE_TYPE (this_class);
   tree function_type, fndecl;
   const unsigned char *sig
     = (const unsigned char *) IDENTIFIER_POINTER (method_sig);
@@ -703,7 +679,7 @@ add_method (this_class, access_flags, name, method_sig)
     fatal_error ("bad method signature");
 
   function_type = get_type_from_signature (method_sig);
-  fndecl = add_method_1 (handle_class, access_flags, name, function_type);
+  fndecl = add_method_1 (this_class, access_flags, name, function_type);
   set_java_signature (TREE_TYPE (fndecl), method_sig);
   return fndecl;
 }
@@ -1525,7 +1501,7 @@ make_class_data (type)
     fields_decl = NULL_TREE;
 
   /* Build Method array. */
-  for (method = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (type));
+  for (method = TYPE_METHODS (type);
        method != NULL_TREE; method = TREE_CHAIN (method))
     {
       tree init;
@@ -1707,7 +1683,7 @@ void
 finish_class ()
 {
   tree method;
-  tree type_methods = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (current_class));
+  tree type_methods = TYPE_METHODS (current_class);
   int saw_native_method = 0;
 
   /* Find out if we have any native methods.  We use this information
@@ -2013,13 +1989,12 @@ layout_class_methods (this_class)
      tree this_class;
 {
   tree method_decl, dtable_count;
-  tree super_class, handle_type;
+  tree super_class;
 
   if (TYPE_NVIRTUALS (this_class))
     return;
 
   super_class = CLASSTYPE_SUPER (this_class);
-  handle_type = CLASS_TO_HANDLE_TYPE (this_class);
 
   if (super_class)
     {
@@ -2031,18 +2006,14 @@ layout_class_methods (this_class)
   else
     dtable_count = integer_zero_node;
 
-  TYPE_METHODS (handle_type) = nreverse (TYPE_METHODS (handle_type));
+  TYPE_METHODS (this_class) = nreverse (TYPE_METHODS (this_class));
 
-  for (method_decl = TYPE_METHODS (handle_type);
+  for (method_decl = TYPE_METHODS (this_class);
        method_decl; method_decl = TREE_CHAIN (method_decl))
     dtable_count = layout_class_method (this_class, super_class, 
                                        method_decl, dtable_count);
 
   TYPE_NVIRTUALS (this_class) = dtable_count;
-
-#ifdef JAVA_USE_HANDLES
-  layout_type (handle_type);
-#endif
 }
 
 /* Return 0 if NAME is equal to STR, -1 if STR is "less" than NAME,
index 34be4d5..08525be 100644 (file)
@@ -198,22 +198,6 @@ java_truthvalue_conversion (expr)
     }
 }
 
-#ifdef JAVA_USE_HANDLES
-/* Given a pointer to a handle, get a pointer to an object. */
-
-tree
-unhand_expr (expr)
-     tree expr;
-{
-  tree field, handle_type;
-  expr = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (expr)), expr);
-  handle_type = TREE_TYPE (expr);
-  field = TYPE_FIELDS (handle_type);
-  expr = build (COMPONENT_REF, TREE_TYPE (field), expr, field);
-  return expr;
-}
-#endif
-
 /* Save any stack slots that happen to be in the quick_stack into their
    home virtual register slots.
 
@@ -404,8 +388,6 @@ can_widen_reference_to (source_type, target_type)
     return 1;
   else
     {
-      source_type = HANDLE_TO_CLASS_TYPE (source_type);
-      target_type = HANDLE_TO_CLASS_TYPE (target_type);
       if (TYPE_ARRAY_P (source_type) || TYPE_ARRAY_P (target_type))
        {
          HOST_WIDE_INT source_length, target_length;
@@ -1571,12 +1553,9 @@ build_field_ref (self_value, self_class, name)
                   && ! (DECL_P (self_value)
                         && DECL_NAME (self_value) == this_identifier_node));
 
-      tree base_handle_type = promote_type (base_class);
-      if (base_handle_type != TREE_TYPE (self_value))
-       self_value = fold (build1 (NOP_EXPR, base_handle_type, self_value));
-#ifdef JAVA_USE_HANDLES
-      self_value = unhand_expr (self_value);
-#endif
+      tree base_type = promote_type (base_class);
+      if (base_type != TREE_TYPE (self_value))
+       self_value = fold (build1 (NOP_EXPR, base_type, self_value));
       self_value = build_java_indirect_ref (TREE_TYPE (TREE_TYPE (self_value)),
                                            self_value, check);
       return fold (build (COMPONENT_REF, TREE_TYPE (field_decl),
@@ -1842,7 +1821,7 @@ build_known_method_ref (method, method_type, self_type,
        methods_ident = get_identifier ("methods");
       ref = build (COMPONENT_REF, method_ptr_type_node, ref,
                   lookup_field (&class_type_node, methods_ident));
-      for (meth = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (self_type));
+      for (meth = TYPE_METHODS (self_type);
           ; meth = TREE_CHAIN (meth))
        {
          if (method == meth)
@@ -2056,11 +2035,9 @@ expand_invoke (opcode, method_ref_index, nargs)
   layout_class_methods (self_type);
 
   if (ID_INIT_P (method_name))
-    method = lookup_java_constructor (CLASS_TO_HANDLE_TYPE (self_type),
-                                     method_signature);
+    method = lookup_java_constructor (self_type, method_signature);
   else
-    method = lookup_java_method (CLASS_TO_HANDLE_TYPE (self_type),
-                                method_name, method_signature);
+    method = lookup_java_method (self_type, method_name, method_signature);
   if (method == NULL_TREE)
     {
       error ("class '%s' has no method named '%s' matching signature '%s'",
index 71a6388..9ba52a6 100644 (file)
@@ -1059,22 +1059,6 @@ struct lang_type GTY(())
   unsigned strictfp:1;         /* `strictfp' class.  */
 };
 
-#ifdef JAVA_USE_HANDLES
-/* TYPE_BINFO_HANDLE points from a handle-class to its corresponding
-   non-handle-class, and vice verse. */
-
-#define BINFO_HANDLE(NODE) TREE_VEC_ELT ((NODE), 6)
-
-/* Given a RECORD_TYPE for a handle type, return the corresponding class. */
-#define HANDLE_TO_CLASS_TYPE(HTYPE) BINFO_HANDLE (TYPE_BINFO (HTYPE))
-
-/* Given a RECORD_TYPE for a class, return the corresponding handle type. */
-#define CLASS_TO_HANDLE_TYPE(TYPE) BINFO_HANDLE (TYPE_BINFO (TYPE))
-#else
-#define HANDLE_TO_CLASS_TYPE(HTYPE) (HTYPE)
-#define CLASS_TO_HANDLE_TYPE(TYPE) (TYPE)
-#endif
-
 #define JCF_u4 unsigned long
 #define JCF_u2 unsigned short
 
@@ -1261,13 +1245,8 @@ extern void jcf_print_utf8 PARAMS ((FILE *, const unsigned char *, int));
 extern void jcf_print_char PARAMS ((FILE *, int));
 extern void jcf_print_utf8_replace PARAMS ((FILE *, const unsigned char *,
                                           int, int, int));
-# if JCF_USE_STDIO
-extern const char* open_class PARAMS ((const char *, struct JCF *,
-                                      FILE *, const char *));
-# else
 extern const char* open_class PARAMS ((const char *, struct JCF *,
                                       int, const char *));
-# endif /* JCF_USE_STDIO */
 #endif
 extern void java_debug_context PARAMS ((void));
 extern void safe_layout_class PARAMS ((tree));
index 8c4052d..aa90374 100644 (file)
@@ -939,11 +939,7 @@ DEFUN(main, (argc, argv),
   if (optind >= argc)
     {
       fprintf (out, "Reading .class from <standard input>.\n");
-#if JCF_USE_STDIO
-      open_class ("<stdio>", jcf, stdin, NULL);
-#else
       open_class ("<stdio>", jcf, 0, NULL);
-#endif
       process_class (jcf);
     }
   else
index b228bf5..a1af70a 100644 (file)
@@ -231,30 +231,6 @@ DEFUN(read_zip_member, (jcf, zipd, zipf),
          return 0;
 }
 
-#if JCF_USE_STDIO
-const char *
-DEFUN(open_class, (filename, jcf, stream, dep_name),
-      const char *filename AND JCF *jcf AND FILE* stream
-      AND const char *dep_name)
-{
-  if (jcf)
-    {
-      if (dep_name != NULL)
-       jcf_dependency_add_file (dep_name, 0);
-      JCF_ZERO (jcf);
-      jcf->buffer = NULL;
-      jcf->buffer_end = NULL;
-      jcf->read_ptr = NULL;
-      jcf->read_end = NULL;
-      jcf->read_state = stream;
-      jcf->filename = filename;
-      jcf->filbuf = jcf_filbuf_from_stdio;
-    }
-  else
-    fclose (stream);
-  return filename;
-}
-#else
 const char *
 DEFUN(open_class, (filename, jcf, fd, dep_name),
       const char *filename AND JCF *jcf AND int fd AND const char *dep_name)
@@ -289,24 +265,16 @@ DEFUN(open_class, (filename, jcf, fd, dep_name),
     close (fd);
   return filename;
 }
-#endif
 
 
 const char *
 DEFUN(find_classfile, (filename, jcf, dep_name),
       char *filename AND JCF *jcf AND const char *dep_name)
 {
-#if JCF_USE_STDIO
-  FILE *stream = fopen (filename, "rb");
-  if (stream == NULL)
-    return NULL;
-  return open_class (arg, jcf, stream, dep_name);
-#else
   int fd = open (filename, O_RDONLY | O_BINARY);
   if (fd < 0)
     return NULL;
   return open_class (filename, jcf, fd, dep_name);
-#endif
 }
 
 #if JCF_USE_SCANDIR
@@ -461,11 +429,7 @@ DEFUN(find_class, (classname, classname_length, jcf, source_ok),
       const char *classname AND int classname_length AND JCF *jcf AND int source_ok)
 
 {
-#if JCF_USE_STDIO
-  FILE *stream;
-#else
   int fd;
-#endif
   int i, k, java = -1, class = -1;
   struct stat java_buf, class_buf;
   char *dep_file;
@@ -578,27 +542,6 @@ DEFUN(find_class, (classname, classname_length, jcf, source_ok),
     dep_file = java_buffer;
   else
     dep_file = buffer;
-#if JCF_USE_STDIO
-  if (!class)
-    {
-      SOURCE_FRONTEND_DEBUG (("Trying %s", buffer));
-      stream = fopen (buffer, "rb");
-      if (stream)
-       goto found;
-    }
-  /* Give .java a try, if necessary */
-  if (!java)
-    {
-      strcpy (buffer, java_buffer);
-      SOURCE_FRONTEND_DEBUG (("Trying %s", buffer));
-      stream = fopen (buffer, "r");
-      if (stream)
-       {
-         jcf->java_source = 1;
-         goto found;
-       }
-    }
-#else
   if (!class)
     {
       SOURCE_FRONTEND_DEBUG ((stderr, "[Class selected: %s]\n",
@@ -624,7 +567,6 @@ DEFUN(find_class, (classname, classname_length, jcf, source_ok),
          goto found;
        }
     }
-#endif
 
   free (buffer);
 
@@ -635,12 +577,6 @@ DEFUN(find_class, (classname, classname_length, jcf, source_ok),
 
   return NULL;
  found:
-#if JCF_USE_STDIO
-  if (jcf->java_source)
-    return NULL;               /* FIXME */
-  else
-    return open_class (buffer, jcf, stream, dep_file);
-#else
   if (jcf->java_source)
     {
       JCF_ZERO (jcf);          /* JCF_FINISH relies on this */
@@ -652,7 +588,6 @@ DEFUN(find_class, (classname, classname_length, jcf, source_ok),
     buffer = (char *) open_class (buffer, jcf, fd, dep_file);
   jcf->classname = xstrdup (classname);
   return buffer;
-#endif
 }
 
 void
index af9022b..3b1f5d6 100644 (file)
@@ -193,9 +193,7 @@ set_source_filename (jcf, index)
   DECL_LINENUMBERS_OFFSET (current_method) = 0)
 
 #define HANDLE_END_METHODS() \
-{ tree handle_type = CLASS_TO_HANDLE_TYPE (current_class); \
-  if (handle_type != current_class) layout_type (handle_type); \
-  current_method = NULL_TREE; }
+{ current_method = NULL_TREE; }
 
 #define HANDLE_CODE_ATTRIBUTE(MAX_STACK, MAX_LOCALS, CODE_LENGTH) \
 { DECL_MAX_STACK (current_method) = (MAX_STACK); \
@@ -745,12 +743,12 @@ parse_class_file ()
      compiling from class files.  */
   always_initialize_class_p = 1;
 
-  for (field = TYPE_FIELDS (CLASS_TO_HANDLE_TYPE (current_class));
+  for (field = TYPE_FIELDS (current_class);
        field != NULL_TREE; field = TREE_CHAIN (field))
     if (FIELD_STATIC (field))
       DECL_EXTERNAL (field) = 0;
 
-  for (method = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (current_class));
+  for (method = TYPE_METHODS (current_class);
        method != NULL_TREE; method = TREE_CHAIN (method))
     {
       JCF *jcf = current_jcf;
index 960bd90..e00834b 100644 (file)
@@ -1896,6 +1896,7 @@ catch_clause:
                  exit_block ();
                  $$ = $1;
                }
+;
 
 catch_clause_parameter:
        CATCH_TK OP_TK formal_parameter CP_TK
@@ -6303,7 +6304,7 @@ java_check_regular_methods (class_decl)
 {
   int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
   tree method;
-  tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
+  tree class = TREE_TYPE (class_decl);
   tree found = NULL_TREE;
   tree mthrows;
 
index d32bc05..86bc024 100644 (file)
@@ -446,7 +446,7 @@ promote_type (type)
   switch (TREE_CODE (type))
     {
     case RECORD_TYPE:
-      return build_pointer_type (CLASS_TO_HANDLE_TYPE (type));
+      return build_pointer_type (type);
     case BOOLEAN_TYPE:
       if (type == boolean_type_node)
        return promoted_boolean_type_node;
index f554248..b81927e 100644 (file)
@@ -145,8 +145,8 @@ merge_types (type1, type2)
       if (type2 == ptr_type_node || type1 == object_ptr_type_node)
        return type1;
 
-      tt1 = HANDLE_TO_CLASS_TYPE (TREE_TYPE (type1));
-      tt2 = HANDLE_TO_CLASS_TYPE (TREE_TYPE (type2));
+      tt1 = TREE_TYPE (type1);
+      tt2 = TREE_TYPE (type2);
 
       /* If tt{1,2} haven't been properly loaded, now is a good time
          to do it. */