Chromium Code Reviews| 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); |
| } |