Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: compiler/java/com/google/dart/compiler/resolver/TopLevelElementBuilder.java

Issue 11226010: Issue 6073. Fixes for 'export'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/resolver/TopLevelElementBuilder.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/TopLevelElementBuilder.java b/compiler/java/com/google/dart/compiler/resolver/TopLevelElementBuilder.java
index 2a4e52b933eb38a420af520becab31c69e16f81f..3cb47c748f863b5073eba05d4464818746c6c814 100644
--- a/compiler/java/com/google/dart/compiler/resolver/TopLevelElementBuilder.java
+++ b/compiler/java/com/google/dart/compiler/resolver/TopLevelElementBuilder.java
@@ -7,6 +7,7 @@ package com.google.dart.compiler.resolver;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.DartCompilerContext;
import com.google.dart.compiler.DartCompilerListener;
@@ -35,6 +36,7 @@ import com.google.dart.compiler.util.apache.StringUtils;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* Builds all class elements and types of a library. Once all libraries
@@ -63,18 +65,25 @@ public class TopLevelElementBuilder {
* libraries.
*/
public void fillInLibraryScope(LibraryUnit library, DartCompilerListener listener) {
+ fillInLibraryScope(library, listener, Sets.newHashSet());
+ }
+
+ /**
+ * Fill the scope for this library, using its own top-level elements and elements from imported
+ * libraries.
+ */
+ private void fillInLibraryScope(LibraryUnit library, DartCompilerListener listener,
+ Set<Object> processedObjects) {
Scope importScope = library.getElement().getImportScope();
Scope scope = library.getElement().getScope();
- // We are processing this library now, or already done this.
- if (library.getElement().getScope().isStateProgress()
- || library.getElement().getScope().isStateReady()) {
+ // We are done with this library.
+ if (library.getElement().getScope().isStateReady()) {
return;
}
- library.getElement().getScope().markStateProgress();
// Fill "library" scope.
- {
+ if (processedObjects.add(library)) {
Brian Wilkerson 2012/10/20 17:39:43 I don't understand this. If we've already processe
scheglov 2012/10/20 18:21:27 We need this for the case when library A imports B
Brian Wilkerson 2012/10/20 19:05:18 Ah! The joys of mutually recursive libraries! Than
List<Element> exportedElements = Lists.newArrayList();
{
DartUnit selfUnit = library.getSelfDartUnit();
@@ -100,8 +109,12 @@ public class TopLevelElementBuilder {
}
}
+ // Fill "import" scope.
Map<String, LibraryPrefixElement> libraryPrefixElements = Maps.newHashMap();
for (LibraryImport libraryImport : library.getImports()) {
+ if (!processedObjects.add(libraryImport)) {
+ continue;
+ }
LibraryUnit lib = libraryImport.getLibrary();
// Prepare scope for this import.
Scope scopeForImport;
@@ -128,7 +141,7 @@ public class TopLevelElementBuilder {
}
}
// Prepare "lib" scope.
- fillInLibraryScope(lib, listener);
+ fillInLibraryScope(lib, listener, processedObjects);
// Fill "library" scope with element exported from "lib".
for (Element element : lib.getElement().getExportedElements()) {
String name = element.getName();
@@ -141,10 +154,14 @@ public class TopLevelElementBuilder {
}
}
}
+
// Fill "library" export scope with re-exports.
for (LibraryExport export : library.getExports()) {
+ if (!processedObjects.add(export)) {
+ continue;
+ }
LibraryUnit lib = export.getLibrary();
- fillInLibraryScope(lib, listener);
+ fillInLibraryScope(lib, listener, processedObjects);
for (Element element : lib.getElement().getExportedElements()) {
String name = element.getName();
// re-export only in not defined locally
@@ -157,6 +174,7 @@ public class TopLevelElementBuilder {
}
}
}
+
// Done.
library.getElement().getScope().markStateReady();
}

Powered by Google App Engine
This is Rietveld 408576698