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

Unified Diff: lib/compiler/implementation/apiimpl.dart

Issue 10894005: Remove library_map.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove dart:mirror from dart2js and dartdoc. Created 8 years, 4 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
« no previous file with comments | « lib/_internal/libraries.dart ('k') | lib/compiler/implementation/library_map.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/apiimpl.dart
diff --git a/lib/compiler/implementation/apiimpl.dart b/lib/compiler/implementation/apiimpl.dart
index 0847766f976dddb4801ebc5a6e4f93779e4ae26c..e2bed12487ba0374a174d6ebfb45c76525e87b46 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,17 +24,39 @@ 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,
- cutDeclarationTypes: options.indexOf('--cutDeclarationTypes') != -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: _hasOption(options, '--minify'),
+ cutDeclarationTypes: _hasOption(options, '--cutDeclarationTypes'));
+
+ static bool _hasOption(List<String> options, String option) {
ahe 2012/08/29 12:30:21 Why is this method private?
Lasse Reichstein Nielsen 2012/08/29 12:43:53 Because it can't be unnamed, and I can't make it v
+ return options.indexOf(option) >= 0;
+ }
+
+ String lookupDartLibraryPath(String dartLibraryName) {
+ LibraryInfo info = LIBRARIES[dartLibraryName];
+ if (info == null) return null;
ahe 2012/08/29 12:30:21 Please use === as long as the new == semantics are
Lasse Reichstein Nielsen 2012/08/29 12:43:53 The semantics change will not make any difference
+ if (!info.isDart2jsLibrary) return null;
+ String path = info.dart2jsPath;
+ if (path == null) path = info.path;
ahe 2012/08/29 12:30:21 ===
ahe 2012/08/29 12:30:21 This looks like a bail out, but it is not a return
Lasse Reichstein Nielsen 2012/08/29 12:43:53 Done.
+ return "lib/$path";
+ }
+
+ String lookupDartPatchPath(String dartLibraryName) {
ahe 2012/08/29 12:30:21 Remove "dart" from method name. This brings focus
Lasse Reichstein Nielsen 2012/08/29 12:43:53 Done.
+ 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(lookupDartLibraryPath(path));
Uri canonicalUri;
if (path.startsWith("_")) {
canonicalUri = uri;
@@ -78,13 +100,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 = lookupDartLibraryPath(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;
@@ -93,7 +116,7 @@ class Compiler extends leg.Compiler {
}
Uri resolvePatchUri(String dartLibraryPath) {
- String patchPath = DART2JS_LIBRARY_MAP[dartLibraryPath].patchPath;
+ String patchPath = lookupDartPatchPath(dartLibraryPath);
if (patchPath === null) return null;
return libraryRoot.resolve(patchPath);
}
« no previous file with comments | « lib/_internal/libraries.dart ('k') | lib/compiler/implementation/library_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698