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

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

Issue 2872903005: Rework DillLoader to allow adding multiple dills. (Closed)
Patch Set: Fixes for review changes. 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
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 eb4867d749ca587417494de17966fb440e0cc79a..db0b740b2d8b773c38b263ba1a378df3e61934ee 100644
--- a/pkg/front_end/lib/src/fasta/fasta.dart
+++ b/pkg/front_end/lib/src/fasta/fasta.dart
@@ -14,7 +14,7 @@ import 'package:front_end/physical_file_system.dart';
import 'package:kernel/binary/ast_to_binary.dart'
show LibraryFilteringBinaryPrinter;
-import 'package:kernel/kernel.dart' show Program, Library;
+import 'package:kernel/kernel.dart' show Library, Program, loadProgramFromBytes;
import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget;
@@ -180,7 +180,7 @@ Future<CompilationResult> parseScript(
await TranslateUri.parse(PhysicalFileSystem.instance, null, packages);
final Ticker ticker = new Ticker(isVerbose: verbose);
final DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
- dillTarget.read(patchedSdk.resolve('platform.dill'));
+ _appendDillForUri(dillTarget, patchedSdk.resolve('platform.dill'));
final KernelTarget kernelTarget = new KernelTarget(
PhysicalFileSystem.instance, dillTarget, uriTranslator, strongMode);
kernelTarget.read(fileName);
@@ -250,8 +250,8 @@ Future writeDepsFile(Uri script, Uri depsFile, Uri output,
TranslateUri uriTranslator = await TranslateUri.parse(
c.fileSystem, c.options.sdk, c.options.packages);
ticker.logMs("Read packages file");
- DillTarget dillTarget = new DillTarget(ticker, uriTranslator)
- ..read(platform);
+ DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
+ _appendDillForUri(dillTarget, platform);
KernelTarget kernelTarget = new KernelTarget(PhysicalFileSystem.instance,
dillTarget, uriTranslator, false, c.uriToSource);
@@ -263,6 +263,14 @@ Future writeDepsFile(Uri script, Uri depsFile, Uri output,
});
}
+/// Load the [Program] from the given [uri] and append its libraries
+/// to the [dillTarget].
+void _appendDillForUri(DillTarget dillTarget, Uri uri) {
+ var bytes = new File.fromUri(uri).readAsBytesSync();
+ var platformProgram = loadProgramFromBytes(bytes);
+ dillTarget.loader.appendLibraries(platformProgram);
+}
+
// TODO(ahe): https://github.com/dart-lang/sdk/issues/28316
class ByteSink implements Sink<List<int>> {
final BytesBuilder builder = new BytesBuilder();

Powered by Google App Engine
This is Rietveld 408576698