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

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

Issue 2885233003: Move writeOutline() and writeProgram() out of KernelTarget. (Closed)
Patch Set: Fixes for review comments. Created 3 years, 7 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/utils.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/utils.dart b/pkg/front_end/lib/src/fasta/kernel/utils.dart
index 6748f99a01758c06ff26ea507cfd5e6bf3308725..9bb7a2f014b58c0ead18ad68795e56f1a054321e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/utils.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/utils.dart
@@ -2,8 +2,12 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:async';
+import 'dart:io';
+
import 'package:front_end/src/scanner/token.dart' show Token;
import 'package:kernel/ast.dart';
+import 'package:kernel/binary/ast_to_binary.dart';
import 'package:kernel/text/ast_to_text.dart';
/// A null-aware alternative to `token.offset`. If [token] is `null`, returns
@@ -21,3 +25,14 @@ void printProgramText(Program program) {
}
print(sb);
}
+
+Future<Null> writeProgramToFile(Program program, Uri uri) async {
+ File output = new File.fromUri(uri);
+ IOSink sink = output.openWrite();
+ try {
+ new BinaryPrinter(sink).writeProgramFile(program);
+ program.unbindCanonicalNames();
+ } finally {
+ await sink.close();
+ }
+}
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_target.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698