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

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

Issue 27510003: Scanner for UTF-8 byte arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Re-add ArrayBasedScanner, minor fixes. Created 7 years, 2 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
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

Powered by Google App Engine
This is Rietveld 408576698