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..2d0cbd2768da835d6d335eafe5101772e6bfde66 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,17 @@ 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) { |
+ SourceFile sourceFile; |
+ if (data is List<int>) { |
+ sourceFile = new Utf8BytesSourceFile(resourceUri.toString(), data); |
kasperl
2013/10/17 08:50:39
Consider doing resourceUri.toString only once.
lukas
2013/10/17 17:49:34
Done.
|
+ } else if (data is String) { |
+ sourceFile = new StringSourceFile(resourceUri.toString(), 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 |