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

Side by Side Diff: pkg/compiler/lib/src/resolution/send_resolver.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 dart2js.semantics_visitor; 5 part of dart2js.semantics_visitor;
6 6
7 enum SendStructureKind { 7 enum SendStructureKind {
8 GET, 8 GET,
9 SET, 9 SET,
10 INVOKE, 10 INVOKE,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 if (node.isOperator) { 219 if (node.isOperator) {
220 String operatorText = node.selector.asOperator().source; 220 String operatorText = node.selector.asOperator().source;
221 if (operatorText == 'is') { 221 if (operatorText == 'is') {
222 return internalError(node, "Unexpected is test."); 222 return internalError(node, "Unexpected is test.");
223 } else if (operatorText == 'as') { 223 } else if (operatorText == 'as') {
224 return internalError(node, "Unexpected as cast."); 224 return internalError(node, "Unexpected as cast.");
225 return new AsStructure(elements.getType(node.arguments.single)); 225 return new AsStructure(elements.getType(node.arguments.single));
226 } else if (operatorText == '&&') { 226 } else if (operatorText == '&&') {
227 return internalError(node, "Unexpected logical and."); 227 return internalError(node, "Unexpected logical and.");
228 return const LogicalAndStructure();
229 } else if (operatorText == '||') { 228 } else if (operatorText == '||') {
230 return internalError(node, "Unexpected logical or."); 229 return internalError(node, "Unexpected logical or.");
230 } else if (operatorText == '??') {
231 return internalError(node, "Unexpected if-null.");
231 } 232 }
232 } 233 }
233 234
234 SendStructureKind kind; 235 SendStructureKind kind;
235 236
236 if (node.asSendSet() != null) { 237 if (node.asSendSet() != null) {
237 SendSet sendSet = node.asSendSet(); 238 SendSet sendSet = node.asSendSet();
238 String operatorText = sendSet.assignmentOperator.source; 239 String operatorText = sendSet.assignmentOperator.source;
239 if (sendSet.isPrefix || sendSet.isPostfix) { 240 if (sendSet.isPrefix || sendSet.isPostfix) {
240 kind = sendSet.isPrefix 241 kind = sendSet.isPrefix
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 } 508 }
508 return new CompoundAccessSemantics(accessKind, getter, element); 509 return new CompoundAccessSemantics(accessKind, getter, element);
509 } 510 }
510 return new StaticAccess.superSetter(element); 511 return new StaticAccess.superSetter(element);
511 } else if (isCompound) { 512 } else if (isCompound) {
512 return new CompoundAccessSemantics( 513 return new CompoundAccessSemantics(
513 CompoundAccessKind.SUPER_GETTER_SETTER, getter, element); 514 CompoundAccessKind.SUPER_GETTER_SETTER, getter, element);
514 } else { 515 } else {
515 return new StaticAccess.superMethod(element); 516 return new StaticAccess.superMethod(element);
516 } 517 }
517 } else if (node.isOperator) { 518 } else if (node.isOperator || node.isConditional) {
519 // Conditional sends (e?.x) are treated as dynamic property reads because
520 // they are equivalent to do ((a) => a == null ? null : a.x)(e). If `e` is
521 // a type `A`, this is equivalent to write `(A).x`.
522 // TODO(johnniwinther): maybe add DynamicAccess.conditionalDynamicProperty
518 return new DynamicAccess.dynamicProperty(node.receiver); 523 return new DynamicAccess.dynamicProperty(node.receiver);
519 } else if (Elements.isClosureSend(node, element)) { 524 } else if (Elements.isClosureSend(node, element)) {
520 if (element == null) { 525 if (element == null) {
521 if (node.selector.isThis()) { 526 if (node.selector.isThis()) {
522 return new AccessSemantics.thisAccess(); 527 return new AccessSemantics.thisAccess();
523 } else { 528 } else {
524 return new AccessSemantics.expression(); 529 return new AccessSemantics.expression();
525 } 530 }
526 } else if (Elements.isErroneous(element)) { 531 } else if (Elements.isErroneous(element)) {
527 return new StaticAccess.unresolved(element); 532 return new StaticAccess.unresolved(element);
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 return internalError(node, "Unexpected variable $element."); 940 return internalError(node, "Unexpected variable $element.");
936 } 941 }
937 if (element.isConst) { 942 if (element.isConst) {
938 ConstantExpression constant = elements.getConstant(element.initializer); 943 ConstantExpression constant = elements.getConstant(element.initializer);
939 return new ConstantVariableStructure(kind, node, element, constant); 944 return new ConstantVariableStructure(kind, node, element, constant);
940 } else { 945 } else {
941 return new NonConstantVariableStructure(kind, node, element); 946 return new NonConstantVariableStructure(kind, node, element);
942 } 947 }
943 } 948 }
944 } 949 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart ('k') | pkg/compiler/lib/src/resolution/send_structure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698