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 Resolution; | 9 import '../common/resolution.dart' show Resolution; |
10 import '../compile_time_constants.dart'; | 10 import '../compile_time_constants.dart'; |
(...skipping 2815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2826 } else { | 2826 } else { |
2827 MemberElement member = element; | 2827 MemberElement member = element; |
2828 // TODO(johnniwinther): Needed to provoke a parsing and with it discovery | 2828 // TODO(johnniwinther): Needed to provoke a parsing and with it discovery |
2829 // of parse errors to make [element] erroneous. Fix this! | 2829 // of parse errors to make [element] erroneous. Fix this! |
2830 member.computeType(resolution); | 2830 member.computeType(resolution); |
2831 if (member.isMalformed) { | 2831 if (member.isMalformed) { |
2832 // [member] has parse errors. | 2832 // [member] has parse errors. |
2833 semantics = new StaticAccess.unresolved(member); | 2833 semantics = new StaticAccess.unresolved(member); |
2834 } else if (member.isFunction) { | 2834 } else if (member.isFunction) { |
2835 // `a = b`, `a++` or `a += b` where `a` is a function. | 2835 // `a = b`, `a++` or `a += b` where `a` is a function. |
2836 ErroneousElement error = reportAndCreateErroneousElement( | 2836 reportAndCreateErroneousElement( |
2837 node.selector, name.text, MessageKind.ASSIGNING_METHOD, const {}); | 2837 node.selector, name.text, MessageKind.ASSIGNING_METHOD, const {}); |
2838 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 2838 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
2839 if (node.isComplex) { | 2839 if (node.isComplex) { |
2840 // `a++` or `a += b` where `a` is a function. | 2840 // `a++` or `a += b` where `a` is a function. |
2841 registry.registerStaticUse(new StaticUse.staticTearOff(element)); | 2841 registry.registerStaticUse(new StaticUse.staticTearOff(element)); |
2842 } | 2842 } |
2843 semantics = member.isTopLevel | 2843 semantics = member.isTopLevel |
2844 ? new StaticAccess.topLevelMethod(member) | 2844 ? new StaticAccess.topLevelMethod(member) |
2845 : new StaticAccess.staticMethod(member); | 2845 : new StaticAccess.staticMethod(member); |
2846 } else { | 2846 } else { |
2847 // `a = b`, `a++` or `a += b` where `a` is a field. | 2847 // `a = b`, `a++` or `a += b` where `a` is a field. |
2848 assert(invariant(node, member.isField, | 2848 assert(invariant(node, member.isField, |
2849 message: "Unexpected element: $member.")); | 2849 message: "Unexpected element: $member.")); |
2850 if (node.isComplex) { | 2850 if (node.isComplex) { |
2851 // `a++` or `a += b` where `a` is a field. | 2851 // `a++` or `a += b` where `a` is a field. |
2852 registry.registerStaticUse(new StaticUse.staticGet(member)); | 2852 registry.registerStaticUse(new StaticUse.staticGet(member)); |
2853 } | 2853 } |
2854 if (member.isFinal || member.isConst) { | 2854 if (member.isFinal || member.isConst) { |
2855 ErroneousElement error = reportAndCreateErroneousElement( | 2855 reportAndCreateErroneousElement( |
2856 node.selector, | 2856 node.selector, |
2857 name.text, | 2857 name.text, |
2858 MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER, | 2858 MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER, |
2859 {'name': name}); | 2859 {'name': name}); |
2860 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 2860 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
2861 semantics = member.isTopLevel | 2861 semantics = member.isTopLevel |
2862 ? new StaticAccess.finalTopLevelField(member) | 2862 ? new StaticAccess.finalTopLevelField(member) |
2863 : new StaticAccess.finalStaticField(member); | 2863 : new StaticAccess.finalStaticField(member); |
2864 } else { | 2864 } else { |
2865 registry.registerStaticUse(new StaticUse.staticSet(member)); | 2865 registry.registerStaticUse(new StaticUse.staticSet(member)); |
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4763 } | 4763 } |
4764 return const NoneResult(); | 4764 return const NoneResult(); |
4765 } | 4765 } |
4766 } | 4766 } |
4767 | 4767 |
4768 /// Looks up [name] in [scope] and unwraps the result. | 4768 /// Looks up [name] in [scope] and unwraps the result. |
4769 Element lookupInScope( | 4769 Element lookupInScope( |
4770 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4770 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
4771 return Elements.unwrap(scope.lookup(name), reporter, node); | 4771 return Elements.unwrap(scope.lookup(name), reporter, node); |
4772 } | 4772 } |
OLD | NEW |