Chromium Code Reviews| Index: pkg/front_end/lib/src/incremental_kernel_generator_impl.dart |
| diff --git a/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart b/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart |
| index ad86ecad33a76270ed55117786b3ca8a4e3f4f45..03a56b0e6439ac8eb11039958cf48b4c244994f4 100644 |
| --- a/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart |
| +++ b/pkg/front_end/lib/src/incremental_kernel_generator_impl.dart |
| @@ -11,6 +11,7 @@ import 'package:front_end/incremental_resolved_ast_generator.dart'; |
| import 'package:front_end/src/base/api_signature.dart'; |
| import 'package:front_end/src/base/performace_logger.dart'; |
| import 'package:front_end/src/base/processed_options.dart'; |
| +import 'package:front_end/src/fasta/dill/dill_library_builder.dart'; |
| import 'package:front_end/src/fasta/dill/dill_target.dart'; |
| import 'package:front_end/src/fasta/kernel/kernel_target.dart'; |
| import 'package:front_end/src/fasta/ticker.dart'; |
| @@ -147,8 +148,11 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator { |
| /// We need kernel libraries for these URIs. |
| Set<Uri> libraryUris = new Set<Uri>(); |
| + Map<Uri, FileState> libraryUriToFile = {}; |
| for (FileState library in cycle.libraries) { |
| - libraryUris.add(library.uri); |
| + Uri uri = library.uri; |
| + libraryUris.add(uri); |
| + libraryUriToFile[uri] = library; |
| } |
| /// Check if there is already a bundle with these libraries. |
| @@ -158,8 +162,11 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator { |
| var program = new Program(nameRoot: nameRoot); |
| var reader = new BinaryBuilder(bytes); |
| reader.readProgram(program); |
| - dillTarget.loader |
| + |
| + List<DillLibraryBuilder> libraryBuilders = dillTarget.loader |
| .appendLibraries(program, (uri) => libraryUris.contains(uri)); |
| + _computeExportScopes(dillTarget, libraryUriToFile, libraryBuilders); |
| + |
| return new _LibraryCycleResult(cycle, signature, program.libraries); |
| }); |
| } |
| @@ -185,8 +192,9 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator { |
| List<Library> kernelLibraries = program.libraries |
| .where((library) => libraryUris.contains(library.importUri)) |
| .toList(); |
| - dillTarget.loader |
| + List<DillLibraryBuilder> libraryBuilders = dillTarget.loader |
| .appendLibraries(program, (uri) => libraryUris.contains(uri)); |
| + _computeExportScopes(dillTarget, libraryUriToFile, libraryBuilders); |
| _logger.run('Serialize ${kernelLibraries.length} libraries', () { |
| program.unbindCanonicalNames(); |
| @@ -199,6 +207,33 @@ class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator { |
| }); |
| } |
| + /// Compute exports scopes for a new strongly connected cycle of [libraries]. |
| + /// The [dillTarget] can be used to access libraries from previous cycles. |
|
Paul Berry
2017/05/15 21:53:48
How much of this code is working around the fact t
scheglov
2017/05/16 17:02:44
Done.
|
| + void _computeExportScopes(DillTarget dillTarget, |
| + Map<Uri, FileState> uriToFile, List<DillLibraryBuilder> libraries) { |
| + bool wasChanged = false; |
| + do { |
| + wasChanged = false; |
| + for (DillLibraryBuilder library in libraries) { |
| + FileState file = uriToFile[library.uri]; |
| + for (NamespaceExport export in file.exports) { |
| + DillLibraryBuilder exportedLibrary = |
| + dillTarget.loader.read(export.library.uri); |
| + if (exportedLibrary != null) { |
| + exportedLibrary.exports.forEach((name, member) { |
| + if (export.filter(name) && |
| + library.addToExportScope(name, member)) { |
| + wasChanged = true; |
| + } |
| + }); |
| + } else { |
| + // TODO(scheglov) How to handle this? |
| + } |
| + } |
| + } |
| + } while (wasChanged); |
| + } |
| + |
| /// Refresh all the invalidated files and update dependencies. |
| Future<Null> _refreshInvalidatedFiles() async { |
| await _logger.runAsync('Refresh invalidated files', () async { |