| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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.analyzer_compile; | 5 library fasta.analyzer_compile; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:io' show exitCode; | 9 import 'dart:io' show exitCode; |
| 10 | 10 |
| 11 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget; | 11 import 'package:analyzer/src/fasta/analyzer_target.dart' show AnalyzerTarget; |
| 12 | 12 |
| 13 import 'package:front_end/src/fasta/compiler_command_line.dart' | 13 import 'package:front_end/src/fasta/compiler_command_line.dart' |
| 14 show CompilerCommandLine; | 14 show CompilerCommandLine; |
| 15 | 15 |
| 16 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; | 16 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; |
| 17 | 17 |
| 18 import 'package:front_end/src/fasta/ticker.dart' show Ticker; | 18 import 'package:front_end/src/fasta/ticker.dart' show Ticker; |
| 19 | 19 |
| 20 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; | 20 import 'package:front_end/src/fasta/fasta.dart' show CompileTask; |
| 21 | 21 |
| 22 import 'package:front_end/src/fasta/errors.dart' show InputError; | 22 import 'package:front_end/src/fasta/deprecated_problems.dart' |
| 23 show deprecated_InputError; |
| 23 | 24 |
| 24 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; | 25 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; |
| 25 | 26 |
| 26 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; | 27 import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; |
| 27 | 28 |
| 28 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); | 29 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); |
| 29 | 30 |
| 30 Future<Uri> compile(List<String> arguments) async { | 31 Future<Uri> compile(List<String> arguments) async { |
| 31 try { | 32 try { |
| 32 return await CompilerCommandLine.withGlobalOptions("kompile", arguments, | 33 return await CompilerCommandLine.withGlobalOptions("kompile", arguments, |
| 33 (CompilerContext c) async { | 34 (CompilerContext c) async { |
| 34 if (c.options.verbose) { | 35 if (c.options.verbose) { |
| 35 print("Compiling via analyzer: ${arguments.join(' ')}"); | 36 print("Compiling via analyzer: ${arguments.join(' ')}"); |
| 36 } | 37 } |
| 37 AnalyzerCompileTask task = | 38 AnalyzerCompileTask task = |
| 38 new AnalyzerCompileTask(c, new Ticker(isVerbose: c.options.verbose)); | 39 new AnalyzerCompileTask(c, new Ticker(isVerbose: c.options.verbose)); |
| 39 return await task.compile(); | 40 return await task.compile(); |
| 40 }); | 41 }); |
| 41 } on InputError catch (e) { | 42 } on deprecated_InputError catch (e) { |
| 42 exitCode = 1; | 43 exitCode = 1; |
| 43 print(e.format()); | 44 print(e.deprecated_format()); |
| 44 return null; | 45 return null; |
| 45 } | 46 } |
| 46 } | 47 } |
| 47 | 48 |
| 48 class AnalyzerCompileTask extends CompileTask { | 49 class AnalyzerCompileTask extends CompileTask { |
| 49 AnalyzerCompileTask(CompilerContext c, Ticker ticker) : super(c, ticker); | 50 AnalyzerCompileTask(CompilerContext c, Ticker ticker) : super(c, ticker); |
| 50 | 51 |
| 51 @override | 52 @override |
| 52 AnalyzerTarget createKernelTarget( | 53 AnalyzerTarget createKernelTarget( |
| 53 DillTarget dillTarget, TranslateUri uriTranslator, bool strongMode) { | 54 DillTarget dillTarget, TranslateUri uriTranslator, bool strongMode) { |
| 54 return new AnalyzerTarget( | 55 return new AnalyzerTarget( |
| 55 dillTarget, uriTranslator, strongMode, c.uriToSource); | 56 dillTarget, uriTranslator, strongMode, c.uriToSource); |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 | 59 |
| 59 main(List<String> arguments) async { | 60 main(List<String> arguments) async { |
| 60 for (int i = 0; i < iterations; i++) { | 61 for (int i = 0; i < iterations; i++) { |
| 61 if (i > 0) { | 62 if (i > 0) { |
| 62 print("\n"); | 63 print("\n"); |
| 63 } | 64 } |
| 64 await compile(arguments); | 65 await compile(arguments); |
| 65 } | 66 } |
| 66 } | 67 } |
| OLD | NEW |