| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 elements.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 import 'dart:collection' show LinkedHashMap; |
| 8 | 9 |
| 9 import 'elements.dart'; | 10 import 'elements.dart'; |
| 10 import '../../compiler.dart' as api; | 11 import '../../compiler.dart' as api; |
| 11 import '../tree/tree.dart'; | 12 import '../tree/tree.dart'; |
| 12 import '../util/util.dart'; | 13 import '../util/util.dart'; |
| 13 import '../resolution/resolution.dart'; | 14 import '../resolution/resolution.dart'; |
| 14 | 15 |
| 15 import '../dart2jslib.dart' show invariant, | 16 import '../dart2jslib.dart' show invariant, |
| 16 InterfaceType, | 17 InterfaceType, |
| 17 DartType, | 18 DartType, |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 /** | 558 /** |
| 558 * Link for elements exported either through export declarations or through | 559 * Link for elements exported either through export declarations or through |
| 559 * declaration. This field should not be accessed directly but instead through | 560 * declaration. This field should not be accessed directly but instead through |
| 560 * the [exports] getter. | 561 * the [exports] getter. |
| 561 * | 562 * |
| 562 * [LibraryDependencyHandler] sets this field through [setExports] when the | 563 * [LibraryDependencyHandler] sets this field through [setExports] when the |
| 563 * library is loaded. | 564 * library is loaded. |
| 564 */ | 565 */ |
| 565 Link<Element> slotForExports; | 566 Link<Element> slotForExports; |
| 566 | 567 |
| 568 final Map<LibraryDependency, LibraryElement> tagMapping = |
| 569 new LinkedHashMap<LibraryDependency, LibraryElement>(); |
| 570 |
| 567 LibraryElementX(Script script, [Uri canonicalUri, LibraryElement this.origin]) | 571 LibraryElementX(Script script, [Uri canonicalUri, LibraryElement this.origin]) |
| 568 : this.canonicalUri = ((canonicalUri == null) ? script.uri : canonicalUri), | 572 : this.canonicalUri = ((canonicalUri == null) ? script.uri : canonicalUri), |
| 569 importScope = new Map<SourceString, Element>(), | 573 importScope = new Map<SourceString, Element>(), |
| 570 super(new SourceString(script.name), ElementKind.LIBRARY, null) { | 574 super(new SourceString(script.name), ElementKind.LIBRARY, null) { |
| 571 entryCompilationUnit = new CompilationUnitElementX(script, this); | 575 entryCompilationUnit = new CompilationUnitElementX(script, this); |
| 572 if (isPatch) { | 576 if (isPatch) { |
| 573 origin.patch = this; | 577 origin.patch = this; |
| 574 } | 578 } |
| 575 } | 579 } |
| 576 | 580 |
| 577 bool get isPatched => patch != null; | 581 bool get isPatched => patch != null; |
| 578 bool get isPatch => origin != null; | 582 bool get isPatch => origin != null; |
| 579 | 583 |
| 580 LibraryElement get declaration => super.declaration; | 584 LibraryElement get declaration => super.declaration; |
| 581 LibraryElement get implementation => super.implementation; | 585 LibraryElement get implementation => super.implementation; |
| 582 | 586 |
| 583 CompilationUnitElement getCompilationUnit() => entryCompilationUnit; | 587 CompilationUnitElement getCompilationUnit() => entryCompilationUnit; |
| 584 | 588 |
| 585 void addCompilationUnit(CompilationUnitElement element) { | 589 void addCompilationUnit(CompilationUnitElement element) { |
| 586 compilationUnits = compilationUnits.prepend(element); | 590 compilationUnits = compilationUnits.prepend(element); |
| 587 } | 591 } |
| 588 | 592 |
| 589 void addTag(LibraryTag tag, DiagnosticListener listener) { | 593 void addTag(LibraryTag tag, DiagnosticListener listener) { |
| 590 tags = tags.prepend(tag); | 594 tags = tags.prepend(tag); |
| 591 } | 595 } |
| 592 | 596 |
| 597 void resolvedTag(LibraryDependency tag, LibraryElement library) { |
| 598 assert(tagMapping[tag] == null); |
| 599 tagMapping[tag] = library; |
| 600 } |
| 601 |
| 602 LibraryElement getDependency(LibraryDependency tag) => tagMapping[tag]; |
| 603 |
| 593 /** | 604 /** |
| 594 * Adds [element] to the import scope of this library. | 605 * Adds [element] to the import scope of this library. |
| 595 * | 606 * |
| 596 * If an element by the same name is already in the imported scope, an | 607 * If an element by the same name is already in the imported scope, an |
| 597 * [ErroneousElement] will be put in the imported scope, allowing for the | 608 * [ErroneousElement] will be put in the imported scope, allowing for the |
| 598 * detection of ambiguous uses of imported names. | 609 * detection of ambiguous uses of imported names. |
| 599 */ | 610 */ |
| 600 void addImport(Element element, DiagnosticListener listener) { | 611 void addImport(Element element, DiagnosticListener listener) { |
| 601 Element existing = importScope[element.name]; | 612 Element existing = importScope[element.name]; |
| 602 if (existing != null) { | 613 if (existing != null) { |
| (...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 | 1980 |
| 1970 MetadataAnnotation ensureResolved(Compiler compiler) { | 1981 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1971 if (resolutionState == STATE_NOT_STARTED) { | 1982 if (resolutionState == STATE_NOT_STARTED) { |
| 1972 compiler.resolver.resolveMetadataAnnotation(this); | 1983 compiler.resolver.resolveMetadataAnnotation(this); |
| 1973 } | 1984 } |
| 1974 return this; | 1985 return this; |
| 1975 } | 1986 } |
| 1976 | 1987 |
| 1977 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1988 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1978 } | 1989 } |
| OLD | NEW |