| OLD | NEW |
| 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 |
| 1 import 'dart:async'; | 5 import 'dart:async'; |
| 2 | 6 |
| 3 import 'package:front_end/kernel_generator.dart'; | 7 import 'package:front_end/kernel_generator.dart'; |
| 4 import 'package:front_end/compiler_options.dart'; | 8 import 'package:front_end/compiler_options.dart'; |
| 5 import 'package:kernel/binary/ast_to_binary.dart'; | 9 import 'package:kernel/binary/ast_to_binary.dart'; |
| 6 import 'package:kernel/kernel.dart' show Program; | 10 import 'package:kernel/kernel.dart' show Program; |
| 7 | 11 |
| 8 Future dumpToSink(Program program, StreamSink<List<int>> sink) { | 12 Future dumpToSink(Program program, StreamSink<List<int>> sink) { |
| 9 new BinaryPrinter(sink).writeProgramFile(program); | 13 new BinaryPrinter(sink).writeProgramFile(program); |
| 10 return sink.close(); | 14 return sink.close(); |
| 11 } | 15 } |
| 12 | 16 |
| 13 Future kernelToSink(Uri entry, StreamSink<List<int>> sink) async { | 17 Future kernelToSink(Uri entry, StreamSink<List<int>> sink) async { |
| 14 var program = await kernelForProgram( | 18 var program = await kernelForProgram( |
| 15 entry, | 19 entry, |
| 16 new CompilerOptions() | 20 new CompilerOptions() |
| 17 ..sdkRoot = new Uri.file('sdk') | 21 ..sdkRoot = new Uri.file('sdk') |
| 18 ..packagesFileUri = new Uri.file('.packages') | 22 ..packagesFileUri = new Uri.file('.packages') |
| 19 ..onError = (e) => print(e.message)); | 23 ..onError = (e) => print(e.message)); |
| 20 | 24 |
| 21 await dumpToSink(program, sink); | 25 await dumpToSink(program, sink); |
| 22 } | 26 } |
| 23 | 27 |
| 24 main(args) async { | 28 main(args) async { |
| 25 kernelToSink( | 29 kernelToSink( |
| 26 Uri.base.resolve(args[0]), | 30 Uri.base.resolve(args[0]), |
| 27 // TODO(sigmund,hausner): define memory type where to dump binary data. | 31 // TODO(sigmund,hausner): define memory type where to dump binary data. |
| 28 new StreamController<List<int>>.broadcast().sink); | 32 new StreamController<List<int>>.broadcast().sink); |
| 29 } | 33 } |
| OLD | NEW |