Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1126173002: Refactor handling of compounds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after
2799 } else { 2799 } else {
2800 seenNamedArguments[source] = namedArgument; 2800 seenNamedArguments[source] = namedArgument;
2801 } 2801 }
2802 } else if (!seenNamedArguments.isEmpty) { 2802 } else if (!seenNamedArguments.isEmpty) {
2803 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED); 2803 error(argument, MessageKind.INVALID_ARGUMENT_AFTER_NAMED);
2804 } 2804 }
2805 } 2805 }
2806 sendIsMemberAccess = oldSendIsMemberAccess; 2806 sendIsMemberAccess = oldSendIsMemberAccess;
2807 } 2807 }
2808 2808
2809 void registerTypeLiteralAccess(Send node, Element target) {
2810 // Set the type of the node to [Type] to mark this send as a
2811 // type literal.
2812 DartType type;
2813
2814 // TODO(johnniwinther): Remove this hack when we can pass more complex
2815 // information between methods than resolved elements.
2816 if (target == compiler.typeClass && node.receiver == null) {
2817 // Potentially a 'dynamic' type literal.
2818 type = registry.getType(node.selector);
2819 }
2820 if (type == null) {
2821 type = target.computeType(compiler);
2822 }
2823 registry.registerTypeLiteral(node, type);
2824
2825 if (!target.isTypeVariable) {
2826 // Don't try to make constants of calls and assignments to type literals.
2827 if (!node.isCall && node.asSendSet() == null) {
2828 analyzeConstantDeferred(node, enforceConst: false);
2829 } else {
2830 // The node itself is not a constant but we register the selector (the
2831 // identifier that refers to the class/typedef) as a constant.
2832 if (node.receiver != null) {
2833 // This is a hack for the case of prefix.Type, we need to store
2834 // the element on the selector, so [analyzeConstant] can build
2835 // the type literal from the selector.
2836 registry.useElement(node.selector, target);
2837 }
2838 analyzeConstantDeferred(node.selector, enforceConst: false);
2839 }
2840 }
2841 }
2842
2809 ResolutionResult visitSend(Send node) { 2843 ResolutionResult visitSend(Send node) {
2810 bool oldSendIsMemberAccess = sendIsMemberAccess; 2844 bool oldSendIsMemberAccess = sendIsMemberAccess;
2811 sendIsMemberAccess = node.isPropertyAccess || node.isCall; 2845 sendIsMemberAccess = node.isPropertyAccess || node.isCall;
2812 ResolutionResult result; 2846 ResolutionResult result;
2813 if (node.isLogicalAnd) { 2847 if (node.isLogicalAnd) {
2814 result = doInPromotionScope(node.receiver, () => resolveSend(node)); 2848 result = doInPromotionScope(node.receiver, () => resolveSend(node));
2815 } else { 2849 } else {
2816 result = resolveSend(node); 2850 result = resolveSend(node);
2817 } 2851 }
2818 sendIsMemberAccess = oldSendIsMemberAccess; 2852 sendIsMemberAccess = oldSendIsMemberAccess;
(...skipping 23 matching lines...) Expand all
2842 } else if (target.isTypeVariable) { 2876 } else if (target.isTypeVariable) {
2843 ClassElement cls = target.enclosingClass; 2877 ClassElement cls = target.enclosingClass;
2844 assert(enclosingElement.enclosingClass == cls); 2878 assert(enclosingElement.enclosingClass == cls);
2845 if (!Elements.hasAccessToTypeVariables(enclosingElement)) { 2879 if (!Elements.hasAccessToTypeVariables(enclosingElement)) {
2846 compiler.reportError(node, 2880 compiler.reportError(node,
2847 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, 2881 MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
2848 {'typeVariableName': node.selector}); 2882 {'typeVariableName': node.selector});
2849 } 2883 }
2850 registry.registerClassUsingVariableExpression(cls); 2884 registry.registerClassUsingVariableExpression(cls);
2851 registry.registerTypeVariableExpression(); 2885 registry.registerTypeVariableExpression();
2852 // Set the type of the node to [Type] to mark this send as a 2886 registerTypeLiteralAccess(node, target);
2853 // type variable expression.
2854 registry.registerTypeLiteral(node, target.computeType(compiler));
2855 } else if (target.impliesType && (!sendIsMemberAccess || node.isCall)) { 2887 } else if (target.impliesType && (!sendIsMemberAccess || node.isCall)) {
2856 // Set the type of the node to [Type] to mark this send as a 2888 registerTypeLiteralAccess(node, target);
2857 // type literal.
2858 DartType type;
2859
2860 // TODO(johnniwinther): Remove this hack when we can pass more complex
2861 // information between methods than resolved elements.
2862 if (target == compiler.typeClass && node.receiver == null) {
2863 // Potentially a 'dynamic' type literal.
2864 type = registry.getType(node.selector);
2865 }
2866 if (type == null) {
2867 type = target.computeType(compiler);
2868 }
2869 registry.registerTypeLiteral(node, type);
2870
2871 // Don't try to make constants of calls to type literals.
2872 if (!node.isCall) {
2873 analyzeConstantDeferred(node, enforceConst: false);
2874 } else {
2875 // The node itself is not a constant but we register the selector (the
2876 // identifier that refers to the class/typedef) as a constant.
2877 if (node.receiver != null) {
2878 // This is a hack for the case of prefix.Type, we need to store
2879 // the element on the selector, so [analyzeConstant] can build
2880 // the type literal from the selector.
2881 registry.useElement(node.selector, target);
2882 }
2883 analyzeConstantDeferred(node.selector, enforceConst: false);
2884 }
2885 } 2889 }
2886 if (isPotentiallyMutableTarget(target)) { 2890 if (isPotentiallyMutableTarget(target)) {
2887 if (enclosingElement != target.enclosingElement) { 2891 if (enclosingElement != target.enclosingElement) {
2888 for (Node scope in promotionScope) { 2892 for (Node scope in promotionScope) {
2889 registry.setAccessedByClosureIn(scope, target, node); 2893 registry.setAccessedByClosureIn(scope, target, node);
2890 } 2894 }
2891 } 2895 }
2892 } 2896 }
2893 } 2897 }
2894 2898
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3021 } 3025 }
3022 if (isComplex && getter == null && !inInstanceContext) { 3026 if (isComplex && getter == null && !inInstanceContext) {
3023 getter = reportAndCreateErroneousElement(node.selector, field.name, 3027 getter = reportAndCreateErroneousElement(node.selector, field.name,
3024 MessageKind.CANNOT_RESOLVE_GETTER, const {}); 3028 MessageKind.CANNOT_RESOLVE_GETTER, const {});
3025 registry.registerThrowNoSuchMethod(); 3029 registry.registerThrowNoSuchMethod();
3026 } 3030 }
3027 } else if (target.impliesType) { 3031 } else if (target.impliesType) {
3028 setter = reportAndCreateErroneousElement(node.selector, target.name, 3032 setter = reportAndCreateErroneousElement(node.selector, target.name,
3029 MessageKind.ASSIGNING_TYPE, const {}); 3033 MessageKind.ASSIGNING_TYPE, const {});
3030 registry.registerThrowNoSuchMethod(); 3034 registry.registerThrowNoSuchMethod();
3035 registerTypeLiteralAccess(node, target);
3031 } else if (target.isFinal || target.isConst) { 3036 } else if (target.isFinal || target.isConst) {
3032 if (Elements.isStaticOrTopLevelField(target) || target.isLocal) { 3037 if (Elements.isStaticOrTopLevelField(target) || target.isLocal) {
3033 setter = reportAndCreateErroneousElement( 3038 setter = reportAndCreateErroneousElement(
3034 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER, 3039 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER,
3035 const {}); 3040 const {});
3036 } else if (node.isSuperCall) { 3041 } else if (node.isSuperCall) {
3037 setter = reportAndCreateErroneousElement( 3042 setter = reportAndCreateErroneousElement(
3038 node.selector, target.name, MessageKind.SETTER_NOT_FOUND_IN_SUPER, 3043 node.selector, target.name, MessageKind.SETTER_NOT_FOUND_IN_SUPER,
3039 {'name': target.name, 'className': currentClass.name}); 3044 {'name': target.name, 'className': currentClass.name});
3040 registry.registerSuperNoSuchMethod(); 3045 registry.registerSuperNoSuchMethod();
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5161 } 5166 }
5162 5167
5163 /// The result for the resolution of the `assert` method. 5168 /// The result for the resolution of the `assert` method.
5164 class AssertResult implements ResolutionResult { 5169 class AssertResult implements ResolutionResult {
5165 const AssertResult(); 5170 const AssertResult();
5166 5171
5167 Element get element => null; 5172 Element get element => null;
5168 5173
5169 String toString() => 'AssertResult()'; 5174 String toString() => 'AssertResult()';
5170 } 5175 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/access_semantics.dart ('k') | pkg/compiler/lib/src/resolution/semantic_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698