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

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

Issue 2874723002: Add a way to use shared CanonicalName root to deserialize Program. (Closed)
Patch Set: Add TODO for 'uriToSource'. 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 'package:kernel/ast.dart' show Library, Program; 9 import 'package:kernel/ast.dart' show Library, Program;
10 10
11 import '../loader.dart' show Loader; 11 import '../loader.dart' show Loader;
12 import '../target_implementation.dart' show TargetImplementation; 12 import '../target_implementation.dart' show TargetImplementation;
13 import 'dill_library_builder.dart' show DillLibraryBuilder; 13 import 'dill_library_builder.dart' show DillLibraryBuilder;
14 14
15 class DillLoader extends Loader<Library> { 15 class DillLoader extends Loader<Library> {
16 Program program; 16 /// Source targets are compiled against these binary libraries.
17 final libraries = <Library>[];
ahe 2017/05/15 09:08:44 Please add a type.
17 18
18 DillLoader(TargetImplementation target) : super(target); 19 DillLoader(TargetImplementation target) : super(target);
19 20
20 /// Append compiled libraries from the given [program]. If the [filter] is 21 /// Append compiled libraries from the given [program]. If the [filter] is
21 /// provided, append only libraries whose [Uri] is accepted by the [filter]. 22 /// provided, append only libraries whose [Uri] is accepted by the [filter].
22 void appendLibraries(Program program, [bool filter(Uri uri)]) { 23 void appendLibraries(Program program, [bool filter(Uri uri)]) {
23 this.program ??= new Program();
24 program.unbindCanonicalNames();
25 for (Library library in program.libraries) { 24 for (Library library in program.libraries) {
26 if (filter == null || filter(library.importUri)) { 25 if (filter == null || filter(library.importUri)) {
27 this.program.libraries.add(library); 26 libraries.add(library);
28 read(library.importUri).library = library; 27 read(library.importUri).library = library;
29 } 28 }
30 } 29 }
31 } 30 }
32 31
33 Future<Null> buildBody(DillLibraryBuilder builder) { 32 Future<Null> buildBody(DillLibraryBuilder builder) {
34 return buildOutline(builder); 33 return buildOutline(builder);
35 } 34 }
36 35
37 Future<Null> buildOutline(DillLibraryBuilder builder) async { 36 Future<Null> buildOutline(DillLibraryBuilder builder) async {
38 builder.library.classes.forEach(builder.addClass); 37 builder.library.classes.forEach(builder.addClass);
39 builder.library.procedures.forEach(builder.addMember); 38 builder.library.procedures.forEach(builder.addMember);
40 builder.library.fields.forEach(builder.addMember); 39 builder.library.fields.forEach(builder.addMember);
41 } 40 }
42 41
43 DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri); 42 DillLibraryBuilder read(Uri uri, [Uri fileUri]) => super.read(uri, fileUri);
44 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698