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..d70aa043703f8dd3580fef662155af2b209cf045 100644 |
--- a/pkg/front_end/lib/src/fasta/dill/dill_loader.dart |
+++ b/pkg/front_end/lib/src/fasta/dill/dill_loader.dart |
@@ -6,43 +6,49 @@ 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; |
Siggi Cherem (dart-lang)
2017/05/09 20:14:30
doesn't have to be in this CL, but we probably onl
scheglov
2017/05/09 20:32:21
Yeah, mostly we use libraries.
But lib/src/fasta/k
|
DillLoader(TargetImplementation target) : super(target); |
- DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri); |
+ /// Add already compiled libraries from the given [dill]. If [uris] is |
Siggi Cherem (dart-lang)
2017/05/09 20:14:30
nit: a couple suggestions on this comment:
- I pr
scheglov
2017/05/09 20:32:21
Done.
Siggi Cherem (dart-lang)
2017/05/09 22:12:37
After talking on VC I just realized something: is
scheglov
2017/05/10 00:47:40
If the idea with serializing just individual stron
|
+ /// `null`, then only libraries these URIs are added (e.g. to add a library |
+ /// without all its already added dependencies). It is up to the client to |
+ /// make sure that the added libraries have all their dependencies added |
+ /// before. |
+ void addDill(Program dill, [Set<Uri> uris]) { |
Siggi Cherem (dart-lang)
2017/05/09 20:14:30
some suggestions:
- rename addDill => appendProgr
scheglov
2017/05/09 20:32:21
Done.
|
+ program ??= new Program(); |
+ dill.unbindCanonicalNames(); |
+ for (Library library in dill.libraries) { |
+ if (uris == null || uris.contains(library.importUri)) { |
+ program.libraries.add(library); |
+ read(library.importUri).library = library; |
+ } |
+ } |
+ } |
+ |
+ Future<Null> buildBody(DillLibraryBuilder builder) { |
+ return buildOutline(builder); |
+ } |
Future<Null> buildOutline(DillLibraryBuilder builder) async { |
- if (program == null) { |
- byteCount = await new File.fromUri(input).length(); |
- setProgram(await loadProgramFromBinary(input.toFilePath())); |
- } |
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); |
- } |
+ DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri); |
void setProgram(Program program) { |
Siggi Cherem (dart-lang)
2017/05/09 20:14:30
I'd delete this and use `addDill` in testing/suite
scheglov
2017/05/09 20:32:21
Ah... Right, we don't need it anymore!
|
- assert(input != null); |
+ if (this.program != null) { |
+ throw new StateError('The full DILL can be set only once.'); |
+ } |
this.program = program; |
program.unbindCanonicalNames(); |
for (Library library in program.libraries) { |