Chromium Code Reviews| Index: pkg/front_end/lib/src/fasta/fasta.dart |
| diff --git a/pkg/front_end/lib/src/fasta/fasta.dart b/pkg/front_end/lib/src/fasta/fasta.dart |
| index dd56cebac4f7a01111bfe52720e13e512ae6d52e..c5b90295b0cd8665f156200d0d802a6f4764d506 100644 |
| --- a/pkg/front_end/lib/src/fasta/fasta.dart |
| +++ b/pkg/front_end/lib/src/fasta/fasta.dart |
| @@ -12,6 +12,8 @@ import 'dart:io' show BytesBuilder, Directory, File, exitCode; |
| import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter; |
| +import 'package:kernel/binary/tag.dart' show Tag; |
| + |
| import 'package:kernel/kernel.dart' show Program; |
| import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; |
| @@ -150,6 +152,23 @@ class CompileTask { |
| } |
| } |
| +class FrontEndBinaryPrinter extends BinaryPrinter { |
|
Kevin Millikin (Google)
2017/03/31 10:05:42
This is hacky and I'm sure there is a better way.
ahe
2017/03/31 10:13:09
I think this would be a better fit for the "kernel
ahe
2017/03/31 10:13:09
How about renaming this FilteringBinaryPrinter and
|
| + FrontEndBinaryPrinter(Sink<List<int>> sink) : super(sink); |
| + |
| + void writeProgramFile(Program program) { |
| + program.computeCanonicalNames(); |
| + writeMagicWord(Tag.ProgramFile); |
| + stringIndexer.scanProgram(program); |
| + writeStringTable(stringIndexer); |
| + writeUriToSource(program); |
| + writeLinkTable(program); |
| + writeList(program.libraries.where((lib) => !lib.importUri.isScheme('dart')), |
| + writeNode); |
| + writeMemberReference(program.mainMethod, allowNull: true); |
| + flush(); |
| + } |
| +} |
| + |
| Future<CompilationResult> parseScript( |
| Uri fileName, Uri packages, Uri patchedSdk, bool verbose) async { |
| try { |
| @@ -191,7 +210,7 @@ Future<CompilationResult> parseScript( |
| // Write the program to a list of bytes and return it. |
| var sink = new ByteSink(); |
| - new BinaryPrinter(sink).writeProgramFile(program); |
| + new FrontEndBinaryPrinter(sink).writeProgramFile(program); |
| return new CompilationResult.ok(sink.builder.takeBytes()); |
| } catch (e, s) { |
| return reportCrash(e, s, fileName); |