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

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

Issue 2991753002: Add export dependencies to Kernel libraries and use them to resynthesize ExportElement(s) in Analyz… (Closed)
Patch Set: Extract exportedLibrary. 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 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;
8 8
9 import '../../base/resolve_relative_uri.dart' show resolveRelativeUri; 9 import '../../base/resolve_relative_uri.dart' show resolveRelativeUri;
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 final DeclarationBuilder<T> libraryDeclaration; 62 final DeclarationBuilder<T> libraryDeclaration;
63 63
64 final List<ConstructorReferenceBuilder> constructorReferences = 64 final List<ConstructorReferenceBuilder> constructorReferences =
65 <ConstructorReferenceBuilder>[]; 65 <ConstructorReferenceBuilder>[];
66 66
67 final List<SourceLibraryBuilder<T, R>> parts = <SourceLibraryBuilder<T, R>>[]; 67 final List<SourceLibraryBuilder<T, R>> parts = <SourceLibraryBuilder<T, R>>[];
68 68
69 final List<Import> imports = <Import>[]; 69 final List<Import> imports = <Import>[];
70 70
71 final List<Export> exports = <Export>[];
72
71 final Scope importScope; 73 final Scope importScope;
72 74
73 final Uri fileUri; 75 final Uri fileUri;
74 76
75 final List<List> implementationBuilders = <List<List>>[]; 77 final List<List> implementationBuilders = <List<List>>[];
76 78
77 /// Indicates whether type inference (and type promotion) should be disabled 79 /// Indicates whether type inference (and type promotion) should be disabled
78 /// for this library. 80 /// for this library.
79 final bool disableTypeInference; 81 final bool disableTypeInference;
80 82
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 "${name} != ${currentDeclaration.name}"); 146 "${name} != ${currentDeclaration.name}");
145 DeclarationBuilder<T> previous = currentDeclaration; 147 DeclarationBuilder<T> previous = currentDeclaration;
146 currentDeclaration = currentDeclaration.parent; 148 currentDeclaration = currentDeclaration.parent;
147 return previous; 149 return previous;
148 } 150 }
149 151
150 Uri resolve(String path) => uri.resolve(path); 152 Uri resolve(String path) => uri.resolve(path);
151 153
152 void addExport(List<MetadataBuilder> metadata, String uri, 154 void addExport(List<MetadataBuilder> metadata, String uri,
153 Unhandled conditionalUris, List<Combinator> combinators, int charOffset) { 155 Unhandled conditionalUris, List<Combinator> combinators, int charOffset) {
154 loader 156 var exportedLibrary = loader.read(resolve(uri), charOffset, accessor: this);
ahe 2017/08/08 09:47:58 Missing type.
scheglov 2017/08/08 16:31:16 It's not like it is worse typed now than it was. T
155 .read(resolve(uri), charOffset, accessor: this) 157 exportedLibrary.addExporter(this, combinators, charOffset);
156 .addExporter(this, combinators, charOffset); 158 exports.add(new Export(this, exportedLibrary, combinators, charOffset));
ahe 2017/08/08 09:47:58 Question: you need access to the metadata as well,
scheglov 2017/08/08 16:31:16 Yes, we need metadata for everything about what th
157 } 159 }
158 160
159 void addImport( 161 void addImport(
160 List<MetadataBuilder> metadata, 162 List<MetadataBuilder> metadata,
161 String uri, 163 String uri,
162 Unhandled conditionalUris, 164 Unhandled conditionalUris,
163 String prefix, 165 String prefix,
164 List<Combinator> combinators, 166 List<Combinator> combinators,
165 bool deferred, 167 bool deferred,
166 int charOffset, 168 int charOffset,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 addCompileTimeError( 332 addCompileTimeError(
331 templateDeferredPrefixDuplicated.withArguments(name), 333 templateDeferredPrefixDuplicated.withArguments(name),
332 deferred.charOffset, 334 deferred.charOffset,
333 fileUri); 335 fileUri);
334 addCompileTimeError( 336 addCompileTimeError(
335 templateDeferredPrefixDuplicatedCause.withArguments(name), 337 templateDeferredPrefixDuplicatedCause.withArguments(name),
336 other.charOffset, 338 other.charOffset,
337 fileUri); 339 fileUri);
338 } 340 }
339 return existing 341 return existing
340 ..exports.merge(builder.exports, 342 ..exportScope.merge(builder.exportScope,
341 (String name, Builder existing, Builder member) { 343 (String name, Builder existing, Builder member) {
342 return buildAmbiguousBuilder(name, existing, member, charOffset); 344 return buildAmbiguousBuilder(name, existing, member, charOffset);
343 }); 345 });
344 } else if (isDuplicatedDefinition(existing, builder)) { 346 } else if (isDuplicatedDefinition(existing, builder)) {
345 addCompileTimeError(templateDuplicatedDefinition.withArguments(name), 347 addCompileTimeError(templateDuplicatedDefinition.withArguments(name),
346 charOffset, fileUri); 348 charOffset, fileUri);
347 } 349 }
348 return members[name] = builder; 350 return members[name] = builder;
349 } 351 }
350 352
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 493
492 void addImportsToScope() { 494 void addImportsToScope() {
493 bool explicitCoreImport = this == loader.coreLibrary; 495 bool explicitCoreImport = this == loader.coreLibrary;
494 for (Import import in imports) { 496 for (Import import in imports) {
495 if (import.imported == loader.coreLibrary) { 497 if (import.imported == loader.coreLibrary) {
496 explicitCoreImport = true; 498 explicitCoreImport = true;
497 } 499 }
498 import.finalizeImports(this); 500 import.finalizeImports(this);
499 } 501 }
500 if (!explicitCoreImport) { 502 if (!explicitCoreImport) {
501 loader.coreLibrary.exports.forEach((String name, Builder member) { 503 loader.coreLibrary.exportScope.forEach((String name, Builder member) {
502 addToScope(name, member, -1, true); 504 addToScope(name, member, -1, true);
503 }); 505 });
504 } 506 }
505 } 507 }
506 508
507 @override 509 @override
508 void addToScope(String name, Builder member, int charOffset, bool isImport) { 510 void addToScope(String name, Builder member, int charOffset, bool isImport) {
509 Map<String, Builder> map = 511 Map<String, Builder> map =
510 member.isSetter ? importScope.setters : importScope.local; 512 member.isSetter ? importScope.setters : importScope.local;
511 Builder existing = map[name]; 513 Builder existing = map[name];
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 /// synthesize type variables on the factory matching the class'. 649 /// synthesize type variables on the factory matching the class'.
648 void addFactoryDeclaration( 650 void addFactoryDeclaration(
649 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { 651 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) {
650 factoryDeclarations[procedure] = factoryDeclaration; 652 factoryDeclarations[procedure] = factoryDeclaration;
651 } 653 }
652 654
653 Scope toScope(Scope parent) { 655 Scope toScope(Scope parent) {
654 return new Scope(members, setters, parent, isModifiable: false); 656 return new Scope(members, setters, parent, isModifiable: false);
655 } 657 }
656 } 658 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698