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

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

Issue 3004973002: Revert "Store actual Reference(s) for additional exports." (Closed)
Patch Set: Update status file. Created 3 years, 4 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bb87bc4e1c23aa9f218683ee2ec0922419b31320..48bcb98b9f1cf622846ee2cc37ff69860621e3a9 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
@@ -4,6 +4,8 @@
library fasta.dill_library_builder;
+import 'dart:convert' show JSON;
+
import 'package:kernel/ast.dart'
show
Class,
@@ -11,10 +13,12 @@ import 'package:kernel/ast.dart'
Library,
ListLiteral,
Member,
- Reference,
StaticGet,
+ StringLiteral,
Typedef;
+import '../fasta_codes.dart' show templateUnspecified;
+
import '../problems.dart' show unimplemented;
import '../kernel/kernel_builder.dart'
@@ -43,10 +47,18 @@ class DillLibraryBuilder extends LibraryBuilder<KernelTypeBuilder, Library> {
Library library;
- /// References to nodes exported by `export` declarations that:
- /// - aren't ambiguous, or
- /// - aren't hidden by local declarations.
- List<Reference> additionalExports;
+ /// Exports in addition to the members declared in this library.
+ ///
+ /// 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;
DillLibraryBuilder(this.uri, this.loader)
: super(uri, new Scope.top(), new Scope.top());
@@ -76,7 +88,13 @@ class DillLibraryBuilder extends LibraryBuilder<KernelTypeBuilder, Library> {
void addMember(Member member) {
String name = member.name.name;
- addBuilder(name, new DillMemberBuilder(member, this), member.fileOffset);
+ if (name == "_exports#") {
+ Field field = member;
+ StringLiteral string = field.initializer;
+ additionalExports = JSON.decode(string.value);
+ } else {
+ addBuilder(name, new DillMemberBuilder(member, this), member.fileOffset);
+ }
}
Builder addBuilder(String name, Builder builder, int charOffset) {
@@ -127,28 +145,19 @@ class DillLibraryBuilder extends LibraryBuilder<KernelTypeBuilder, Library> {
}
void finalizeExports() {
- for (var reference in library.additionalExports) {
- var node = reference.node;
- Uri libraryUri;
- String name;
- if (node is Class) {
- libraryUri = node.enclosingLibrary.importUri;
- name = node.name;
- } 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 {
- unimplemented('${node.runtimeType}', -1, uri);
- }
- var library = loader.read(libraryUri, -1);
- Builder builder = library.exportScopeBuilder[name];
- assert(node == builder.target);
- if (builder.isSetter) {
- exportScopeBuilder.addSetter(name, builder);
- } else {
+ 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);
+ }
exportScopeBuilder.addMember(name, builder);
}
}
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698