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

Unified Diff: compiler/java/com/google/dart/compiler/DartCompiler.java

Issue 8333016: Migrate --expose_core_impl flag from DartRunner to DartCompiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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/DartCompiler.java
diff --git a/compiler/java/com/google/dart/compiler/DartCompiler.java b/compiler/java/com/google/dart/compiler/DartCompiler.java
index e860694aaf961e36c05236ae59a13f9a269e8df0..c40658658db2cf78a2fe34b8e102f3e4c0ccb2d8 100644
--- a/compiler/java/com/google/dart/compiler/DartCompiler.java
+++ b/compiler/java/com/google/dart/compiler/DartCompiler.java
@@ -4,6 +4,7 @@
package com.google.dart.compiler;
+import com.google.common.collect.Lists;
import com.google.common.io.CharStreams;
import com.google.common.io.Closeables;
import com.google.common.io.Files;
@@ -70,6 +71,49 @@ public class DartCompiler {
public static final String CORELIB_URL_SPEC = "dart:core";
public static final String MAIN_ENTRY_POINT_NAME = "main";
+ private static class NamedPlaceHolderLibrarySource implements LibrarySource {
+ private final String name;
+
+ public NamedPlaceHolderLibrarySource(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean exists() {
+ throw new AssertionError();
+ }
+
+ @Override
+ public long getLastModified() {
+ throw new AssertionError();
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Reader getSourceReader() {
+ throw new AssertionError();
+ }
+
+ @Override
+ public URI getUri() {
+ throw new AssertionError();
+ }
+
+ @Override
+ public LibrarySource getImportFor(String relPath) {
+ throw new AssertionError();
+ }
+
+ @Override
+ public DartSource getSourceFor(String relPath) {
+ throw new AssertionError();
+ }
+ }
+
private static class Compiler {
private final LibrarySource app;
private final List<LibrarySource> embeddedLibraries = new ArrayList<LibrarySource>();
@@ -417,7 +461,7 @@ public class DartCompiler {
}
}
}
-
+
if (filesHaveChanged) {
context.setFilesHaveChanged();
}
@@ -500,7 +544,7 @@ public class DartCompiler {
Tracer.end(logEvent);
}
}
-
+
private void validateLibraryDirectives() {
LibraryUnit appLibUnit = context.getAppLibraryUnit();
for (LibraryUnit lib : libraries.values()) {
@@ -576,7 +620,7 @@ public class DartCompiler {
private void setEntryPoint() {
LibraryUnit lib = context.getAppLibraryUnit();
lib.setEntryNode(new LibraryNode(MAIN_ENTRY_POINT_NAME));
- // this ensures that if we find it, it's a top-level static element
+ // this ensures that if we find it, it's a top-level static element
Element element = lib.getElement().lookupLocalElement(MAIN_ENTRY_POINT_NAME);
switch (ElementKind.of(element)) {
case NONE:
@@ -1052,6 +1096,16 @@ public class DartCompiler {
DartCompilerListener listener) throws IOException {
DartCompilerMainContext context = new DartCompilerMainContext(lib, provider, listener,
config);
+ if (config.getCompilerOptions().shouldExposeCoreImpl()) {
+ if (embeddedLibraries == null) {
+ embeddedLibraries = Lists.newArrayList();
+ }
+ // use a place-holder LibrarySource instance, to be replaced when embedded
+ // in the compiler, where the dart uri can be resolved.
+ embeddedLibraries.add(new NamedPlaceHolderLibrarySource("dart:coreimpl"));
+ }
+
+
new Compiler(lib, embeddedLibraries, config, context).compile();
int errorCount = context.getErrorCount();
if (config.typeErrorsAreFatal()) {
@@ -1172,7 +1226,7 @@ public class DartCompiler {
}
return null;
}
-
+
public static LibraryUnit getCoreLib(LibraryUnit libraryUnit) {
return findLibrary(libraryUnit, "corelib.dart", new HashSet<LibraryElement>());
}
« no previous file with comments | « compiler/java/com/google/dart/compiler/CommandLineOptions.java ('k') | compiler/java/com/google/dart/runner/DartRunner.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698