Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 loader |
| 155 .read(resolve(uri), charOffset, accessor: this) | 157 .read(resolve(uri), charOffset, accessor: this) |
| 156 .addExporter(this, combinators, charOffset); | 158 .addExporter(this, combinators, charOffset); |
| 159 exports.add(new Export( | |
| 160 this, | |
| 161 loader.read(resolve(uri), charOffset, accessor: this), | |
|
Siggi Cherem (dart-lang)
2017/07/26 19:22:42
rather than rereading it here, store it in a local
scheglov
2017/07/26 19:33:04
Done.
| |
| 162 combinators, | |
| 163 charOffset)); | |
| 157 } | 164 } |
| 158 | 165 |
| 159 void addImport( | 166 void addImport( |
| 160 List<MetadataBuilder> metadata, | 167 List<MetadataBuilder> metadata, |
| 161 String uri, | 168 String uri, |
| 162 Unhandled conditionalUris, | 169 Unhandled conditionalUris, |
| 163 String prefix, | 170 String prefix, |
| 164 List<Combinator> combinators, | 171 List<Combinator> combinators, |
| 165 bool deferred, | 172 bool deferred, |
| 166 int charOffset, | 173 int charOffset, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 addCompileTimeError( | 337 addCompileTimeError( |
| 331 templateDeferredPrefixDuplicated.withArguments(name), | 338 templateDeferredPrefixDuplicated.withArguments(name), |
| 332 deferred.charOffset, | 339 deferred.charOffset, |
| 333 fileUri); | 340 fileUri); |
| 334 addCompileTimeError( | 341 addCompileTimeError( |
| 335 templateDeferredPrefixDuplicatedCause.withArguments(name), | 342 templateDeferredPrefixDuplicatedCause.withArguments(name), |
| 336 other.charOffset, | 343 other.charOffset, |
| 337 fileUri); | 344 fileUri); |
| 338 } | 345 } |
| 339 return existing | 346 return existing |
| 340 ..exports.merge(builder.exports, | 347 ..exportScope.merge(builder.exportScope, |
| 341 (String name, Builder existing, Builder member) { | 348 (String name, Builder existing, Builder member) { |
| 342 return buildAmbiguousBuilder(name, existing, member, charOffset); | 349 return buildAmbiguousBuilder(name, existing, member, charOffset); |
| 343 }); | 350 }); |
| 344 } else if (isDuplicatedDefinition(existing, builder)) { | 351 } else if (isDuplicatedDefinition(existing, builder)) { |
| 345 addCompileTimeError(templateDuplicatedDefinition.withArguments(name), | 352 addCompileTimeError(templateDuplicatedDefinition.withArguments(name), |
| 346 charOffset, fileUri); | 353 charOffset, fileUri); |
| 347 } | 354 } |
| 348 return members[name] = builder; | 355 return members[name] = builder; |
| 349 } | 356 } |
| 350 | 357 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 | 498 |
| 492 void addImportsToScope() { | 499 void addImportsToScope() { |
| 493 bool explicitCoreImport = this == loader.coreLibrary; | 500 bool explicitCoreImport = this == loader.coreLibrary; |
| 494 for (Import import in imports) { | 501 for (Import import in imports) { |
| 495 if (import.imported == loader.coreLibrary) { | 502 if (import.imported == loader.coreLibrary) { |
| 496 explicitCoreImport = true; | 503 explicitCoreImport = true; |
| 497 } | 504 } |
| 498 import.finalizeImports(this); | 505 import.finalizeImports(this); |
| 499 } | 506 } |
| 500 if (!explicitCoreImport) { | 507 if (!explicitCoreImport) { |
| 501 loader.coreLibrary.exports.forEach((String name, Builder member) { | 508 loader.coreLibrary.exportScope.forEach((String name, Builder member) { |
| 502 addToScope(name, member, -1, true); | 509 addToScope(name, member, -1, true); |
| 503 }); | 510 }); |
| 504 } | 511 } |
| 505 } | 512 } |
| 506 | 513 |
| 507 @override | 514 @override |
| 508 void addToScope(String name, Builder member, int charOffset, bool isImport) { | 515 void addToScope(String name, Builder member, int charOffset, bool isImport) { |
| 509 Map<String, Builder> map = | 516 Map<String, Builder> map = |
| 510 member.isSetter ? importScope.setters : importScope.local; | 517 member.isSetter ? importScope.setters : importScope.local; |
| 511 Builder existing = map[name]; | 518 Builder existing = map[name]; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 /// synthesize type variables on the factory matching the class'. | 654 /// synthesize type variables on the factory matching the class'. |
| 648 void addFactoryDeclaration( | 655 void addFactoryDeclaration( |
| 649 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { | 656 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { |
| 650 factoryDeclarations[procedure] = factoryDeclaration; | 657 factoryDeclarations[procedure] = factoryDeclaration; |
| 651 } | 658 } |
| 652 | 659 |
| 653 Scope toScope(Scope parent) { | 660 Scope toScope(Scope parent) { |
| 654 return new Scope(members, setters, parent, isModifiable: false); | 661 return new Scope(members, setters, parent, isModifiable: false); |
| 655 } | 662 } |
| 656 } | 663 } |
| OLD | NEW |