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

Side by Side Diff: pkg/compiler/lib/compiler_new.dart

Issue 2897903003: Support loading binary data in dart2js (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/apiimpl.dart » ('j') | pkg/compiler/lib/src/apiimpl.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// New Compiler API. This API is under construction, use only internally or 5 /// New Compiler API. This API is under construction, use only internally or
6 /// in unittests. 6 /// in unittests.
7 7
8 library compiler_new; 8 library compiler_new;
9 9
10 import 'dart:async'; 10 import 'dart:async';
11 11
12 import 'compiler.dart' show Diagnostic; 12 import 'compiler.dart' show Diagnostic;
13 import 'src/apiimpl.dart'; 13 import 'src/apiimpl.dart';
14 import 'src/options.dart' show CompilerOptions; 14 import 'src/options.dart' show CompilerOptions;
15 15
16 export 'compiler.dart' show Diagnostic, PackagesDiscoveryProvider; 16 export 'compiler.dart' show Diagnostic, PackagesDiscoveryProvider;
17 17
18 // Unless explicitly allowed, passing `null` for any argument to the 18 // Unless explicitly allowed, passing `null` for any argument to the
19 // methods of library will result in an Error being thrown. 19 // methods of library will result in an Error being thrown.
20 20
21 /// Input kinds used by [CompilerInput.readFromUri].
22 enum InputKind {
23 /// Data is read as UTF8 either as a [String] or a zero-terminated
24 /// `List<int>`.
25 utf8,
26
27 /// Data is read as bytes in a `List<int>`.
28 binary,
29 }
30
31 /// Interface for data read through [CompilerInput.readFromUri].
32 abstract class Input<T> {
33 /// The URI from which data was read.
34 Uri get uri;
35
36 /// The format of the read [data].
37 InputKind get inputKind;
38
39 /// The raw data read from [uri].
40 T get data;
41 }
42
21 /// Interface for providing the compiler with input. That is, Dart source files, 43 /// Interface for providing the compiler with input. That is, Dart source files,
22 /// package config files, etc. 44 /// package config files, etc.
23 abstract class CompilerInput { 45 abstract class CompilerInput {
24 /// Returns a future that completes to the source corresponding to [uri]. 46 /// Returns a future that completes to the source corresponding to [uri].
25 /// If an exception occurs, the future completes with this exception. 47 /// If an exception occurs, the future completes with this exception.
26 /// 48 ///
27 /// The source can be represented either as a [:List<int>:] of UTF-8 bytes or 49 /// If [inputKind] is `InputKind.utf8` the source can be represented either as
28 /// as a [String]. 50 /// a zero-terminated `List<int>` of UTF-8 bytes or as a [String]. If
51 /// [inputKind] is `InputKind.binary` the source is a read a `List<int>`.
29 /// 52 ///
30 /// The following text is non-normative: 53 /// The following text is non-normative:
31 /// 54 ///
32 /// It is recommended to return a UTF-8 encoded list of bytes because the 55 /// It is recommended to return a UTF-8 encoded list of bytes because the
33 /// scanner is more efficient in this case. In either case, the data structure 56 /// scanner is more efficient in this case. In either case, the data structure
34 /// is expected to hold a zero element at the last position. If this is not 57 /// is expected to hold a zero element at the last position. If this is not
35 /// the case, the entire data structure is copied before scanning. 58 /// the case, the entire data structure is copied before scanning.
36 Future /* <String | List<int>> */ readFromUri(Uri uri); 59 Future<Input> readFromUri(Uri uri, {InputKind inputKind: InputKind.utf8});
37 } 60 }
38 61
39 /// Output types used in `CompilerOutput.createOutputSink`. 62 /// Output types used in `CompilerOutput.createOutputSink`.
40 enum OutputType { 63 enum OutputType {
41 /// The main JavaScript output. 64 /// The main JavaScript output.
42 js, 65 js,
43 66
44 /// A deferred JavaScript output part. 67 /// A deferred JavaScript output part.
45 jsPart, 68 jsPart,
46 69
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (compilerOutput == null) { 163 if (compilerOutput == null) {
141 throw new ArgumentError("compilerOutput must be non-null"); 164 throw new ArgumentError("compilerOutput must be non-null");
142 } 165 }
143 166
144 CompilerImpl compiler = new CompilerImpl( 167 CompilerImpl compiler = new CompilerImpl(
145 compilerInput, compilerOutput, compilerDiagnostics, compilerOptions); 168 compilerInput, compilerOutput, compilerDiagnostics, compilerOptions);
146 return compiler.run(compilerOptions.entryPoint).then((bool success) { 169 return compiler.run(compilerOptions.entryPoint).then((bool success) {
147 return new CompilationResult(compiler, isSuccess: success); 170 return new CompilationResult(compiler, isSuccess: success);
148 }); 171 });
149 } 172 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/apiimpl.dart » ('j') | pkg/compiler/lib/src/apiimpl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698