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

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

Issue 10032015: Add support for the package: directive in Frog and dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review change Created 8 years, 8 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 | « frog/reader.dart ('k') | no next file » | 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 4301708c40a05ee726362258b91490a18f9a907f..5becdeaa30d1c367cf8ee4f0fe1025999f14d6ac 100644
--- a/lib/compiler/implementation/apiimpl.dart
+++ b/lib/compiler/implementation/apiimpl.dart
@@ -19,6 +19,7 @@ class Compiler extends leg.Compiler {
ReadUriFromString provider;
DiagnosticHandler handler;
Uri libraryRoot;
+ Uri packageRoot;
ahe 2012/04/13 09:30:18 I think this should be initialized by the construc
List<String> options;
bool mockableLibraryUsed = false;
@@ -38,6 +39,8 @@ class Compiler extends leg.Compiler {
leg.Script readScript(Uri uri, [leg.ScriptTag node]) {
if (uri.scheme == 'dart') {
uri = translateDartUri(uri, node);
+ } else if (uri.scheme == 'package') {
+ uri = translatePackageUri(uri, node);
}
String text = "";
try {
@@ -65,12 +68,20 @@ class Compiler extends leg.Compiler {
return libraryRoot.resolve(path);
}
+ translatePackageUri(Uri uri, leg.ScriptTag node) =>
+ packageRoot.resolve(uri.path);
+
bool run(Uri uri) {
- bool success = super.run(uri);
- for (final task in tasks) {
- log('${task.name} took ${task.timing}msec');
+ try {
+ packageRoot = uri.resolve('packages/');
+ bool success = super.run(uri);
+ for (final task in tasks) {
+ log('${task.name} took ${task.timing}msec');
+ }
+ return success;
+ } finally {
+ packageRoot = null;
ahe 2012/04/13 09:30:18 This "scoping" of packageRoot is weird to me, and
}
- return success;
}
void reportDiagnostic(leg.SourceSpan span, String message, bool fatal) {
« no previous file with comments | « frog/reader.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698