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

Unified Diff: pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart

Issue 3009953003: Store actual Reference(s) for additional exports. (Closed)
Patch Set: Use references, but keep JSON hacks for errors and void/dynamic. Created 3 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
index 48bcb98b9f1cf622846ee2cc37ff69860621e3a9..e07e6a063dbf28fd690e2e2b11dac446c57f7736 100644
--- a/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
+++ b/pkg/front_end/lib/src/fasta/dill/dill_library_builder.dart
@@ -13,13 +13,14 @@ import 'package:kernel/ast.dart'
Library,
ListLiteral,
Member,
+ Procedure,
StaticGet,
StringLiteral,
Typedef;
import '../fasta_codes.dart' show templateUnspecified;
-import '../problems.dart' show unimplemented;
+import '../problems.dart' show unhandled, unimplemented;
import '../kernel/kernel_builder.dart'
show
@@ -47,18 +48,11 @@ class DillLibraryBuilder extends LibraryBuilder<KernelTypeBuilder, Library> {
Library library;
- /// Exports in addition to the members declared in this library.
+ /// Exports that can't be serialized.
///
- /// Each entry in the list is either two or three elements long.
- ///
- /// The first element is the library URI, if it is null, this is an ambiguous
- /// export and the list has three elements. Otherwise the list has two
- /// elements.
- ///
- /// The second element is the name of the exported element.
- ///
- /// The third element (if present) is an error message.
- List<List<String>> additionalExports;
+ /// The elements of this map are documented in
+ /// [../source/source_library_builder.dart].
+ Map<String, String> additionalExports;
Johnni Winther 2017/09/01 12:32:32 Rename this to [unserializableExports] to avoid co
ahe 2017/09/01 14:05:39 Done.
DillLibraryBuilder(this.uri, this.loader)
: super(uri, new Scope.top(), new Scope.top());
@@ -145,21 +139,59 @@ class DillLibraryBuilder extends LibraryBuilder<KernelTypeBuilder, Library> {
}
void finalizeExports() {
- if (additionalExports != null) {
- for (List<String> additionalExport in additionalExports) {
- String uriString = additionalExport[0];
- String name = additionalExport[1];
- Builder builder;
- if (uriString == null) {
- builder = new KernelInvalidTypeBuilder(name, -1, null,
- templateUnspecified.withArguments(additionalExport[2]));
- } else {
- DillLibraryBuilder library = loader.read(uri.resolve(uriString), -1);
- builder = library?.exportScopeBuilder[name] ??
- new KernelInvalidTypeBuilder(name, -1, null);
- }
+ additionalExports?.forEach((String name, String message) {
+ Builder builder;
+ switch (name) {
+ case "dynamic":
+ case "void":
+ // TODO(ahe): It's likely that we shouldn't be exporting these types
+ // from dart:core, and this case can be removed.
+ builder = loader.coreLibrary.exportScopeBuilder[name];
+ break;
+
+ default:
+ builder = new KernelInvalidTypeBuilder(
+ name,
+ -1,
+ null,
+ message == null
+ ? null
+ : templateUnspecified.withArguments(message));
+ }
+ exportScopeBuilder.addMember(name, builder);
+ });
+
+ for (var reference in library.additionalExports) {
+ var node = reference.node;
+ Uri libraryUri;
+ String name;
+ bool isSetter = false;
+ if (node is Class) {
+ libraryUri = node.enclosingLibrary.importUri;
+ name = node.name;
+ } else if (node is Procedure) {
+ libraryUri = node.enclosingLibrary.importUri;
+ name = node.name.name;
+ isSetter = node.isSetter;
+ } else if (node is Member) {
+ libraryUri = node.enclosingLibrary.importUri;
+ name = node.name.name;
+ } else if (node is Typedef) {
+ libraryUri = node.enclosingLibrary.importUri;
+ name = node.name;
+ } else {
+ unhandled("${node.runtimeType}", "finalizeExports", -1, fileUri);
+ }
+ var library = loader.read(libraryUri, -1);
+ Builder builder;
+ if (isSetter) {
+ builder = library.exportScope.setters[name];
+ exportScopeBuilder.addSetter(name, builder);
+ } else {
+ builder = library.exportScope.local[name];
exportScopeBuilder.addMember(name, builder);
}
+ assert(node == builder.target);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698