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 dart2js.resolution.members; | 5 library dart2js.resolution.members; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show Selectors; | 8 import '../common/names.dart' show Selectors; |
9 import '../common/resolution.dart' show Feature; | 9 import '../common/resolution.dart' show Feature; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 if (node.isOperator) { | 1817 if (node.isOperator) { |
1818 // When the resolved receiver is a class, we can have two cases: | 1818 // When the resolved receiver is a class, we can have two cases: |
1819 // 1) a static send: C.foo, or | 1819 // 1) a static send: C.foo, or |
1820 // 2) an operator send, where the receiver is a class literal: 'C + 1'. | 1820 // 2) an operator send, where the receiver is a class literal: 'C + 1'. |
1821 // The following code that looks up the selector on the resolved | 1821 // The following code that looks up the selector on the resolved |
1822 // receiver will treat the second as the invocation of a static operator | 1822 // receiver will treat the second as the invocation of a static operator |
1823 // if the resolved receiver is not null. | 1823 // if the resolved receiver is not null. |
1824 return const NoneResult(); | 1824 return const NoneResult(); |
1825 } | 1825 } |
1826 MembersCreator.computeClassMembersByName( | 1826 MembersCreator.computeClassMembersByName( |
1827 compiler, receiverClass.declaration, name); | 1827 resolution, receiverClass.declaration, name); |
1828 Element member = receiverClass.lookupLocalMember(name); | 1828 Element member = receiverClass.lookupLocalMember(name); |
1829 if (member == null) { | 1829 if (member == null) { |
1830 return handleUnresolvedStaticMemberAccess( | 1830 return handleUnresolvedStaticMemberAccess( |
1831 node, memberName, receiverClass); | 1831 node, memberName, receiverClass); |
1832 } else if (member.isAmbiguous) { | 1832 } else if (member.isAmbiguous) { |
1833 return handleAmbiguousSend(node, memberName, member); | 1833 return handleAmbiguousSend(node, memberName, member); |
1834 } else if (member.isInstanceMember) { | 1834 } else if (member.isInstanceMember) { |
1835 return handleStaticInstanceMemberAccess( | 1835 return handleStaticInstanceMemberAccess( |
1836 node, memberName, receiverClass, member); | 1836 node, memberName, receiverClass, member); |
1837 } else if (memberName.isPrivate && memberName.library != member.library) { | 1837 } else if (memberName.isPrivate && memberName.library != member.library) { |
1838 return handlePrivateStaticMemberAccess( | 1838 return handlePrivateStaticMemberAccess( |
1839 node, memberName, receiverClass, member); | 1839 node, memberName, receiverClass, member); |
1840 } else { | 1840 } else { |
1841 return handleStaticOrTopLevelAccess(node, memberName, member); | 1841 return handleStaticOrTopLevelAccess(node, memberName, member); |
1842 } | 1842 } |
1843 } | 1843 } |
1844 | 1844 |
1845 /// Handle qualified update to a static member, like `a.b = c` or `a.b++` | 1845 /// Handle qualified update to a static member, like `a.b = c` or `a.b++` |
1846 /// where `a` is a class and `b` is a static member of `a`. | 1846 /// where `a` is a class and `b` is a static member of `a`. |
1847 ResolutionResult handleStaticMemberUpdate( | 1847 ResolutionResult handleStaticMemberUpdate( |
1848 Send node, Name memberName, ClassElement receiverClass) { | 1848 Send node, Name memberName, ClassElement receiverClass) { |
1849 String name = memberName.text; | 1849 String name = memberName.text; |
1850 receiverClass.ensureResolved(resolution); | 1850 receiverClass.ensureResolved(resolution); |
1851 MembersCreator.computeClassMembersByName( | 1851 MembersCreator.computeClassMembersByName( |
1852 compiler, receiverClass.declaration, name); | 1852 resolution, receiverClass.declaration, name); |
1853 Element member = receiverClass.lookupLocalMember(name); | 1853 Element member = receiverClass.lookupLocalMember(name); |
1854 if (member == null) { | 1854 if (member == null) { |
1855 return handleUnresolvedStaticMemberUpdate( | 1855 return handleUnresolvedStaticMemberUpdate( |
1856 node, memberName, receiverClass); | 1856 node, memberName, receiverClass); |
1857 } else if (member.isAmbiguous) { | 1857 } else if (member.isAmbiguous) { |
1858 return handleAmbiguousUpdate(node, memberName, member); | 1858 return handleAmbiguousUpdate(node, memberName, member); |
1859 } else if (member.isInstanceMember) { | 1859 } else if (member.isInstanceMember) { |
1860 return handleStaticInstanceMemberUpdate( | 1860 return handleStaticInstanceMemberUpdate( |
1861 node, memberName, receiverClass, member); | 1861 node, memberName, receiverClass, member); |
1862 } else if (memberName.isPrivate && memberName.library != member.library) { | 1862 } else if (memberName.isPrivate && memberName.library != member.library) { |
(...skipping 2834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4697 } | 4697 } |
4698 return const NoneResult(); | 4698 return const NoneResult(); |
4699 } | 4699 } |
4700 } | 4700 } |
4701 | 4701 |
4702 /// Looks up [name] in [scope] and unwraps the result. | 4702 /// Looks up [name] in [scope] and unwraps the result. |
4703 Element lookupInScope( | 4703 Element lookupInScope( |
4704 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4704 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
4705 return Elements.unwrap(scope.lookup(name), reporter, node); | 4705 return Elements.unwrap(scope.lookup(name), reporter, node); |
4706 } | 4706 } |
OLD | NEW |