Index: sdk/lib/_internal/compiler/implementation/apiimpl.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/apiimpl.dart b/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
index 5fa3e99fc9dacc0506ce5350f6e2c2b8c4b16945..47495ce1cc214543d91686274990d27fe9eb8ec9 100644 |
--- a/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
+++ b/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
@@ -89,10 +89,7 @@ class Compiler extends leg.Compiler { |
elements.LibraryElement scanBuiltinLibrary(String path) { |
Uri uri = libraryRoot.resolve(lookupLibraryPath(path)); |
- Uri canonicalUri = null; |
- if (!path.startsWith("_")) { |
- canonicalUri = new Uri.fromComponents(scheme: "dart", path: path); |
- } |
+ Uri canonicalUri = new Uri.fromComponents(scheme: "dart", path: path); |
elements.LibraryElement library = |
libraryLoader.loadLibrary(uri, null, canonicalUri); |
return library; |
@@ -102,15 +99,31 @@ class Compiler extends leg.Compiler { |
handler(null, null, null, message, api.Diagnostic.VERBOSE_INFO); |
} |
+ /** |
+ * Resolves the [uri] into a file resource URI. |
+ * |
+ * The [importingUri] holds the canonical uri for the library importing [uri] |
+ * or [:null:] if [uri] is loaded as the main library. The [importingUri] is |
+ * used to grant access to private libraries for platform libraries. |
ahe
2013/01/18 11:03:10
Please document that this method is responsible fo
Johnni Winther
2013/01/21 09:27:54
Done.
|
+ */ |
+ Uri resolveScriptUri(Uri importingUri, Uri uri, [tree.Node node]) { |
ahe
2013/01/18 11:03:10
I like this method.
|
+ if (uri.scheme == 'dart') { |
+ return translateDartUri(importingUri, uri, node); |
+ } |
+ return translateUri(uri, node); |
+ } |
+ |
+ /** |
+ * Reads the script designated by [uri]. |
+ */ |
leg.Script readScript(Uri uri, [tree.Node node]) { |
+ if (!uri.isAbsolute()) throw new ArgumentError(uri); |
ahe
2013/01/18 11:03:10
You should be able to report an (internal) error i
Johnni Winther
2013/01/21 09:27:54
Done.
|
return fileReadingTask.measure(() { |
- if (uri.scheme == 'dart') uri = translateDartUri(uri, node); |
ahe
2013/01/18 11:03:10
I really like that you got rid of this.
|
- var translated = translateUri(uri, node); |
String text = ""; |
try { |
// TODO(ahe): We expect the future to be complete and call value |
// directly. In effect, we don't support truly asynchronous API. |
- text = deprecatedFutureValue(provider(translated)); |
+ text = deprecatedFutureValue(provider(uri)); |
} catch (exception) { |
if (node != null) { |
cancel("$exception", node: node); |
@@ -119,7 +132,7 @@ class Compiler extends leg.Compiler { |
throw new leg.CompilerCancelledException("$exception"); |
} |
} |
- SourceFile sourceFile = new SourceFile(translated.toString(), text); |
+ SourceFile sourceFile = new SourceFile(uri.toString(), text); |
return new leg.Script(uri, sourceFile); |
}); |
} |
@@ -131,9 +144,26 @@ class Compiler extends leg.Compiler { |
} |
} |
- Uri translateDartUri(Uri uri, tree.Node node) { |
+ Uri translateDartUri(Uri sourceUri, Uri uri, tree.Node node) { |
String path = lookupLibraryPath(uri.path); |
- if (path == null || LIBRARIES[uri.path].category == "Internal") { |
+ if (LIBRARIES[uri.path] != null && |
ngeoffray
2013/01/16 15:40:57
Store LIBRARIES[uri.path] in a local variable?
Johnni Winther
2013/01/21 09:27:54
Done.
|
+ LIBRARIES[uri.path].category == "Internal") { |
+ bool allowPrivateLibraryAccess = false; |
+ if (sourceUri != null) { |
+ if (sourceUri.scheme == 'dart' || sourceUri.scheme == 'patch') { |
ahe
2013/01/18 11:03:10
What is the patch scheme?
Johnni Winther
2013/01/21 09:27:54
A new scheme used to provide patch libraries with
ahe
2013/01/21 09:39:38
I don't think it is a good idea to invent new sche
Johnni Winther
2013/01/21 09:45:55
Then I'll have to encode it in the path, like dart
ahe
2013/01/21 10:08:25
I was hoping we could get rid of encoding this inf
Johnni Winther
2013/01/21 10:15:15
Then I think I'd rather go back to having no canon
ahe
2013/01/21 10:18:09
SGTM
|
+ allowPrivateLibraryAccess = true; |
+ } |
+ if (sourceUri.path.contains('dart/tests/compiler/dart2js_native')) { |
+ allowPrivateLibraryAccess = true; |
+ } |
+ } |
+ if (!allowPrivateLibraryAccess) { |
+ log('Internal library $uri is not accessible ' |
ngeoffray
2013/01/16 15:40:57
Why do you log that? Isn't that something that the
ahe
2013/01/18 11:03:10
The user will see an error message like this:
fis
Johnni Winther
2013/01/21 09:27:54
Changed to [reportError].
|
+ '${sourceUri != null ? 'from $sourceUri' : ''}'); |
+ path = null; |
+ } |
+ } |
+ if (path == null) { |
if (node != null) { |
reportError(node, 'library not found ${uri}'); |
} else { |