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

Side by Side Diff: pkg/front_end/lib/src/fasta/fasta.dart

Issue 2742333006: Move patch file generation to fasta. (Closed)
Patch Set: Extract method. Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library fasta; 5 library fasta;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:convert' show JSON; 9 import 'dart:convert' show JSON;
10 10
11 import 'dart:io' show BytesBuilder, Directory, File, exitCode; 11 import 'dart:io' show BytesBuilder, Directory, File, exitCode;
12 12
13 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; 13 import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
14 14
15 import 'package:kernel/kernel.dart' show Program; 15 import 'package:kernel/kernel.dart' show Program;
16 16
17 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; 17 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget;
18 18
19 import 'compiler_command_line.dart' show CompilerCommandLine; 19 import 'compiler_command_line.dart' show CompilerCommandLine;
20 20
21 import 'compiler_context.dart' show CompilerContext; 21 import 'compiler_context.dart' show CompilerContext;
22 22
23 import 'errors.dart' show InputError, formatUnexpected, inputError, reportCrash; 23 import 'errors.dart' show InputError, formatUnexpected, inputError, reportCrash;
24 24
25 import 'kernel/kernel_target.dart' show KernelTarget; 25 import 'kernel/kernel_target.dart' show KernelTarget;
26 26
27 import 'dill/dill_target.dart' show DillTarget; 27 import 'dill/dill_target.dart' show DillTarget;
28 28
29 import 'compile_platform.dart' show compilePlatformInternal;
30
29 import 'ticker.dart' show Ticker; 31 import 'ticker.dart' show Ticker;
30 32
31 import 'translate_uri.dart' show TranslateUri; 33 import 'translate_uri.dart' show TranslateUri;
32 34
33 import 'vm.dart' show CompilationResult; 35 import 'vm.dart' show CompilationResult;
34 36
35 const bool summary = const bool.fromEnvironment("summary", defaultValue: false); 37 const bool summary = const bool.fromEnvironment("summary", defaultValue: false);
36 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); 38 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1);
37 39
38 compileEntryPoint(List<String> arguments) async { 40 compileEntryPoint(List<String> arguments) async {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 191
190 // Write the program to a list of bytes and return it. 192 // Write the program to a list of bytes and return it.
191 var sink = new ByteSink(); 193 var sink = new ByteSink();
192 new BinaryPrinter(sink).writeProgramFile(program); 194 new BinaryPrinter(sink).writeProgramFile(program);
193 return new CompilationResult.ok(sink.builder.takeBytes()); 195 return new CompilationResult.ok(sink.builder.takeBytes());
194 } catch (e, s) { 196 } catch (e, s) {
195 return reportCrash(e, s, fileName); 197 return reportCrash(e, s, fileName);
196 } 198 }
197 } 199 }
198 200
201 Future compilePlatform(Uri patchedSdk, Uri output,
202 {Uri packages, bool verbose: false}) async {
203 Ticker ticker = new Ticker(isVerbose: verbose);
204 await CompilerCommandLine.withGlobalOptions("", [""], (CompilerContext c) {
205 c.options.options["--packages"] = packages;
206 if (verbose) {
207 c.options.options["--verbose"] = true;
208 }
209 return compilePlatformInternal(c, ticker, patchedSdk, output);
210 });
211 }
212
213 Future writeDepsFile(Uri script, Uri depsFile, Uri output,
214 {Uri packages,
215 Uri platform,
216 Iterable<Uri> extraDependencies,
217 bool verbose: false}) async {
218 Ticker ticker = new Ticker(isVerbose: verbose);
219 await CompilerCommandLine.withGlobalOptions("", [""],
220 (CompilerContext c) async {
221 c.options.options["--packages"] = packages;
222 if (verbose) {
223 c.options.options["--verbose"] = true;
224 }
225
226 TranslateUri uriTranslator =
227 await TranslateUri.parse(c.options.sdk, c.options.packages);
228 ticker.logMs("Read packages file");
229 DillTarget dillTarget = new DillTarget(ticker, uriTranslator)
230 ..read(platform);
231 KernelTarget kernelTarget =
232 new KernelTarget(dillTarget, uriTranslator, c.uriToSource);
233
234 kernelTarget.read(script);
235 await dillTarget.writeOutline(null);
236 await kernelTarget.loader.buildOutlines();
237 await kernelTarget.writeDepsFile(output, depsFile,
238 extraDependencies: extraDependencies);
239 });
240 }
241
199 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28316 242 // TODO(ahe): https://github.com/dart-lang/sdk/issues/28316
200 class ByteSink implements Sink<List<int>> { 243 class ByteSink implements Sink<List<int>> {
201 final BytesBuilder builder = new BytesBuilder(); 244 final BytesBuilder builder = new BytesBuilder();
202 245
203 void add(List<int> data) { 246 void add(List<int> data) {
204 builder.add(data); 247 builder.add(data);
205 } 248 }
206 249
207 void close() { 250 void close() {
208 // Nothing to do. 251 // Nothing to do.
209 } 252 }
210 } 253 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/compile_platform.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698