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

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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 elements.getType(node.arguments.single.asSend().receiver)); 217 elements.getType(node.arguments.single.asSend().receiver));
218 } else { 218 } else {
219 return new IsStructure(elements.getType(node.arguments.single)); 219 return new IsStructure(elements.getType(node.arguments.single));
220 } 220 }
221 } else if (operatorText == 'as') { 221 } else if (operatorText == 'as') {
222 return new AsStructure(elements.getType(node.arguments.single)); 222 return new AsStructure(elements.getType(node.arguments.single));
223 } else if (operatorText == '&&') { 223 } else if (operatorText == '&&') {
224 return const LogicalAndStructure(); 224 return const LogicalAndStructure();
225 } else if (operatorText == '||') { 225 } else if (operatorText == '||') {
226 return const LogicalOrStructure(); 226 return const LogicalOrStructure();
227 } else if (operatorText == '??') {
228 return const IfNullStructure();
227 } 229 }
228 } 230 }
229 231
230 SendStructureKind kind; 232 SendStructureKind kind;
231 233
232 if (node.asSendSet() != null) { 234 if (node.asSendSet() != null) {
233 SendSet sendSet = node.asSendSet(); 235 SendSet sendSet = node.asSendSet();
234 String operatorText = sendSet.assignmentOperator.source; 236 String operatorText = sendSet.assignmentOperator.source;
235 if (sendSet.isPrefix || sendSet.isPostfix) { 237 if (sendSet.isPrefix || sendSet.isPostfix) {
236 kind = sendSet.isPrefix 238 kind = sendSet.isPrefix
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 505 }
504 return new CompoundAccessSemantics(accessKind, getter, element); 506 return new CompoundAccessSemantics(accessKind, getter, element);
505 } 507 }
506 return new StaticAccess.superSetter(element); 508 return new StaticAccess.superSetter(element);
507 } else if (isCompound) { 509 } else if (isCompound) {
508 return new CompoundAccessSemantics( 510 return new CompoundAccessSemantics(
509 CompoundAccessKind.SUPER_GETTER_SETTER, getter, element); 511 CompoundAccessKind.SUPER_GETTER_SETTER, getter, element);
510 } else { 512 } else {
511 return new StaticAccess.superMethod(element); 513 return new StaticAccess.superMethod(element);
512 } 514 }
513 } else if (node.isOperator) { 515 } else if (node.isOperator || node.isConditional) {
516 // Conditional sends (e?.x) are treated as dynamic property reads because
517 // they are equivalent to do ((a) => a == null ? null : a.x)(e). If `e` is
518 // a type `A`, this is equivalent to write `(A).x`.
514 return new DynamicAccess.dynamicProperty(node.receiver); 519 return new DynamicAccess.dynamicProperty(node.receiver);
Johnni Winther 2015/05/22 12:39:49 Add a TODO for me to maybe add a DynamicAccess.con
Siggi Cherem (dart-lang) 2015/05/22 19:49:54 Done.
515 } else if (Elements.isClosureSend(node, element)) { 520 } else if (Elements.isClosureSend(node, element)) {
516 if (element == null) { 521 if (element == null) {
517 if (node.selector.isThis()) { 522 if (node.selector.isThis()) {
518 return new AccessSemantics.thisAccess(); 523 return new AccessSemantics.thisAccess();
519 } else { 524 } else {
520 return new AccessSemantics.expression(); 525 return new AccessSemantics.expression();
521 } 526 }
522 } else if (Elements.isErroneous(element)) { 527 } else if (Elements.isErroneous(element)) {
523 return new StaticAccess.unresolved(element); 528 return new StaticAccess.unresolved(element);
524 } else { 529 } else {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 return internalError(node, "Unexpected variable $element."); 936 return internalError(node, "Unexpected variable $element.");
932 } 937 }
933 if (element.isConst) { 938 if (element.isConst) {
934 ConstantExpression constant = elements.getConstant(element.initializer); 939 ConstantExpression constant = elements.getConstant(element.initializer);
935 return new ConstantVariableStructure(kind, node, element, constant); 940 return new ConstantVariableStructure(kind, node, element, constant);
936 } else { 941 } else {
937 return new NonConstantVariableStructure(kind, node, element); 942 return new NonConstantVariableStructure(kind, node, element);
938 } 943 }
939 } 944 }
940 } 945 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698