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

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

Issue 9866006: Add library mapping. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased 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
« no previous file with comments | « dart/frog/tests/leg/src/mock_compiler.dart ('k') | dart/lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/apiimpl.dart
diff --git a/dart/lib/compiler/implementation/apiimpl.dart b/dart/lib/compiler/implementation/apiimpl.dart
index 3b9b5318c2fa5ea338930ec4f7a602d77e2e86f7..4301708c40a05ee726362258b91490a18f9a907f 100644
--- a/dart/lib/compiler/implementation/apiimpl.dart
+++ b/dart/lib/compiler/implementation/apiimpl.dart
@@ -12,6 +12,8 @@
#import('../../../frog/lang.dart', prefix: 'frog');
#import('../compiler.dart');
#import('../../uri/uri.dart');
+#import('library_map.dart');
+
class Compiler extends leg.Compiler {
ReadUriFromString provider;
@@ -21,10 +23,10 @@ class Compiler extends leg.Compiler {
bool mockableLibraryUsed = false;
Compiler(this.provider, this.handler, this.libraryRoot, this.options)
- : super.withCurrentDirectory(null, tracer: new ssa.HTracer());
+ : super(tracer: new ssa.HTracer());
- leg.LibraryElement scanBuiltinLibrary(String filename) {
- Uri uri = libraryRoot.resolve(filename);
+ leg.LibraryElement scanBuiltinLibrary(String path) {
+ Uri uri = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]);
leg.LibraryElement library = scanner.loadLibrary(uri, null);
return library;
}
@@ -50,27 +52,17 @@ class Compiler extends leg.Compiler {
}
translateDartUri(Uri uri, leg.ScriptTag node) {
- String uriName = uri.toString();
- // TODO(ahe): Clean this up.
- if (uriName == 'dart:dom') {
- mockableLibraryUsed = true;
- return libraryRoot.resolve('../../../../lib/dom/frog/dom_frog.dart');
- } else if (uriName == 'dart:html') {
- mockableLibraryUsed = true;
- return libraryRoot.resolve('../../../../lib/html/frog/html_frog.dart');
- } else if (uriName == 'dart:json') {
- return libraryRoot.resolve('../../../../lib/json/json.dart');
- } else if (uriName == 'dart:isolate') {
- return libraryRoot.resolve('../../../../lib/isolate/isolate_leg.dart');
- } else if (uriName == 'dart:io') {
+ String path = DART2JS_LIBRARY_MAP[uri.path];
+ if (path === null || uri.path.startsWith('_')) {
+ reportError(node, 'library not found ${uri}');
+ return null;
+ }
+ if (uri.path == 'dom' || uri.path == 'html' || uri.path == 'io') {
+ // TODO(ahe): Get rid of mockableLibraryUsed when test.dart
+ // supports this use case better.
mockableLibraryUsed = true;
- return libraryRoot.resolve('io.dart');
- } else if (uriName == 'dart:utf') {
- return libraryRoot.resolve('../../../../lib/utf/utf.dart');
- } else if (uriName == 'dart:uri') {
- return libraryRoot.resolve('../../../../lib/uri/uri.dart');
}
- reportError(node, "library not found $uriName");
+ return libraryRoot.resolve(path);
}
bool run(Uri uri) {
« no previous file with comments | « dart/frog/tests/leg/src/mock_compiler.dart ('k') | dart/lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698