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 2b56ac00003095c547ef53a3d9f48f088646d33d..f72214bfb52b2121edeea9314d037aaab06b1dec 100644 |
--- a/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
+++ b/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
@@ -15,7 +15,7 @@ import '../../libraries.dart'; |
import 'source_file.dart'; |
class Compiler extends leg.Compiler { |
- api.ReadStringFromUri provider; |
+ api.CompilerInputProvider provider; |
api.DiagnosticHandler handler; |
final Uri libraryRoot; |
final Uri packageRoot; |
@@ -176,8 +176,18 @@ class Compiler extends leg.Compiler { |
// [Future] to ensure that we never execute an asynchronous action without setting |
// up the current element of the compiler. |
return new Future.sync(() => callUserProvider(resourceUri)) |
- .then((String text) { |
- SourceFile sourceFile = new SourceFile(resourceUri.toString(), text); |
+ .then((data) { |
ngeoffray
2013/10/18 10:19:37
Fits in previous line?
lukas
2013/10/24 16:48:36
Done.
|
+ SourceFile sourceFile; |
+ String resourceUriString = resourceUri.toString(); |
+ if (data is List<int>) { |
+ sourceFile = new Utf8BytesSourceFile(resourceUriString, data); |
+ } else if (data is String) { |
+ sourceFile = new StringSourceFile(resourceUriString, data); |
+ } else { |
+ String message = "Expected a 'String' or a 'List<int>' from the input " |
+ "provider, but got: ${Error.safeToString(data)}."; |
+ reportReadError(message); |
+ } |
// We use [readableUri] as the URI for the script since need to preserve |
// the scheme in the script because [Script.uri] is used for resolving |
// relative URIs mentioned in the script. See the comment on |