Chromium Code Reviews| OLD | NEW |
|---|---|
| 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, Source; |
| 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 /// Source targets are compiled against these binary libraries. | 16 /// Source targets are compiled against these binary libraries. |
| 17 final libraries = <Library>[]; | 17 final libraries = <Library>[]; |
| 18 | 18 |
| 19 /// Sources for all appended programs. | |
|
scheglov
2017/06/09 15:32:56
"appended libraries"
| |
| 20 final Map<String, Source> uriToSource = <String, Source>{}; | |
| 21 | |
| 19 DillLoader(TargetImplementation target) : super(target); | 22 DillLoader(TargetImplementation target) : super(target); |
| 20 | 23 |
| 21 /// Append compiled libraries from the given [program]. If the [filter] is | 24 /// Append compiled libraries from the given [program]. If the [filter] is |
| 22 /// provided, append only libraries whose [Uri] is accepted by the [filter]. | 25 /// provided, append only libraries whose [Uri] is accepted by the [filter]. |
| 23 List<DillLibraryBuilder> appendLibraries(Program program, | 26 List<DillLibraryBuilder> appendLibraries(Program program, |
| 24 [bool filter(Uri uri)]) { | 27 [bool filter(Uri uri)]) { |
| 25 var builders = <DillLibraryBuilder>[]; | 28 var builders = <DillLibraryBuilder>[]; |
| 26 for (Library library in program.libraries) { | 29 for (Library library in program.libraries) { |
| 27 if (filter == null || filter(library.importUri)) { | 30 if (filter == null || filter(library.importUri)) { |
| 28 libraries.add(library); | 31 libraries.add(library); |
| 29 DillLibraryBuilder builder = read(library.importUri, -1); | 32 DillLibraryBuilder builder = read(library.importUri, -1); |
| 30 builder.library = library; | 33 builder.library = library; |
| 31 builders.add(builder); | 34 builders.add(builder); |
| 32 } | 35 } |
| 33 } | 36 } |
| 37 uriToSource.addAll(program.uriToSource); | |
|
scheglov
2017/06/09 15:32:56
We're adding only some libraries, why do we add AL
Johnni Winther
2017/06/09 15:46:23
To ensure soundness. It would of course be an opti
| |
| 34 return builders; | 38 return builders; |
| 35 } | 39 } |
| 36 | 40 |
| 37 Future<Null> buildOutline(DillLibraryBuilder builder) async { | 41 Future<Null> buildOutline(DillLibraryBuilder builder) async { |
| 38 builder.library.classes.forEach(builder.addClass); | 42 builder.library.classes.forEach(builder.addClass); |
| 39 builder.library.procedures.forEach(builder.addMember); | 43 builder.library.procedures.forEach(builder.addMember); |
| 40 builder.library.typedefs.forEach(builder.addTypedef); | 44 builder.library.typedefs.forEach(builder.addTypedef); |
| 41 builder.library.fields.forEach(builder.addMember); | 45 builder.library.fields.forEach(builder.addMember); |
| 42 } | 46 } |
| 43 | 47 |
| 44 Future<Null> buildBody(DillLibraryBuilder builder) { | 48 Future<Null> buildBody(DillLibraryBuilder builder) { |
| 45 return buildOutline(builder); | 49 return buildOutline(builder); |
| 46 } | 50 } |
| 47 } | 51 } |
| OLD | NEW |