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

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

Issue 9860009: Removes dartc reliance on its own libraries, now can be targeted at any implementation's libraries (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated 'configs' to be 'config' directory, updated addLib() to throw exception Created 8 years, 9 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 6968b104eb511739e82b33fe39ed6741d0e5fe60..2f4fa763e7ce977afba094ebf5ebb04c8ed13405 100644
--- a/compiler/java/com/google/dart/compiler/DartCompiler.java
+++ b/compiler/java/com/google/dart/compiler/DartCompiler.java
@@ -96,7 +96,7 @@ public class DartCompiler {
public String getName() {
return name;
}
-
+
@Override
public Reader getSourceReader() {
throw new AssertionError();
@@ -131,7 +131,6 @@ public class DartCompiler {
private final Map<URI, LibraryUnit> libraries = new LinkedHashMap<URI, LibraryUnit>();
private CoreTypeProvider typeProvider;
private final boolean incremental;
- private final boolean usePrecompiledDartLibs;
private final List<DartCompilationPhase> phases;
private final LibrarySource coreLibrarySource;
@@ -143,22 +142,24 @@ public class DartCompiler {
this.context = context;
for (LibrarySource library : embedded) {
if (SystemLibraryManager.isDartSpec(library.getName())) {
- embeddedLibraries.add(context.getSystemLibraryFor(library.getName()));
+ LibrarySource foundLibrary = context.getSystemLibraryFor(library.getName());
+ assert(foundLibrary != null);
+ embeddedLibraries.add(foundLibrary);
} else {
embeddedLibraries.add(library);
}
}
coreLibrarySource = context.getSystemLibraryFor(CORELIB_URL_SPEC);
+ assert(coreLibrarySource != null);
embeddedLibraries.add(coreLibrarySource);
incremental = config.incremental();
- usePrecompiledDartLibs = true;
}
-
+
void addResolvedLibraries(Map<URI, LibraryUnit> resolvedLibraries) {
libraries.putAll(resolvedLibraries);
}
-
+
Map<URI, LibraryUnit> getLibraries() {
return libraries;
}
@@ -234,7 +235,6 @@ public class DartCompiler {
for (LibraryUnit lib : getLibrariesToProcess()) {
LibrarySource libSrc = lib.getSource();
LibraryNode selfSourcePath = lib.getSelfSourcePath();
- boolean libIsDartUri = SystemLibraryManager.isDartUri(libSrc.getUri());
// Load the existing DEPS, or create an empty one.
LibraryDeps deps = lib.getDeps(context);
@@ -254,7 +254,7 @@ public class DartCompiler {
}
if (!incremental
- || (libIsDartUri && !usePrecompiledDartLibs)
+ || SystemLibraryManager.isDartUri(libSrc.getUri())
|| isSourceOutOfDate(dartSrc)) {
DartUnit unit = parse(dartSrc, lib.getPrefixes(), false);
@@ -510,11 +510,6 @@ public class DartCompiler {
boolean filesHaveChanged = false;
for (LibraryUnit lib : getLibrariesToProcess()) {
- if (SystemLibraryManager.isDartUri(lib.getSource().getUri())) {
- // embedded dart libs are always up to date
- continue;
- }
-
// Load the existing DEPS, or create an empty one.
LibraryDeps deps = lib.getDeps(context);
@@ -851,8 +846,8 @@ public class DartCompiler {
}
/**
- * Selectively compile a library. Use supplied libraries and ASTs when available.
- * This allows programming tools to provide customized ASTs for code that is currently being
+ * Selectively compile a library. Use supplied libraries and ASTs when available.
+ * This allows programming tools to provide customized ASTs for code that is currently being
* edited, and may not compile correctly.
*/
private static class SelectiveCompiler extends Compiler {
@@ -862,14 +857,14 @@ public class DartCompiler {
private Collection<LibraryUnit> librariesToProcess;
private SelectiveCompiler(LibrarySource app, Map<URI, LibraryUnit> resolvedLibraries,
- Map<URI,DartUnit> parsedUnits, CompilerConfiguration config,
+ Map<URI,DartUnit> parsedUnits, CompilerConfiguration config,
DartCompilerMainContext context) {
super(app, Collections.<LibrarySource>emptyList(), config, context);
this.resolvedLibraries = resolvedLibraries;
this.parsedUnits = parsedUnits;
addResolvedLibraries(resolvedLibraries);
}
-
+
@Override
Collection<LibraryUnit> getLibrariesToProcess() {
if (librariesToProcess == null) {
@@ -911,20 +906,31 @@ public class DartCompiler {
return compilerOptions;
}
- public static void main(String[] args) {
+ public static void main(final String[] topArgs) {
Tracer.init();
- CompilerOptions topCompilerOptions = processCommandLineOptions(args);
+ CompilerOptions topCompilerOptions = processCommandLineOptions(topArgs);
boolean result = false;
try {
if (topCompilerOptions.shouldBatch()) {
- if (args.length > 1) {
+ if (topArgs.length > 1) {
System.err.println("(Extra arguments specified with -batch ignored.)");
}
- UnitTestBatchRunner.runAsBatch(args, new Invocation() {
+ UnitTestBatchRunner.runAsBatch(topArgs, new Invocation() {
@Override
- public boolean invoke(String[] args) throws Throwable {
- CompilerOptions compilerOptions = processCommandLineOptions(args);
+ public boolean invoke(String[] lineArgs) throws Throwable {
+ List<String> allArgs = new ArrayList<String>();
+ for (String arg: topArgs) {
+ if (!arg.equals("-batch")) {
+ allArgs.add(arg);
+ }
+ }
+ for (String arg: lineArgs) {
+ allArgs.add(arg);
+ }
+
+ CompilerOptions compilerOptions = processCommandLineOptions(
+ allArgs.toArray(new String[allArgs.size()]));
if (compilerOptions.shouldBatch()) {
System.err.println("-batch ignored: Already in batch mode.");
}

Powered by Google App Engine
This is Rietveld 408576698