| OLD | NEW |
| 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.compile_platform; | 5 library fasta.compile_platform; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'kernel/verifier.dart' show verifyProgram; | 9 import 'kernel/verifier.dart' show verifyProgram; |
| 10 | 10 |
| 11 import 'ticker.dart' show Ticker; | 11 import 'ticker.dart' show Ticker; |
| 12 | 12 |
| 13 import 'dart:io' show exitCode; | 13 import 'dart:io' show exitCode; |
| 14 | 14 |
| 15 import 'compiler_command_line.dart' show CompilerCommandLine; | 15 import 'compiler_command_line.dart' show CompilerCommandLine; |
| 16 | 16 |
| 17 import 'compiler_context.dart' show CompilerContext; | 17 import 'compiler_context.dart' show CompilerContext; |
| 18 | 18 |
| 19 import 'errors.dart' show InputError; | 19 import 'errors.dart' show InputError; |
| 20 | 20 |
| 21 import 'kernel/kernel_target.dart' show KernelTarget; | 21 import 'kernel/kernel_target.dart' show KernelTarget; |
| 22 | 22 |
| 23 import 'dill/dill_target.dart' show DillTarget; | 23 import 'dill/dill_target.dart' show DillTarget; |
| 24 | 24 |
| 25 import 'translate_uri.dart' show TranslateUri; | 25 import 'translate_uri.dart' show TranslateUri; |
| 26 | 26 |
| 27 import 'ast_kind.dart' show AstKind; | |
| 28 | |
| 29 Future main(List<String> arguments) async { | 27 Future main(List<String> arguments) async { |
| 30 Ticker ticker = new Ticker(); | 28 Ticker ticker = new Ticker(); |
| 31 try { | 29 try { |
| 32 await CompilerCommandLine.withGlobalOptions("compile_platform", arguments, | 30 await CompilerCommandLine.withGlobalOptions("compile_platform", arguments, |
| 33 (CompilerContext c) => compilePlatform(c, ticker)); | 31 (CompilerContext c) => compilePlatform(c, ticker)); |
| 34 } on InputError catch (e) { | 32 } on InputError catch (e) { |
| 35 exitCode = 1; | 33 exitCode = 1; |
| 36 print(e.format()); | 34 print(e.format()); |
| 37 return null; | 35 return null; |
| 38 } | 36 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 53 | 51 |
| 54 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); | 52 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); |
| 55 KernelTarget kernelTarget = | 53 KernelTarget kernelTarget = |
| 56 new KernelTarget(dillTarget, uriTranslator, c.uriToSource); | 54 new KernelTarget(dillTarget, uriTranslator, c.uriToSource); |
| 57 | 55 |
| 58 kernelTarget.read(Uri.parse("dart:core")); | 56 kernelTarget.read(Uri.parse("dart:core")); |
| 59 await dillTarget.writeOutline(null); | 57 await dillTarget.writeOutline(null); |
| 60 await kernelTarget.writeOutline(output); | 58 await kernelTarget.writeOutline(output); |
| 61 | 59 |
| 62 if (exitCode != 0) return null; | 60 if (exitCode != 0) return null; |
| 63 await kernelTarget.writeProgram(output, AstKind.Kernel); | 61 await kernelTarget.writeProgram(output); |
| 64 if (c.options.dumpIr) { | 62 if (c.options.dumpIr) { |
| 65 kernelTarget.dumpIr(); | 63 kernelTarget.dumpIr(); |
| 66 } | 64 } |
| 67 if (c.options.verify) { | 65 if (c.options.verify) { |
| 68 try { | 66 try { |
| 69 verifyProgram(kernelTarget.program); | 67 verifyProgram(kernelTarget.program); |
| 70 ticker.logMs("Verified program"); | 68 ticker.logMs("Verified program"); |
| 71 } catch (e, s) { | 69 } catch (e, s) { |
| 72 exitCode = 1; | 70 exitCode = 1; |
| 73 print("Verification of program failed: $e"); | 71 print("Verification of program failed: $e"); |
| 74 if (s != null && c.options.verbose) { | 72 if (s != null && c.options.verbose) { |
| 75 print(s); | 73 print(s); |
| 76 } | 74 } |
| 77 } | 75 } |
| 78 } | 76 } |
| 79 } | 77 } |
| OLD | NEW |