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

Unified Diff: pkg/front_end/lib/src/fasta/dill/dill_loader.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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/dill/dill_target.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/dill/dill_loader.dart
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_loader.dart b/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
index 281bfff376555d777d16df7d9cac507525a78ded..1b843c94b32eef8ee9207d59f7675b99755f235c 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_loader.dart
@@ -6,47 +6,39 @@ library fasta.dill_loader;
import 'dart:async' show Future;
-import 'dart:io' show File;
-
-import 'package:kernel/kernel.dart' show loadProgramFromBinary;
-
import 'package:kernel/ast.dart' show Library, Program;
import '../loader.dart' show Loader;
-
import '../target_implementation.dart' show TargetImplementation;
-
import 'dill_library_builder.dart' show DillLibraryBuilder;
class DillLoader extends Loader<Library> {
- Uri input;
-
Program program;
DillLoader(TargetImplementation target) : super(target);
- DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri);
-
- Future<Null> buildOutline(DillLibraryBuilder builder) async {
- if (program == null) {
- byteCount = await new File.fromUri(input).length();
- setProgram(await loadProgramFromBinary(input.toFilePath()));
+ /// Append compiled libraries from the given [program]. If the [filter] is
+ /// provided, append only libraries whose [Uri] is accepted by the [filter].
+ void appendLibraries(Program program, [bool filter(Uri uri)]) {
+ this.program ??= new Program();
+ program.unbindCanonicalNames();
+ for (Library library in program.libraries) {
+ if (filter == null || filter(library.importUri)) {
+ this.program.libraries.add(library);
+ read(library.importUri).library = library;
+ }
}
- builder.library.classes.forEach(builder.addClass);
- builder.library.procedures.forEach(builder.addMember);
- builder.library.fields.forEach(builder.addMember);
}
Future<Null> buildBody(DillLibraryBuilder builder) {
return buildOutline(builder);
}
- void setProgram(Program program) {
- assert(input != null);
- this.program = program;
- program.unbindCanonicalNames();
- for (Library library in program.libraries) {
- read(library.importUri).library = library;
- }
+ Future<Null> buildOutline(DillLibraryBuilder builder) async {
ahe 2017/05/19 09:15:03 Please stop sorting methods by name, it produces u
scheglov 2017/05/19 16:03:25 Conflicts will happen only once. Hopefully not too
ahe 2017/05/22 09:01:37 What you personally perceive as reducing cognitive
+ builder.library.classes.forEach(builder.addClass);
+ builder.library.procedures.forEach(builder.addMember);
+ builder.library.fields.forEach(builder.addMember);
}
+
+ DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri);
}
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/dill/dill_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698