[gcjx] Patch: FYI: fix static import

Tom Tromey tromey@redhat.com
Wed Oct 26 07:42:00 GMT 2005


I'm checking this in on the gcjx branch.

I broke static import in an earlier patch.
This fixes it.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* model/unit.cc (look_up_name): Use local_scope.
	(look_up_name): Resolve imports.
	(check_imports): Use local_scope.
	* model/unit.hh (model_unit_source::local_scope): New field.
	(model_unit_source): Call push_on_scope.

Index: model/unit.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/unit.cc,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 unit.cc
--- model/unit.cc 25 Oct 2005 19:29:48 -0000 1.1.2.4
+++ model/unit.cc 26 Oct 2005 07:40:41 -0000
@@ -96,12 +96,6 @@
   // not be in scope.
   if (resolved && ! resolving)
     {
-      // We lazily resolve the imports, and for that we need a scope.
-      // The scope doesn't need to know anything other than its
-      // compilation unit.
-      resolution_scope scope;
-      push_on_scope (&scope);
-
       for (std::multimap<std::string, model_import *>::const_iterator i
 	     = simple_name_map.begin ();
 	   i != simple_name_map.end ();
@@ -110,7 +104,7 @@
 	  if (name != (*i).first)
 	    continue;
 	  model_import *imp = (*i).second;
-	  resolve (&scope, imp);
+	  resolve (&local_scope, imp);
 	  model_class *klass = imp->get_class_declaration ();
 	  if (accessible_p (klass, context))
 	    {
@@ -136,19 +130,13 @@
   if (! resolved || resolving)
     return;
 
-  // We lazily resolve the imports, and for that we need a scope.  The
-  // scope doesn't need to know anything other than its compilation
-  // unit.
-  resolution_scope scope;
-  push_on_scope (&scope);
-
   // Finally look at on-demand imports.
   model_import *result_import = NULL;
   for (std::list<ref_import>::const_iterator i = imports.begin ();
        i != imports.end ();
        ++i)
     {
-      resolve (&scope, (*i).get ());
+      resolve (&local_scope, (*i).get ());
       if (! (*i)->single_import_p ())
 	{
 	  // FIXME: imports should probably cache negative results.
@@ -193,6 +181,7 @@
 	  if ((*i)->single_import_p () == (pass == 1))
 	    continue;
 
+	  (*i)->resolve (&local_scope);
 	  (*i)->find_field (name, context, result);
 	  if (! result.empty ());
 	  return;
@@ -216,6 +205,7 @@
 	  if ((*i)->single_import_p () == (pass == 1))
 	    continue;
 
+	  (*i)->resolve (&local_scope);
 	  (*i)->find_method (name, context, accessible);
 	  if (! accessible.empty ())
 	    return;
@@ -226,9 +216,6 @@
 void
 model_unit_source::check_imports ()
 {
-  resolution_scope scope;
-  push_on_scope (&scope);
-
   name_map_type local_name_map;
 
   // Resolve the imports.
@@ -236,7 +223,7 @@
        i != imports.end ();
        ++i)
     {
-      resolve (&scope, (*i).get ());
+      resolve (&local_scope, (*i).get ());
       // This will be NULL if the import doesn't resolve to a single
       // class.
       model_class *k = (*i)->get_class_declaration ();
Index: model/unit.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/unit.hh,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 unit.hh
--- model/unit.hh 25 Oct 2005 19:29:48 -0000 1.1.2.4
+++ model/unit.hh 26 Oct 2005 07:40:41 -0000
@@ -137,6 +137,11 @@
 /// This represents a single .java source file.
 class model_unit_source : public model_unit
 {
+  // We lazily resolve the imports, and for that we need a scope.  The
+  // scope doesn't need to know anything other than its compilation
+  // unit.
+  resolution_scope local_scope;
+
   // Imports.
   std::list<ref_import> imports;
 
@@ -163,6 +168,7 @@
     : model_unit (w),
       resolving (false)
   {
+    push_on_scope (&local_scope);
   }
 
   void add (const ref_class &typ)



More information about the Java-patches mailing list