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

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

Issue 1151163004: Implementation of null-aware operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
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 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 } 2590 }
2591 registry.registerAssert(node); 2591 registry.registerAssert(node);
2592 return const AssertResult(); 2592 return const AssertResult();
2593 } 2593 }
2594 2594
2595 return node.selector.accept(this); 2595 return node.selector.accept(this);
2596 } 2596 }
2597 2597
2598 var oldCategory = allowedCategory; 2598 var oldCategory = allowedCategory;
2599 allowedCategory |= ElementCategory.PREFIX | ElementCategory.SUPER; 2599 allowedCategory |= ElementCategory.PREFIX | ElementCategory.SUPER;
2600
2601 bool oldSendIsMemberAccess = sendIsMemberAccess;
2602 int oldAllowedCategory = allowedCategory;
2603
2604 // Conditional sends like `e?.foo` treat the receiver as an expression. So
2605 // `C?.foo` needs to be treated like `(C).foo`, not like C.foo. Prefixes and
2606 // super are not allowed on their own in that context.
2607 if (node.isConditional) {
2608 sendIsMemberAccess = false;
2609 allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION
2610 | ElementCategory.IMPLIES_TYPE;
Johnni Winther 2015/05/22 12:39:49 Format like this: allowedCategory = ElementCa
Siggi Cherem (dart-lang) 2015/05/22 19:49:54 Done.
2611 }
2600 ResolutionResult resolvedReceiver = visit(node.receiver); 2612 ResolutionResult resolvedReceiver = visit(node.receiver);
2613 if (node.isConditional) {
2614 sendIsMemberAccess = oldSendIsMemberAccess;
2615 allowedCategory = oldAllowedCategory;
2616 }
2617
2601 allowedCategory = oldCategory; 2618 allowedCategory = oldCategory;
2602 2619
2603 Element target; 2620 Element target;
2604 String name = node.selector.asIdentifier().source; 2621 String name = node.selector.asIdentifier().source;
2605 if (identical(name, 'this')) { 2622 if (identical(name, 'this')) {
2606 // TODO(ahe): Why is this using GENERIC? 2623 // TODO(ahe): Why is this using GENERIC?
2607 error(node.selector, MessageKind.GENERIC, 2624 error(node.selector, MessageKind.GENERIC,
2608 {'text': "expected an identifier"}); 2625 {'text': "expected an identifier"});
2609 return null; 2626 return null;
2610 } else if (node.isSuperCall) { 2627 } else if (node.isSuperCall) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
3022 MessageKind.CANNOT_RESOLVE_SETTER, const {}); 3039 MessageKind.CANNOT_RESOLVE_SETTER, const {});
3023 registry.registerThrowNoSuchMethod(); 3040 registry.registerThrowNoSuchMethod();
3024 } 3041 }
3025 } 3042 }
3026 if (isComplex && getter == null && !inInstanceContext) { 3043 if (isComplex && getter == null && !inInstanceContext) {
3027 getter = reportAndCreateErroneousElement(node.selector, field.name, 3044 getter = reportAndCreateErroneousElement(node.selector, field.name,
3028 MessageKind.CANNOT_RESOLVE_GETTER, const {}); 3045 MessageKind.CANNOT_RESOLVE_GETTER, const {});
3029 registry.registerThrowNoSuchMethod(); 3046 registry.registerThrowNoSuchMethod();
3030 } 3047 }
3031 } else if (target.impliesType) { 3048 } else if (target.impliesType) {
3032 setter = reportAndCreateErroneousElement(node.selector, target.name, 3049 if (node.isIfNullAssignment) {
3033 MessageKind.ASSIGNING_TYPE, const {}); 3050 setter = reportAndCreateErroneousElement(node.selector, target.name,
3034 registry.registerThrowNoSuchMethod(); 3051 MessageKind.IF_NULL_ASSIGNING_TYPE, const {});
3052 // In this case, no assignment happens, the rest of the compiler can
3053 // treat the expression `C ??= e` as if it's just reading `C`.
3054 } else {
3055 setter = reportAndCreateErroneousElement(node.selector, target.name,
3056 MessageKind.ASSIGNING_TYPE, const {});
3057 registry.registerThrowNoSuchMethod();
3058 }
3035 registerTypeLiteralAccess(node, target); 3059 registerTypeLiteralAccess(node, target);
Siggi Cherem (dart-lang) 2015/05/22 03:50:49 funny thing that you just added this - I was doing
3036 } else if (target.isFinal || target.isConst) { 3060 } else if (target.isFinal || target.isConst) {
3037 if (Elements.isStaticOrTopLevelField(target) || target.isLocal) { 3061 if (Elements.isStaticOrTopLevelField(target) || target.isLocal) {
3038 setter = reportAndCreateErroneousElement( 3062 setter = reportAndCreateErroneousElement(
3039 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER, 3063 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER,
3040 const {}); 3064 const {});
3041 } else if (node.isSuperCall) { 3065 } else if (node.isSuperCall) {
3042 setter = reportAndCreateErroneousElement( 3066 setter = reportAndCreateErroneousElement(
3043 node.selector, target.name, MessageKind.SETTER_NOT_FOUND_IN_SUPER, 3067 node.selector, target.name, MessageKind.SETTER_NOT_FOUND_IN_SUPER,
3044 {'name': target.name, 'className': currentClass.name}); 3068 {'name': target.name, 'className': currentClass.name});
3045 registry.registerSuperNoSuchMethod(); 3069 registry.registerSuperNoSuchMethod();
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
5170 } 5194 }
5171 5195
5172 /// The result for the resolution of the `assert` method. 5196 /// The result for the resolution of the `assert` method.
5173 class AssertResult implements ResolutionResult { 5197 class AssertResult implements ResolutionResult {
5174 const AssertResult(); 5198 const AssertResult();
5175 5199
5176 Element get element => null; 5200 Element get element => null;
5177 5201
5178 String toString() => 'AssertResult()'; 5202 String toString() => 'AssertResult()';
5179 } 5203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698