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

Side by Side Diff: pkg/front_end/lib/src/fasta/dill/dill_loader.dart

Issue 2872903005: Rework DillLoader to allow adding multiple dills. (Closed)
Patch Set: Updates 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.dill_loader; 5 library fasta.dill_loader;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show File;
10
11 import 'package:kernel/kernel.dart' show loadProgramFromBinary;
12
13 import 'package:kernel/ast.dart' show Library, Program; 9 import 'package:kernel/ast.dart' show Library, Program;
14 10
15 import '../loader.dart' show Loader; 11 import '../loader.dart' show Loader;
16
17 import '../target_implementation.dart' show TargetImplementation; 12 import '../target_implementation.dart' show TargetImplementation;
18
19 import 'dill_library_builder.dart' show DillLibraryBuilder; 13 import 'dill_library_builder.dart' show DillLibraryBuilder;
20 14
21 class DillLoader extends Loader<Library> { 15 class DillLoader extends Loader<Library> {
22 Uri input;
23
24 Program program; 16 Program program;
25 17
26 DillLoader(TargetImplementation target) : super(target); 18 DillLoader(TargetImplementation target) : super(target);
27 19
28 DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri); 20 /// Append compiled libraries from the given [program]. If the [filter] is
29 21 /// provided, append only libraries whose [Uri] is accepted by the [filter].
30 Future<Null> buildOutline(DillLibraryBuilder builder) async { 22 void appendLibraries(Program program, [bool filter(Uri uri)]) {
31 if (program == null) { 23 this.program ??= new Program();
32 byteCount = await new File.fromUri(input).length(); 24 program.unbindCanonicalNames();
33 setProgram(await loadProgramFromBinary(input.toFilePath())); 25 for (Library library in program.libraries) {
26 if (filter == null || filter(library.importUri)) {
27 this.program.libraries.add(library);
28 read(library.importUri).library = library;
29 }
34 } 30 }
35 builder.library.classes.forEach(builder.addClass);
36 builder.library.procedures.forEach(builder.addMember);
37 builder.library.fields.forEach(builder.addMember);
38 } 31 }
39 32
40 Future<Null> buildBody(DillLibraryBuilder builder) { 33 Future<Null> buildBody(DillLibraryBuilder builder) {
41 return buildOutline(builder); 34 return buildOutline(builder);
42 } 35 }
43 36
44 void setProgram(Program program) { 37 Future<Null> buildOutline(DillLibraryBuilder builder) async {
45 assert(input != null); 38 builder.library.classes.forEach(builder.addClass);
46 this.program = program; 39 builder.library.procedures.forEach(builder.addMember);
47 program.unbindCanonicalNames(); 40 builder.library.fields.forEach(builder.addMember);
48 for (Library library in program.libraries) {
49 read(library.importUri).library = library;
50 }
51 } 41 }
42
43 DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri);
52 } 44 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/dill/dill_target.dart » ('j') | pkg/front_end/lib/src/fasta/dill/dill_target.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698