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