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

Unified Diff: pkg/kernel/lib/binary/ast_to_binary.dart

Issue 2786083002: Read platform.dill in the VM. (Closed)
Patch Set: Incorporate review comments and merge. Created 3 years, 8 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_target.dart ('k') | runtime/bin/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/binary/ast_to_binary.dart
diff --git a/pkg/kernel/lib/binary/ast_to_binary.dart b/pkg/kernel/lib/binary/ast_to_binary.dart
index cfc65fffe9b4a7063ccb11c6161f4bffa892750d..95ad03729800295347a08087aa5058622d86ef96 100644
--- a/pkg/kernel/lib/binary/ast_to_binary.dart
+++ b/pkg/kernel/lib/binary/ast_to_binary.dart
@@ -1019,6 +1019,31 @@ class BinaryPrinter extends Visitor {
}
}
+/// A [LibraryFilteringBinaryPrinter] can write a subset of libraries.
+///
+/// This printer writes a Kernel binary but includes only libraries that match a
+/// predicate.
+class LibraryFilteringBinaryPrinter extends BinaryPrinter {
+ final Function predicate;
+
+ LibraryFilteringBinaryPrinter(
+ Sink<List<int>> sink, bool predicate(Library library))
+ : predicate = predicate,
+ super(sink);
+
+ void writeProgramFile(Program program) {
+ program.computeCanonicalNames();
+ writeMagicWord(Tag.ProgramFile);
+ _stringIndexer.scanProgram(program);
+ writeStringTable(_stringIndexer);
+ writeUriToSource(program);
+ writeLinkTable(program);
+ writeList(program.libraries.where(predicate), writeNode);
+ writeMemberReference(program.mainMethod, allowNull: true);
+ _flush();
+ }
+}
+
class VariableIndexer {
final Map<VariableDeclaration, int> index = <VariableDeclaration, int>{};
final List<int> scopes = <int>[];
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_target.dart ('k') | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698