| 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 import 'dart:collection' show LinkedHashMap; |
| 9 | 9 |
| 10 import 'elements.dart'; | 10 import 'elements.dart'; |
| (...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 /** | 1575 /** |
| 1576 * Find the first member in the class chain with the given [selector]. | 1576 * Find the first member in the class chain with the given [selector]. |
| 1577 * | 1577 * |
| 1578 * This method is NOT to be used for resolving | 1578 * This method is NOT to be used for resolving |
| 1579 * unqualified sends because it does not implement the scoping | 1579 * unqualified sends because it does not implement the scoping |
| 1580 * rules, where library scope comes before superclass scope. | 1580 * rules, where library scope comes before superclass scope. |
| 1581 * | 1581 * |
| 1582 * When called on the implementation element both members declared in the | 1582 * When called on the implementation element both members declared in the |
| 1583 * origin and the patch class are returned. | 1583 * origin and the patch class are returned. |
| 1584 */ | 1584 */ |
| 1585 Element lookupSelector(Selector selector) { | 1585 Element lookupSelector(Selector selector, Compiler compiler) { |
| 1586 return internalLookupSelector(selector, false); | 1586 return internalLookupSelector(selector, compiler, false); |
| 1587 } | 1587 } |
| 1588 | 1588 |
| 1589 Element lookupSuperSelector(Selector selector) { | 1589 Element lookupSuperSelector(Selector selector, Compiler compiler) { |
| 1590 return internalLookupSelector(selector, true); | 1590 return internalLookupSelector(selector, compiler, true); |
| 1591 } | 1591 } |
| 1592 | 1592 |
| 1593 Element internalLookupSelector(Selector selector, bool isSuperLookup) { | 1593 Element internalLookupSelector(Selector selector, |
| 1594 Compiler compiler, |
| 1595 bool isSuperLookup) { |
| 1594 SourceString name = selector.name; | 1596 SourceString name = selector.name; |
| 1595 bool isPrivate = name.isPrivate(); | 1597 bool isPrivate = name.isPrivate(); |
| 1596 LibraryElement library = selector.library; | 1598 LibraryElement library = selector.library; |
| 1597 for (ClassElement current = isSuperLookup ? superclass : this; | 1599 for (ClassElement current = isSuperLookup ? superclass : this; |
| 1598 current != null; | 1600 current != null; |
| 1599 current = current.superclass) { | 1601 current = current.superclass) { |
| 1600 Element member = current.lookupLocalMember(name); | 1602 Element member = current.lookupLocalMember(name); |
| 1601 if (member == null && current.isPatched) { | 1603 if (member == null && current.isPatched) { |
| 1602 // Doing lookups on selectors is done after resolution, so it | 1604 // Doing lookups on selectors is done after resolution, so it |
| 1603 // is safe to look in the patch class. | 1605 // is safe to look in the patch class. |
| 1604 member = current.patch.lookupLocalMember(name); | 1606 member = current.patch.lookupLocalMember(name); |
| 1605 } | 1607 } |
| 1606 if (member == null) continue; | 1608 if (member == null) continue; |
| 1607 // Private members from a different library are not visible. | 1609 // Private members from a different library are not visible. |
| 1608 if (isPrivate && !identical(library, member.getLibrary())) continue; | 1610 if (isPrivate && !identical(library, member.getLibrary())) continue; |
| 1609 // Static members are not inherited. | 1611 // Static members are not inherited. |
| 1610 if (member.modifiers.isStatic() && !identical(this, current)) continue; | 1612 if (member.modifiers.isStatic() && !identical(this, current)) continue; |
| 1611 // If we find an abstract field we have to make sure that it has | 1613 // If we find an abstract field we have to make sure that it has |
| 1612 // the getter or setter part we're actually looking | 1614 // the getter or setter part we're actually looking |
| 1613 // for. Otherwise, we continue up the superclass chain. | 1615 // for. Otherwise, we continue up the superclass chain. |
| 1614 if (member.isAbstractField()) { | 1616 if (member.isAbstractField()) { |
| 1615 AbstractFieldElement field = member; | 1617 AbstractFieldElement field = member; |
| 1616 FunctionElement getter = field.getter; | 1618 FunctionElement getter = field.getter; |
| 1617 FunctionElement setter = field.setter; | 1619 FunctionElement setter = field.setter; |
| 1618 if (selector.isSetter()) { | 1620 if (selector.isSetter()) { |
| 1619 if (setter != null) return setter; | 1621 // Abstract members can be defined in a super class. |
| 1622 if (setter != null && !setter.isAbstract(compiler)) return setter; |
| 1620 } else { | 1623 } else { |
| 1621 assert(selector.isGetter() || selector.isCall()); | 1624 assert(selector.isGetter() || selector.isCall()); |
| 1622 if (getter != null) return getter; | 1625 if (getter != null && !getter.isAbstract(compiler)) return getter; |
| 1623 } | 1626 } |
| 1624 } else { | 1627 // Abstract members can be defined in a super class. |
| 1628 } else if (!member.isAbstract(compiler)) { |
| 1625 return member; | 1629 return member; |
| 1626 } | 1630 } |
| 1627 } | 1631 } |
| 1628 return null; | 1632 return null; |
| 1629 } | 1633 } |
| 1630 | 1634 |
| 1631 /** | 1635 /** |
| 1632 * Find the first member in the class chain with the given | 1636 * Find the first member in the class chain with the given |
| 1633 * [memberName]. This method is NOT to be used for resolving | 1637 * [memberName]. This method is NOT to be used for resolving |
| 1634 * unqualified sends because it does not implement the scoping | 1638 * unqualified sends because it does not implement the scoping |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 | 2099 |
| 2096 MetadataAnnotation ensureResolved(Compiler compiler) { | 2100 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2097 if (resolutionState == STATE_NOT_STARTED) { | 2101 if (resolutionState == STATE_NOT_STARTED) { |
| 2098 compiler.resolver.resolveMetadataAnnotation(this); | 2102 compiler.resolver.resolveMetadataAnnotation(this); |
| 2099 } | 2103 } |
| 2100 return this; | 2104 return this; |
| 2101 } | 2105 } |
| 2102 | 2106 |
| 2103 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2107 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2104 } | 2108 } |
| OLD | NEW |