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