Index: lib/compiler/implementation/apiimpl.dart |
diff --git a/lib/compiler/implementation/apiimpl.dart b/lib/compiler/implementation/apiimpl.dart |
index 376a136b54a437dc62a203e841550d0b91305dec..65fd2b66e0bb4caa249acbb14c64ee1137e2cf3a 100644 |
--- a/lib/compiler/implementation/apiimpl.dart |
+++ b/lib/compiler/implementation/apiimpl.dart |
@@ -11,7 +11,7 @@ |
#import('tree/tree.dart', prefix: 'tree'); |
#import('elements/elements.dart', prefix: 'elements'); |
#import('ssa/tracer.dart', prefix: 'ssa'); |
-#import('library_map.dart'); |
+#import('../../../lib/_internal/libraries.dart'); |
#import('source_file.dart'); |
class Compiler extends leg.Compiler { |
@@ -24,16 +24,38 @@ class Compiler extends leg.Compiler { |
Compiler(this.provider, this.handler, this.libraryRoot, this.packageRoot, |
List<String> options) |
- : this.options = options, |
- super( |
- tracer: new ssa.HTracer(), |
- enableTypeAssertions: options.indexOf('--enable-checked-mode') != -1, |
- enableUserAssertions: options.indexOf('--enable-checked-mode') != -1, |
- emitJavascript: options.indexOf('--output-type=dart') == -1, |
- minify: options.indexOf('--minify') != -1); |
+ : this.options = options, |
+ super( |
+ tracer: new ssa.HTracer(), |
+ enableTypeAssertions: _hasOption(options, '--enable-checked-mode'), |
+ enableUserAssertions: _hasOption(options, '--enable-checked-mode'), |
+ emitJavascript: _hasOption(options, '--output-type=dart'), |
+ minify: options.indexOf('--minify') != -1); |
+ |
+ static bool _hasOption(List<String> options, String option) { |
+ return options.indexOf(option) >= 0; |
+ } |
+ |
+ String dartLibraryPath(String dartLibraryName) { |
Johnni Winther
2012/08/28 13:26:04
Rename to getDartLibraryPath.
Lasse Reichstein Nielsen
2012/08/29 09:09:39
Renamed to lookupDartLibraryPath to make it a verb
|
+ LibraryInfo info = LIBRARIES[dartLibraryName]; |
+ if (info == null) return null; |
+ if (!info.isDart2jsLibrary) return null; |
+ String path = info.dart2jsPath; |
+ if (path == null) path = info.path; |
+ return "lib/$path"; |
+ } |
+ |
+ String dartPatchPath(String dartLibraryName) { |
Johnni Winther
2012/08/28 13:26:04
Rename to getDartPatchPath.
Lasse Reichstein Nielsen
2012/08/29 09:09:39
Dittos.
|
+ LibraryInfo info = LIBRARIES[dartLibraryName]; |
+ if (info == null) return null; |
+ if (!info.isDart2jsLibrary) return null; |
+ String path = info.dart2jsPatchPath; |
+ if (path == null) return null; |
+ return "lib/$path"; |
+ } |
elements.LibraryElement scanBuiltinLibrary(String path) { |
- Uri uri = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path].libraryPath); |
+ Uri uri = libraryRoot.resolve(dartLibraryPath(path)); |
Uri canonicalUri; |
if (path.startsWith("_")) { |
canonicalUri = uri; |
@@ -77,13 +99,14 @@ class Compiler extends leg.Compiler { |
} |
Uri translateDartUri(Uri uri, tree.Node node) { |
- String path = DART2JS_LIBRARY_MAP[uri.path].libraryPath; |
- if (path === null || uri.path.startsWith('_')) { |
+ String path = dartLibraryPath(uri.path); |
+ if (path === null || LIBRARIES[uri.path].category == "Internal") { |
reportError(node, 'library not found ${uri}'); |
return null; |
} |
- if (uri.path == 'dom_deprecated' |
- || uri.path == 'html' || uri.path == 'io') { |
+ if (uri.path == 'dom_deprecated' || |
+ uri.path == 'html' || |
+ uri.path == 'io') { |
// TODO(ahe): Get rid of mockableLibraryUsed when test.dart |
// supports this use case better. |
mockableLibraryUsed = true; |
@@ -92,7 +115,7 @@ class Compiler extends leg.Compiler { |
} |
Uri resolvePatchUri(String dartLibraryPath) { |
- String patchPath = DART2JS_LIBRARY_MAP[dartLibraryPath].patchPath; |
+ String patchPath = dartPatchPath(dartLibraryPath); |
if (patchPath === null) return null; |
return libraryRoot.resolve(patchPath); |
} |