OSDN Git Service

* class.c (add_field): Mark static fields external.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Feb 2002 06:23:37 +0000 (06:23 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Feb 2002 06:23:37 +0000 (06:23 +0000)
        (build_class_ref): Remove redundant set.
        * parse.y (java_expand_classes): Mark static fields of classes
        to be compiled as local.
        * jcf-parse.c (parse_class_file): Likewise.

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

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/jcf-parse.c
gcc/java/parse.y

index 4482d28..3bd83c7 100644 (file)
@@ -1,3 +1,11 @@
+2002-02-02  Richard Henderson  <rth@redhat.com>
+
+       * class.c (add_field): Mark static fields external.
+       (build_class_ref): Remove redundant set.
+       * parse.y (java_expand_classes): Mark static fields of classes
+       to be compiled as local.
+       * jcf-parse.c (parse_class_file): Likewise.
+
 2002-02-02  Nic Ferrier  <nferrier@tapsellferrier.co.uk>
 
        * gcj.texi (About CNI): New node.
        (Invoking jv-convert): New node.
 
 2001-01-10  Jeff Sturm  <jsturm@one-point.com>
-            Martin Kahlert  <martin.kahlert@infineon.com>
+           Martin Kahlert  <martin.kahlert@infineon.com>
 
        * jcf-parse.c (get_constant): Don't swap lo/hi for big
        endian targets when HOST_BITS_PER_WIDE_INT >= 64.
 
 2002-01-03  Graham Stott  <grahams@redhat.com>
 
-        * class.c (compile_resource_file): Update copyright date.
-        Constify filename parameter.
-        (java-tree.h): Update copyright date.
-        (compile_resource_file): Constify filename parameter.
+       * class.c (compile_resource_file): Update copyright date.
+       Constify filename parameter.
+       (java-tree.h): Update copyright date.
+       (compile_resource_file): Constify filename parameter.
 
 2002-01-03  Graham Stott  <grahams@redhat.com>
 
-        * gcc/jcf-parse.c: Update copyright date.
-        (yyparse): Constify resource_filename.
+       * gcc/jcf-parse.c: Update copyright date.
+       (yyparse): Constify resource_filename.
 
 2002-01-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
index bd45306..2e70081 100644 (file)
@@ -773,7 +773,11 @@ add_field (class, name, field_type, flags)
       /* Always make field externally visible.  This is required so
         that native methods can always access the field.  */
       TREE_PUBLIC (field) = 1;
+      /* Considered external until we know what classes are being
+        compiled into this object file.  */
+      DECL_EXTERNAL (field) = 1;
     }
+
   return field;
 }
 
@@ -1095,8 +1099,6 @@ build_class_ref (type)
              DECL_EXTERNAL (decl) = 1;
              make_decl_rtl (decl, NULL);
              pushdecl_top_level (decl);
-             if (is_compiled == 1)
-               DECL_EXTERNAL (decl) = 1;
            }
        }
 
index 3e3bd23..e85b578 100644 (file)
@@ -793,7 +793,7 @@ init_outgoing_cpool ()
 static void
 parse_class_file ()
 {
-  tree method;
+  tree method, field;
   const char *save_input_filename = input_filename;
   int save_lineno = lineno;
 
@@ -808,8 +808,13 @@ parse_class_file ()
      compiling from class files.  */
   always_initialize_class_p = 1;
 
-  for ( method = TYPE_METHODS (CLASS_TO_HANDLE_TYPE (current_class));
-       method != NULL_TREE; method = TREE_CHAIN (method))
+  for (field = TYPE_FIELDS (CLASS_TO_HANDLE_TYPE (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));
+       method != NULL_TREE; method = TREE_CHAIN (method))
     {
       JCF *jcf = current_jcf;
 
index 8b33fad..328a18e 100644 (file)
@@ -8963,8 +8963,7 @@ java_expand_classes ()
   java_layout_classes ();
   java_parse_abort_on_error ();
 
-  cur_ctxp = ctxp_for_generation;
-  for (; cur_ctxp; cur_ctxp = cur_ctxp->next)
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
       ctxp = cur_ctxp;
       input_filename = ctxp->filename;
@@ -8976,7 +8975,7 @@ java_expand_classes ()
 
   /* Find anonymous classes and expand their constructor, now they
      have been fixed. */
-  for (cur_ctxp = ctxp_for_generation;  cur_ctxp;  cur_ctxp = cur_ctxp->next)
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
       tree current;
       ctxp = cur_ctxp;
@@ -9009,7 +9008,25 @@ java_expand_classes ()
     return;
 
   /* Now things are stable, go for generation of the class data. */
-  for (cur_ctxp = ctxp_for_generation;  cur_ctxp;  cur_ctxp = cur_ctxp->next)
+
+  /* We pessimistically marked all fields external until we knew
+     what set of classes we were planning to compile.  Now mark
+     those that will be generated locally as not external.  */
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
+    {
+      tree current;
+      for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
+       {
+         tree class = TREE_TYPE (current);
+         tree field;
+         for (field = TYPE_FIELDS (class); field ; field = TREE_CHAIN (field))
+           if (FIELD_STATIC (field))
+             DECL_EXTERNAL (field) = 0;
+       }
+    }
+
+  /* Compile the classes.  */
+  for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
     {
       tree current;
       ctxp = cur_ctxp;