Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: pkg/front_end/lib/src/fasta/fasta.dart

Issue 2786083002: Read platform.dill in the VM. (Closed)
Patch Set: Allow main to be a field or getter. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698