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

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

Issue 2690063002: Refactor CompilerOutput (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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/compiler.dart » ('j') | no next file with comments »
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';
(...skipping 18 matching lines...) Expand all
29 /// 29 ///
30 /// The following text is non-normative: 30 /// The following text is non-normative:
31 /// 31 ///
32 /// It is recommended to return a UTF-8 encoded list of bytes because the 32 /// 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 33 /// 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 34 /// 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. 35 /// the case, the entire data structure is copied before scanning.
36 Future/*<String | List<int>>*/ readFromUri(Uri uri); 36 Future/*<String | List<int>>*/ readFromUri(Uri uri);
37 } 37 }
38 38
39 /// Output types used in `CompilerOutput.createOutputSink`.
40 enum OutputType {
41 /// The main JavaScript output.
42 js,
43
44 /// A deferred JavaScript output part.
45 jsPart,
46
47 /// A source map for a JavaScript output.
48 sourceMap,
49
50 /// Serialization data output.
51 serializationData,
52
53 /// Additional information requested by the user, such dump info or a deferred
54 /// map.
55 info,
56
57 /// Implementation specific output used for debugging the compiler.
58 debug,
59 }
60
61 /// Sink interface used for generating output from the compiler.
62 abstract class OutputSink {
63 /// Adds [text] to the sink.
64 void add(String text);
65
66 /// Closes the sink.
67 void close();
68 }
69
39 /// Interface for producing output from the compiler. That is, JavaScript target 70 /// Interface for producing output from the compiler. That is, JavaScript target
40 /// files, source map files, dump info files, etc. 71 /// files, source map files, dump info files, etc.
41 abstract class CompilerOutput { 72 abstract class CompilerOutput {
42 /// Returns an [EventSink] that will serve as compiler output for the given 73 /// Returns an [OutputSink] that will serve as compiler output for the given
43 /// component. 74 /// component.
44 /// 75 ///
45 /// Components are identified by [name] and [extension]. By convention, 76 /// Components are identified by [name], [extension], and [type]. By
46 /// the empty string [:"":] will represent the main script 77 /// convention, the empty string `""` will represent the main output of the
47 /// (corresponding to the script parameter of [compile]) even if the 78 /// provided [type]. [name] and [extension] are otherwise suggestive.
48 /// main script is a library. For libraries that are compiled 79 // TODO(johnniwinther): Replace [name] and [extension] with something like
49 /// separately, the library name is used. 80 // [id] and [uri].
50 /// 81 OutputSink createOutputSink(String name, String extension, OutputType type);
51 /// At least the following extensions can be expected:
52 ///
53 /// * "js" for JavaScript output.
54 /// * "js.map" for source maps.
55 /// * "dart" for Dart output.
56 /// * "dart.map" for source maps.
57 ///
58 /// As more features are added to the compiler, new names and
59 /// extensions may be introduced.
60 EventSink<String> createEventSink(String name, String extension);
61 } 82 }
62 83
63 /// Interface for receiving diagnostic message from the compiler. That is, 84 /// Interface for receiving diagnostic message from the compiler. That is,
64 /// errors, warnings, hints, etc. 85 /// errors, warnings, hints, etc.
65 abstract class CompilerDiagnostics { 86 abstract class CompilerDiagnostics {
66 /// Invoked by the compiler to report diagnostics. If [uri] is `null`, so are 87 /// Invoked by the compiler to report diagnostics. If [uri] is `null`, so are
67 /// [begin] and [end]. No other arguments may be `null`. If [uri] is not 88 /// [begin] and [end]. No other arguments may be `null`. If [uri] is not
68 /// `null`, neither are [begin] and [end]. [uri] indicates the compilation 89 /// `null`, neither are [begin] and [end]. [uri] indicates the compilation
69 /// unit from where the diagnostic originates. [begin] and [end] are 90 /// unit from where the diagnostic originates. [begin] and [end] are
70 /// zero-based character offsets from the beginning of the compilation unit. 91 /// zero-based character offsets from the beginning of the compilation unit.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (compilerOutput == null) { 140 if (compilerOutput == null) {
120 throw new ArgumentError("compilerOutput must be non-null"); 141 throw new ArgumentError("compilerOutput must be non-null");
121 } 142 }
122 143
123 CompilerImpl compiler = new CompilerImpl( 144 CompilerImpl compiler = new CompilerImpl(
124 compilerInput, compilerOutput, compilerDiagnostics, compilerOptions); 145 compilerInput, compilerOutput, compilerDiagnostics, compilerOptions);
125 return compiler.run(compilerOptions.entryPoint).then((bool success) { 146 return compiler.run(compilerOptions.entryPoint).then((bool success) {
126 return new CompilationResult(compiler, isSuccess: success); 147 return new CompilationResult(compiler, isSuccess: success);
127 }); 148 });
128 } 149 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698