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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/source_library_builder.dart

Issue 3008763002: Store actual Reference(s) for additional exports. (Closed)
Patch Set: Updates for review comments. 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 unified diff | Download patch
OLDNEW
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.source_library_builder; 5 library fasta.source_library_builder;
6 6
7 import 'package:kernel/ast.dart' show ProcedureKind; 7 import 'package:kernel/ast.dart' show ProcedureKind, Reference;
8 8
9 import '../../base/resolve_relative_uri.dart' show resolveRelativeUri; 9 import '../../base/resolve_relative_uri.dart' show resolveRelativeUri;
10 10
11 import '../../scanner/token.dart' show Token; 11 import '../../scanner/token.dart' show Token;
12 12
13 import '../builder/builder.dart' 13 import '../builder/builder.dart'
14 show 14 show
15 Builder, 15 Builder,
16 ClassBuilder, 16 ClassBuilder,
17 ConstructorReferenceBuilder, 17 ConstructorReferenceBuilder,
18 FormalParameterBuilder, 18 FormalParameterBuilder,
19 FunctionTypeBuilder, 19 FunctionTypeBuilder,
20 InvalidTypeBuilder,
21 LibraryBuilder, 20 LibraryBuilder,
22 MemberBuilder, 21 MemberBuilder,
23 MetadataBuilder, 22 MetadataBuilder,
24 NamedTypeBuilder, 23 NamedTypeBuilder,
25 PrefixBuilder, 24 PrefixBuilder,
26 ProcedureBuilder, 25 ProcedureBuilder,
27 Scope, 26 Scope,
28 TypeBuilder, 27 TypeBuilder,
29 TypeDeclarationBuilder, 28 TypeDeclarationBuilder,
30 TypeVariableBuilder, 29 TypeVariableBuilder,
(...skipping 16 matching lines...) Expand all
47 templateMissingPartOf, 46 templateMissingPartOf,
48 templatePartOfLibraryNameMismatch, 47 templatePartOfLibraryNameMismatch,
49 templatePartOfUriMismatch, 48 templatePartOfUriMismatch,
50 templatePartOfUseUri, 49 templatePartOfUseUri,
51 templatePartTwice; 50 templatePartTwice;
52 51
53 import '../import.dart' show Import; 52 import '../import.dart' show Import;
54 53
55 import '../problems.dart' show unhandled; 54 import '../problems.dart' show unhandled;
56 55
57 import '../util/relativize.dart' show relativizeUri;
58
59 import 'source_loader.dart' show SourceLoader; 56 import 'source_loader.dart' show SourceLoader;
60 57
61 abstract class SourceLibraryBuilder<T extends TypeBuilder, R> 58 abstract class SourceLibraryBuilder<T extends TypeBuilder, R>
62 extends LibraryBuilder<T, R> { 59 extends LibraryBuilder<T, R> {
63 final SourceLoader loader; 60 final SourceLoader loader;
64 61
65 final DeclarationBuilder<T> libraryDeclaration; 62 final DeclarationBuilder<T> libraryDeclaration;
66 63
67 final List<ConstructorReferenceBuilder> constructorReferences = 64 final List<ConstructorReferenceBuilder> constructorReferences =
68 <ConstructorReferenceBuilder>[]; 65 <ConstructorReferenceBuilder>[];
(...skipping 23 matching lines...) Expand all
92 List<MetadataBuilder> metadata; 89 List<MetadataBuilder> metadata;
93 90
94 /// The current declaration that is being built. When we start parsing a 91 /// The current declaration that is being built. When we start parsing a
95 /// declaration (class, method, and so on), we don't have enough information 92 /// declaration (class, method, and so on), we don't have enough information
96 /// to create a builder and this object records its members and types until, 93 /// to create a builder and this object records its members and types until,
97 /// for example, [addClass] is called. 94 /// for example, [addClass] is called.
98 DeclarationBuilder<T> currentDeclaration; 95 DeclarationBuilder<T> currentDeclaration;
99 96
100 bool canAddImplementationBuilders = false; 97 bool canAddImplementationBuilders = false;
101 98
102 /// Exports in addition to the members declared in this library. 99 /// References to nodes exported by the `export` directives, don't conflict
103 /// 100 /// with each other, and not are hidden by local declarations.
104 /// See [../dill/dill_library_builder.dart] for additional details on the 101 List<Reference> additionalExports;
105 /// format used.
106 List<List<String>> additionalExports;
107 102
108 SourceLibraryBuilder(SourceLoader loader, Uri fileUri) 103 SourceLibraryBuilder(SourceLoader loader, Uri fileUri)
109 : this.fromScopes(loader, fileUri, new DeclarationBuilder<T>.library(), 104 : this.fromScopes(loader, fileUri, new DeclarationBuilder<T>.library(),
110 new Scope.top()); 105 new Scope.top());
111 106
112 SourceLibraryBuilder.fromScopes( 107 SourceLibraryBuilder.fromScopes(
113 this.loader, this.fileUri, this.libraryDeclaration, this.importScope) 108 this.loader, this.fileUri, this.libraryDeclaration, this.importScope)
114 : disableTypeInference = loader.target.disableTypeInference, 109 : disableTypeInference = loader.target.disableTypeInference,
115 currentDeclaration = libraryDeclaration, 110 currentDeclaration = libraryDeclaration,
116 super( 111 super(
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 511 }
517 import.finalizeImports(this); 512 import.finalizeImports(this);
518 } 513 }
519 if (!explicitCoreImport) { 514 if (!explicitCoreImport) {
520 loader.coreLibrary.exportScope.forEach((String name, Builder member) { 515 loader.coreLibrary.exportScope.forEach((String name, Builder member) {
521 addToScope(name, member, -1, true); 516 addToScope(name, member, -1, true);
522 }); 517 });
523 } 518 }
524 exportScope.forEach((String name, Builder member) { 519 exportScope.forEach((String name, Builder member) {
525 if (member.parent != this) { 520 if (member.parent != this) {
526 additionalExports ??= <List<String>>[]; 521 additionalExports ??= <Reference>[];
527 Builder parent = member.parent; 522 Builder parent = member.parent;
528 if (parent is LibraryBuilder) { 523 if (parent is LibraryBuilder) {
529 additionalExports.add(<String>[ 524 additionalExports.add(member.target.reference);
scheglov 2017/08/29 16:56:57 The specification says that it is an error to re-e
ahe 2017/08/30 14:24:52 I had more time to think about this. I think it is
530 relativizeUri(parent.uri, base: uri.resolve(".")),
531 name
532 ]);
533 } else {
534 InvalidTypeBuilder invalidType = member;
535 String message = invalidType.message.message;
536 additionalExports.add(<String>[null, name, message]);
537 } 525 }
538 } 526 }
539 }); 527 });
540 } 528 }
541 529
542 @override 530 @override
543 void addToScope(String name, Builder member, int charOffset, bool isImport) { 531 void addToScope(String name, Builder member, int charOffset, bool isImport) {
544 Map<String, Builder> map = 532 Map<String, Builder> map =
545 member.isSetter ? importScope.setters : importScope.local; 533 member.isSetter ? importScope.setters : importScope.local;
546 Builder existing = map[name]; 534 Builder existing = map[name];
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 /// synthesize type variables on the factory matching the class'. 670 /// synthesize type variables on the factory matching the class'.
683 void addFactoryDeclaration( 671 void addFactoryDeclaration(
684 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { 672 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) {
685 factoryDeclarations[procedure] = factoryDeclaration; 673 factoryDeclarations[procedure] = factoryDeclaration;
686 } 674 }
687 675
688 Scope toScope(Scope parent) { 676 Scope toScope(Scope parent) {
689 return new Scope(members, setters, parent, isModifiable: false); 677 return new Scope(members, setters, parent, isModifiable: false);
690 } 678 }
691 } 679 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart ('k') | pkg/front_end/test/fasta/ambiguous_export_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698