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

Unified Diff: dart/frog/leg/apiimpl.dart

Issue 9866006: Add library mapping. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 | « no previous file | dart/frog/leg/compiler.dart » ('j') | dart/frog/leg/frog_leg.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/apiimpl.dart
diff --git a/dart/frog/leg/apiimpl.dart b/dart/frog/leg/apiimpl.dart
index 53f71d719b33372e0ba4017d358ad4305e6df850..67248b9a0ec98d1ae7de77d84d50cd28ecae627a 100644
--- a/dart/frog/leg/apiimpl.dart
+++ b/dart/frog/leg/apiimpl.dart
@@ -11,6 +11,7 @@
#import('../lang.dart', prefix: 'frog');
#import('api.dart');
#import('../../lib/uri/uri.dart');
+#import('library_map.dart');
class Compiler extends leg.Compiler {
ReadUriFromString provider;
@@ -20,10 +21,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;
}
@@ -49,27 +50,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 | « no previous file | dart/frog/leg/compiler.dart » ('j') | dart/frog/leg/frog_leg.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698