| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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; | 5 library elements; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
| 9 import '../constants/constructors.dart'; | 9 import '../constants/constructors.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 static bool isStaticOrTopLevelFunction(Element element) { | 500 static bool isStaticOrTopLevelFunction(Element element) { |
| 501 return isStaticOrTopLevel(element) && element.isFunction; | 501 return isStaticOrTopLevel(element) && element.isFunction; |
| 502 } | 502 } |
| 503 | 503 |
| 504 static bool isInstanceMethod(Element element) { | 504 static bool isInstanceMethod(Element element) { |
| 505 return !Elements.isUnresolved(element) && | 505 return !Elements.isUnresolved(element) && |
| 506 element.isInstanceMember && | 506 element.isInstanceMember && |
| 507 (identical(element.kind, ElementKind.FUNCTION)); | 507 (identical(element.kind, ElementKind.FUNCTION)); |
| 508 } | 508 } |
| 509 | 509 |
| 510 /// Also returns true for [ConstructorBodyElement]s and getters/setters. | |
| 511 static bool isNonAbstractInstanceMember(Element element) { | |
| 512 // The generative constructor body is not a function. We therefore treat | |
| 513 // it specially. | |
| 514 if (element.isGenerativeConstructorBody) return true; | |
| 515 return !Elements.isUnresolved(element) && | |
| 516 !element.isAbstract && | |
| 517 element.isInstanceMember && | |
| 518 (element.isFunction || element.isAccessor); | |
| 519 } | |
| 520 | |
| 521 static bool isInstanceSend(Send send, TreeElements elements) { | 510 static bool isInstanceSend(Send send, TreeElements elements) { |
| 522 Element element = elements[send]; | 511 Element element = elements[send]; |
| 523 if (element == null) return !isClosureSend(send, element); | 512 if (element == null) return !isClosureSend(send, element); |
| 524 return isInstanceMethod(element) || | 513 return isInstanceMethod(element) || |
| 525 isInstanceField(element) || | 514 isInstanceField(element) || |
| 526 (send.isConditional && !element.isStatic); | 515 (send.isConditional && !element.isStatic); |
| 527 } | 516 } |
| 528 | 517 |
| 529 static bool isClosureSend(Send send, Element element) { | 518 static bool isClosureSend(Send send, Element element) { |
| 530 if (send.isPropertyAccess) return false; | 519 if (send.isPropertyAccess) return false; |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 bool implementsInterface(ClassElement intrface); | 1524 bool implementsInterface(ClassElement intrface); |
| 1536 | 1525 |
| 1537 bool hasFieldShadowedBy(Element fieldMember); | 1526 bool hasFieldShadowedBy(Element fieldMember); |
| 1538 | 1527 |
| 1539 /// Returns `true` if this class has a @proxy annotation. | 1528 /// Returns `true` if this class has a @proxy annotation. |
| 1540 bool get isProxy; | 1529 bool get isProxy; |
| 1541 | 1530 |
| 1542 /// Returns `true` if the class hierarchy for this class contains errors. | 1531 /// Returns `true` if the class hierarchy for this class contains errors. |
| 1543 bool get hasIncompleteHierarchy; | 1532 bool get hasIncompleteHierarchy; |
| 1544 | 1533 |
| 1545 void addBackendMember(Element element); | 1534 void addBackendMember(ConstructorBodyElement element); |
| 1546 void reverseBackendMembers(); | 1535 void reverseBackendMembers(); |
| 1547 | 1536 |
| 1548 Element lookupMember(String memberName); | 1537 Element lookupMember(String memberName); |
| 1549 | 1538 |
| 1550 /// Looks up a class instance member declared or inherited in this class | 1539 /// Looks up a class instance member declared or inherited in this class |
| 1551 /// using [memberName] to match the (private) name and getter/setter property. | 1540 /// using [memberName] to match the (private) name and getter/setter property. |
| 1552 /// | 1541 /// |
| 1553 /// This method recursively visits superclasses until the member is found or | 1542 /// This method recursively visits superclasses until the member is found or |
| 1554 /// [stopAt] is reached. | 1543 /// [stopAt] is reached. |
| 1555 MemberElement lookupByName(Name memberName, {ClassElement stopAt}); | 1544 MemberElement lookupByName(Name memberName, {ClassElement stopAt}); |
| 1556 MemberElement lookupSuperByName(Name memberName); | 1545 MemberElement lookupSuperByName(Name memberName); |
| 1557 | 1546 |
| 1558 Element lookupLocalMember(String memberName); | 1547 Element lookupLocalMember(String memberName); |
| 1559 Element lookupBackendMember(String memberName); | 1548 ConstructorBodyElement lookupBackendMember(String memberName); |
| 1560 Element lookupSuperMember(String memberName); | 1549 Element lookupSuperMember(String memberName); |
| 1561 | 1550 |
| 1562 Element lookupSuperMemberInLibrary(String memberName, LibraryElement library); | 1551 Element lookupSuperMemberInLibrary(String memberName, LibraryElement library); |
| 1563 | 1552 |
| 1564 // TODO(johnniwinther): Clean up semantics. Can the default constructor take | 1553 // TODO(johnniwinther): Clean up semantics. Can the default constructor take |
| 1565 // optional arguments? Must it be resolved? | 1554 // optional arguments? Must it be resolved? |
| 1566 ConstructorElement lookupDefaultConstructor(); | 1555 ConstructorElement lookupDefaultConstructor(); |
| 1567 ConstructorElement lookupConstructor(String name); | 1556 ConstructorElement lookupConstructor(String name); |
| 1568 | 1557 |
| 1569 void forEachMember(void f(ClassElement enclosingClass, Element member), | 1558 void forEachMember(void f(ClassElement enclosingClass, Element member), |
| 1570 {bool includeBackendMembers: false, | 1559 {bool includeBackendMembers: false, |
| 1571 bool includeSuperAndInjectedMembers: false}); | 1560 bool includeSuperAndInjectedMembers: false}); |
| 1572 | 1561 |
| 1573 void forEachInstanceField( | 1562 void forEachInstanceField( |
| 1574 void f(ClassElement enclosingClass, FieldElement field), | 1563 void f(ClassElement enclosingClass, FieldElement field), |
| 1575 {bool includeSuperAndInjectedMembers: false}); | 1564 {bool includeSuperAndInjectedMembers: false}); |
| 1576 | 1565 |
| 1577 /// Similar to [forEachInstanceField] but visits static fields. | 1566 /// Similar to [forEachInstanceField] but visits static fields. |
| 1578 void forEachStaticField(void f(ClassElement enclosingClass, Element field)); | 1567 void forEachStaticField(void f(ClassElement enclosingClass, Element field)); |
| 1579 | 1568 |
| 1580 void forEachBackendMember(void f(Element member)); | 1569 void forEachBackendMember(void f(ConstructorBodyElement member)); |
| 1581 | 1570 |
| 1582 /// Looks up the member [name] in this class. | 1571 /// Looks up the member [name] in this class. |
| 1583 Member lookupClassMember(Name name); | 1572 Member lookupClassMember(Name name); |
| 1584 | 1573 |
| 1585 /// Calls [f] with each member of this class. | 1574 /// Calls [f] with each member of this class. |
| 1586 void forEachClassMember(f(Member member)); | 1575 void forEachClassMember(f(Member member)); |
| 1587 | 1576 |
| 1588 /// Looks up the member [name] in the interface of this class. | 1577 /// Looks up the member [name] in the interface of this class. |
| 1589 MemberSignature lookupInterfaceMember(Name name); | 1578 MemberSignature lookupInterfaceMember(Name name); |
| 1590 | 1579 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1909 /// by a field. | 1898 /// by a field. |
| 1910 bool get isDeclaredByField; | 1899 bool get isDeclaredByField; |
| 1911 | 1900 |
| 1912 /// Returns `true` if this member is abstract. | 1901 /// Returns `true` if this member is abstract. |
| 1913 bool get isAbstract; | 1902 bool get isAbstract; |
| 1914 | 1903 |
| 1915 /// If abstract, [implementation] points to the overridden concrete member, | 1904 /// If abstract, [implementation] points to the overridden concrete member, |
| 1916 /// if any. Otherwise [implementation] points to the member itself. | 1905 /// if any. Otherwise [implementation] points to the member itself. |
| 1917 Member get implementation; | 1906 Member get implementation; |
| 1918 } | 1907 } |
| OLD | NEW |