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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/kernel_target.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/fasta.dart ('k') | pkg/front_end/lib/src/fasta/kernel/utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index 8ec51b3db2366e2e3e0e87e6ab0b2bdc6ee37698..f69483cc6406a53540930ff0c0ecb1dcee93344e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -6,7 +6,7 @@ library fasta.kernel_target;
import 'dart:async' show Future;
-import 'dart:io' show File, IOSink;
+import 'dart:io' show File;
import 'package:front_end/file_system.dart';
import 'package:kernel/ast.dart'
@@ -41,8 +41,6 @@ import 'package:kernel/ast.dart'
VariableGet,
VoidType;
-import 'package:kernel/binary/ast_to_binary.dart' show BinaryPrinter;
-
import 'package:kernel/transformations/erasure.dart' show Erasure;
import 'package:kernel/transformations/continuation.dart' as transformAsync;
@@ -217,17 +215,13 @@ class KernelTarget extends TargetImplementation {
builder.mixedInType = null;
}
- Future<Program> handleInputError(Uri uri, InputError error,
- {bool isFullProgram}) {
+ void handleInputError(InputError error, {bool isFullProgram}) {
if (error != null) {
String message = error.format();
print(message);
errors.add(message);
}
_program = erroneousProgram(isFullProgram);
- return uri == null
- ? new Future<Program>.value(_program)
- : writeLinkedProgram(uri, _program, isFullProgram: isFullProgram);
}
@override
@@ -255,31 +249,20 @@ class KernelTarget extends TargetImplementation {
loader.checkOverrides(sourceClasses);
loader.prepareInitializerInference();
loader.performInitializerInference();
- return _program;
} on InputError catch (e) {
- return handleInputError(null, e, isFullProgram: false);
+ handleInputError(e, isFullProgram: false);
} catch (e, s) {
return reportCrash(e, s, loader?.currentUriForCrashReporting);
}
- }
-
- Future<Null> writeOutline(Uri uri) async {
- try {
- if (uri != null) {
- await writeLinkedProgram(uri, _program, isFullProgram: false);
- }
- } on InputError catch (e) {
- handleInputError(uri, e, isFullProgram: false);
- } catch (e, s) {
- reportCrash(e, s, loader?.currentUriForCrashReporting);
- }
+ return _program;
}
@override
Future<Program> buildProgram({bool verify: false}) async {
if (loader.first == null) return null;
if (errors.isNotEmpty) {
- return handleInputError(null, null, isFullProgram: true);
+ handleInputError(null, isFullProgram: true);
+ return _program;
}
try {
await loader.buildBodies();
@@ -291,25 +274,14 @@ class KernelTarget extends TargetImplementation {
if (verify) this.verify();
errors.addAll(loader.collectCompileTimeErrors().map((e) => e.format()));
if (errors.isNotEmpty) {
- return handleInputError(null, null, isFullProgram: true);
+ handleInputError(null, isFullProgram: true);
}
- return _program;
- } on InputError catch (e) {
- return handleInputError(null, e, isFullProgram: true);
- } catch (e, s) {
- return reportCrash(e, s, loader?.currentUriForCrashReporting);
- }
- }
-
- Future<Null> writeProgram(Uri uri) async {
- if (loader.first == null) return null;
- try {
- await writeLinkedProgram(uri, _program, isFullProgram: true);
} on InputError catch (e) {
- return handleInputError(uri, e, isFullProgram: true);
+ handleInputError(e, isFullProgram: true);
} catch (e, s) {
return reportCrash(e, s, loader?.currentUriForCrashReporting);
}
+ return _program;
}
Future writeDepsFile(Uri output, Uri depsFile,
@@ -417,24 +389,6 @@ class KernelTarget extends TargetImplementation {
return program;
}
- Future<Program> writeLinkedProgram(Uri uri, Program program,
- {bool isFullProgram}) async {
- File output = new File.fromUri(uri);
- IOSink sink = output.openWrite();
- try {
- new BinaryPrinter(sink).writeProgramFile(program);
- program.unbindCanonicalNames();
- } finally {
- await sink.close();
- }
- if (isFullProgram) {
- ticker.logMs("Wrote program to ${uri.toFilePath()}");
- } else {
- ticker.logMs("Wrote outline to ${uri.toFilePath()}");
- }
- return null;
- }
-
void installDefaultSupertypes() {
Class objectClass = this.objectClass;
loader.builders.forEach((Uri uri, LibraryBuilder library) {
« no previous file with comments | « pkg/front_end/lib/src/fasta/fasta.dart ('k') | pkg/front_end/lib/src/fasta/kernel/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698