Skip to content

Commit 288b203

Browse files
committed
Stop building export scopes in KernelDriver.
Fasta already store exports scopes into Kernel. It was added some time ago and improved recently. 234c4a7 [email protected], [email protected], [email protected] BUG= Review-Url: https://codereview.chromium.org/3004913002 .
1 parent 7924f4c commit 288b203

File tree

3 files changed

+3
-124
lines changed

3 files changed

+3
-124
lines changed

pkg/front_end/lib/src/incremental/file_state.dart

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class FileState {
4646
bool _hasMixinApplication;
4747
List<int> _apiSignature;
4848

49-
List<NamespaceExport> _exports;
5049
List<FileState> _importedLibraries;
5150
List<FileState> _exportedLibraries;
5251
List<FileState> _partFiles;
@@ -81,9 +80,6 @@ class FileState {
8180
/// The list of the libraries exported by this library.
8281
List<FileState> get exportedLibraries => _exportedLibraries;
8382

84-
/// The list of the exported files with combinators.
85-
List<NamespaceExport> get exports => _exports;
86-
8783
@override
8884
int get hashCode => uri.hashCode;
8985

@@ -168,7 +164,6 @@ class FileState {
168164
_importedLibraries = <FileState>[];
169165
_exportedLibraries = <FileState>[];
170166
_partFiles = <FileState>[];
171-
_exports = <NamespaceExport>[];
172167
{
173168
FileState coreFile = await _getFileForRelativeUri('dart:core');
174169
// TODO(scheglov) add error handling
@@ -187,7 +182,6 @@ class FileState {
187182
FileState file = await _getFileForRelativeUri(export_.uri);
188183
if (file != null) {
189184
_exportedLibraries.add(file);
190-
_exports.add(new NamespaceExport(file, export_.combinators));
191185
}
192186
}
193187
for (var part_ in unlinkedUnit.parts) {
@@ -398,30 +392,6 @@ class LibraryCycle {
398392
}
399393
}
400394

401-
/// Information about a single `export` directive.
402-
class NamespaceExport {
403-
final FileState library;
404-
final List<UnlinkedCombinator> combinators;
405-
406-
NamespaceExport(this.library, this.combinators);
407-
408-
/// Return `true` if the [name] satisfies the sequence of the [combinators].
409-
bool isExposed(String name) {
410-
for (var combinator in combinators) {
411-
if (combinator.isShow) {
412-
if (!combinator.names.contains(name)) {
413-
return false;
414-
}
415-
} else {
416-
if (combinator.names.contains(name)) {
417-
return false;
418-
}
419-
}
420-
}
421-
return true;
422-
}
423-
}
424-
425395
/// [FileSystemState] based implementation of [FileSystem].
426396
/// It provides a consistent view on the known file system state.
427397
class _FileSystemView implements FileSystem {

pkg/front_end/lib/src/incremental/kernel_driver.dart

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'package:front_end/src/base/performace_logger.dart';
1010
import 'package:front_end/src/base/processed_options.dart';
1111
import 'package:front_end/src/byte_store/byte_store.dart';
1212
import 'package:front_end/src/fasta/compiler_context.dart';
13-
import 'package:front_end/src/fasta/dill/dill_library_builder.dart';
1413
import 'package:front_end/src/fasta/dill/dill_target.dart';
1514
import 'package:front_end/src/fasta/kernel/kernel_target.dart';
1615
import 'package:front_end/src/fasta/kernel/utils.dart';
@@ -226,14 +225,8 @@ class KernelDriver {
226225
}
227226

228227
Future<Null> appendNewDillLibraries(Program program) async {
229-
List<DillLibraryBuilder> libraryBuilders = dillTarget.loader
230-
.appendLibraries(program, (uri) => libraryUris.contains(uri));
231-
232-
// Compute local scopes.
228+
dillTarget.loader.appendLibraries(program, libraryUris.contains);
233229
await dillTarget.buildOutlines();
234-
235-
// Compute export scopes.
236-
_computeExportScopes(dillTarget, libraryUriToFile, libraryBuilders);
237230
}
238231

239232
// Check if there is already a bundle with these libraries.
@@ -284,34 +277,6 @@ class KernelDriver {
284277
});
285278
}
286279

287-
/// Compute exports scopes for a new strongly connected cycle of [libraries].
288-
/// The [dillTarget] can be used to access libraries from previous cycles.
289-
/// TODO(scheglov) Remove/replace this when Kernel has export scopes.
290-
void _computeExportScopes(DillTarget dillTarget,
291-
Map<Uri, FileState> uriToFile, List<DillLibraryBuilder> libraries) {
292-
bool wasChanged = false;
293-
do {
294-
wasChanged = false;
295-
for (DillLibraryBuilder library in libraries) {
296-
FileState file = uriToFile[library.uri];
297-
for (NamespaceExport export in file.exports) {
298-
DillLibraryBuilder exportedLibrary =
299-
dillTarget.loader.read(export.library.uri, -1, accessor: library);
300-
if (exportedLibrary != null) {
301-
exportedLibrary.exportScope.forEach((name, member) {
302-
if (export.isExposed(name) &&
303-
library.addToExportScope(name, member)) {
304-
wasChanged = true;
305-
}
306-
});
307-
} else {
308-
// TODO(scheglov) How to handle this?
309-
}
310-
}
311-
}
312-
} while (wasChanged);
313-
}
314-
315280
/// Compute salt and put into [_salt].
316281
void _computeSalt() {
317282
var saltBuilder = new ApiSignature();

pkg/front_end/test/src/incremental/file_state_test.dart

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import 'dart:async';
66

77
import 'package:front_end/memory_file_system.dart';
8-
import 'package:front_end/src/fasta/uri_translator_impl.dart';
98
import 'package:front_end/src/byte_store/byte_store.dart';
9+
import 'package:front_end/src/fasta/uri_translator_impl.dart';
1010
import 'package:front_end/src/incremental/file_state.dart';
11+
import 'package:kernel/target/targets.dart';
1112
import 'package:package_config/packages.dart';
1213
import 'package:test/test.dart';
1314
import 'package:test_reflective_loader/test_reflective_loader.dart';
14-
import 'package:kernel/target/targets.dart';
1515

1616
import 'mock_sdk.dart';
1717

@@ -224,62 +224,6 @@ part "c.dart";
224224
expect(bFile.partFiles, isEmpty);
225225
}
226226

227-
test_getFile_exports() async {
228-
var a = writeFile('/a.dart', '');
229-
var b = writeFile('/b.dart', '');
230-
var c = writeFile('/c.dart', '');
231-
var d = writeFile('/d.dart', r'''
232-
export "a.dart" show A, B;
233-
export "b.dart" hide C, D;
234-
export "c.dart" show A, B, C, D hide C show A, D;
235-
''');
236-
237-
FileState aFile = await fsState.getFile(a);
238-
FileState bFile = await fsState.getFile(b);
239-
FileState cFile = await fsState.getFile(c);
240-
FileState dFile = await fsState.getFile(d);
241-
242-
expect(dFile.exports, hasLength(3));
243-
{
244-
NamespaceExport export_ = dFile.exports[0];
245-
expect(export_.library, aFile);
246-
expect(export_.combinators, hasLength(1));
247-
expect(export_.combinators[0].isShow, isTrue);
248-
expect(export_.combinators[0].names, unorderedEquals(['A', 'B']));
249-
expect(export_.isExposed('A'), isTrue);
250-
expect(export_.isExposed('B'), isTrue);
251-
expect(export_.isExposed('C'), isFalse);
252-
expect(export_.isExposed('D'), isFalse);
253-
}
254-
{
255-
NamespaceExport export_ = dFile.exports[1];
256-
expect(export_.library, bFile);
257-
expect(export_.combinators, hasLength(1));
258-
expect(export_.combinators[0].isShow, isFalse);
259-
expect(export_.combinators[0].names, unorderedEquals(['C', 'D']));
260-
expect(export_.isExposed('A'), isTrue);
261-
expect(export_.isExposed('B'), isTrue);
262-
expect(export_.isExposed('C'), isFalse);
263-
expect(export_.isExposed('D'), isFalse);
264-
}
265-
{
266-
NamespaceExport export_ = dFile.exports[2];
267-
expect(export_.library, cFile);
268-
expect(export_.combinators, hasLength(3));
269-
expect(export_.combinators[0].isShow, isTrue);
270-
expect(
271-
export_.combinators[0].names, unorderedEquals(['A', 'B', 'C', 'D']));
272-
expect(export_.combinators[1].isShow, isFalse);
273-
expect(export_.combinators[1].names, unorderedEquals(['C']));
274-
expect(export_.combinators[2].isShow, isTrue);
275-
expect(export_.combinators[2].names, unorderedEquals(['A', 'D']));
276-
expect(export_.isExposed('A'), isTrue);
277-
expect(export_.isExposed('B'), isFalse);
278-
expect(export_.isExposed('C'), isFalse);
279-
expect(export_.isExposed('D'), isTrue);
280-
}
281-
}
282-
283227
test_hasMixinApplication_false() async {
284228
writeFile('/a.dart', r'''
285229
class A {}

0 commit comments

Comments
 (0)