| Index: pkg/compiler/lib/src/io/source_file.dart
|
| diff --git a/pkg/compiler/lib/src/io/source_file.dart b/pkg/compiler/lib/src/io/source_file.dart
|
| index 2710be7f47e7505acf574958165653c77c73abc3..ff47c16eb54d6c4a921ee064bb290a0b72955da6 100644
|
| --- a/pkg/compiler/lib/src/io/source_file.dart
|
| +++ b/pkg/compiler/lib/src/io/source_file.dart
|
| @@ -9,15 +9,17 @@ import 'dart:math';
|
| import 'dart:typed_data' show Uint8List;
|
|
|
| import 'package:kernel/ast.dart' as kernel show Location, Source;
|
| -
|
| import 'location_provider.dart' show LocationProvider;
|
| +import '../../compiler_new.dart';
|
|
|
| /// Represents a file of source code. The content can be either a [String] or
|
| /// a UTF-8 encoded [List<int>] of bytes.
|
| -abstract class SourceFile implements LocationProvider {
|
| +abstract class SourceFile<T> implements Input<T>, LocationProvider {
|
| /// The absolute URI of the source file.
|
| Uri get uri;
|
|
|
| + InputKind get inputKind => InputKind.utf8;
|
| +
|
| kernel.Source cachedKernelSource;
|
|
|
| kernel.Source get kernelSource {
|
| @@ -166,7 +168,7 @@ List<int> _zeroTerminateIfNecessary(List<int> bytes) {
|
| return result;
|
| }
|
|
|
| -class Utf8BytesSourceFile extends SourceFile {
|
| +class Utf8BytesSourceFile extends SourceFile<List<int>> {
|
| final Uri uri;
|
|
|
| /// The UTF-8 encoded content of the source file.
|
| @@ -179,6 +181,8 @@ class Utf8BytesSourceFile extends SourceFile {
|
| Utf8BytesSourceFile(this.uri, List<int> content)
|
| : this.zeroTerminatedContent = _zeroTerminateIfNecessary(content);
|
|
|
| + List<int> get data => zeroTerminatedContent;
|
| +
|
| String slowText() {
|
| // Don't convert the trailing zero byte.
|
| return UTF8.decoder
|
| @@ -220,7 +224,7 @@ class CachingUtf8BytesSourceFile extends Utf8BytesSourceFile {
|
| }
|
| }
|
|
|
| -class StringSourceFile extends SourceFile {
|
| +class StringSourceFile extends SourceFile<String> {
|
| final Uri uri;
|
| final String filename;
|
| final String text;
|
| @@ -233,6 +237,8 @@ class StringSourceFile extends SourceFile {
|
| StringSourceFile.fromName(String filename, String text)
|
| : this(new Uri(path: filename), filename, text);
|
|
|
| + String get data => text;
|
| +
|
| int get length => text.length;
|
| set length(int v) {}
|
|
|
| @@ -244,3 +250,13 @@ class StringSourceFile extends SourceFile {
|
|
|
| String slowSubstring(int start, int end) => text.substring(start, end);
|
| }
|
| +
|
| +/// Binary input data.
|
| +class Binary implements Input<List<int>> {
|
| + final Uri uri;
|
| + final List<int> data;
|
| +
|
| + Binary(this.uri, this.data);
|
| +
|
| + InputKind get inputKind => InputKind.binary;
|
| +}
|
|
|