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

Unified Diff: pkg/compiler/lib/compiler_new.dart

Issue 2897903003: Support loading binary data in dart2js (Closed)
Patch Set: Updated cf. comments Created 3 years, 7 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 | « no previous file | pkg/compiler/lib/src/apiimpl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/compiler_new.dart
diff --git a/pkg/compiler/lib/compiler_new.dart b/pkg/compiler/lib/compiler_new.dart
index ba0bd8439dcd1d81313e6520e26c38219a9a828f..47d39cda67cdf3f4b39979f504fbf5771fc8a6e0 100644
--- a/pkg/compiler/lib/compiler_new.dart
+++ b/pkg/compiler/lib/compiler_new.dart
@@ -18,14 +18,37 @@ export 'compiler.dart' show Diagnostic, PackagesDiscoveryProvider;
// Unless explicitly allowed, passing `null` for any argument to the
// methods of library will result in an Error being thrown.
+/// Input kinds used by [CompilerInput.readFromUri].
+enum InputKind {
+ /// Data is read as UTF8 either as a [String] or a zero-terminated
+ /// `List<int>`.
+ utf8,
+
+ /// Data is read as bytes in a `List<int>`.
+ binary,
+}
+
+/// Interface for data read through [CompilerInput.readFromUri].
+abstract class Input<T> {
+ /// The URI from which data was read.
+ Uri get uri;
+
+ /// The format of the read [data].
+ InputKind get inputKind;
+
+ /// The raw data read from [uri].
+ T get data;
+}
+
/// Interface for providing the compiler with input. That is, Dart source files,
/// package config files, etc.
abstract class CompilerInput {
/// Returns a future that completes to the source corresponding to [uri].
/// If an exception occurs, the future completes with this exception.
///
- /// The source can be represented either as a [:List<int>:] of UTF-8 bytes or
- /// as a [String].
+ /// If [inputKind] is `InputKind.utf8` the source can be represented either as
+ /// a zero-terminated `List<int>` of UTF-8 bytes or as a [String]. If
+ /// [inputKind] is `InputKind.binary` the source is a read a `List<int>`.
///
/// The following text is non-normative:
///
@@ -33,7 +56,7 @@ abstract class CompilerInput {
/// scanner is more efficient in this case. In either case, the data structure
/// is expected to hold a zero element at the last position. If this is not
/// the case, the entire data structure is copied before scanning.
- Future /* <String | List<int>> */ readFromUri(Uri uri);
+ Future<Input> readFromUri(Uri uri, {InputKind inputKind: InputKind.utf8});
}
/// Output types used in `CompilerOutput.createOutputSink`.
« no previous file with comments | « no previous file | pkg/compiler/lib/src/apiimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698