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

Side by Side Diff: pkg/compiler/lib/src/resolution/send_structure.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 library dart2js.send_structure; 5 library dart2js.send_structure;
6 6
7 import 'access_semantics.dart'; 7 import 'access_semantics.dart';
8 import 'operators.dart'; 8 import 'operators.dart';
9 import 'semantic_visitor.dart'; 9 import 'semantic_visitor.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 52 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
53 return visitor.errorInvalidAssert( 53 return visitor.errorInvalidAssert(
54 node, 54 node,
55 node.argumentsNode, 55 node.argumentsNode,
56 arg); 56 arg);
57 } 57 }
58 58
59 String toString() => 'invalid assert'; 59 String toString() => 'invalid assert';
60 } 60 }
61 61
62 /// The structure for a [Send] of the form `a ?? b`.
63 class IfNullStructure<R, A> implements SendStructure<R, A> {
64 const IfNullStructure();
65
66 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
67 return visitor.visitIfNull(
68 node,
69 node.receiver,
70 node.arguments.single,
71 arg);
72 }
73
74 String toString() => '??';
75 }
76
62 /// The structure for a [Send] of the form `a && b`. 77 /// The structure for a [Send] of the form `a && b`.
63 class LogicalAndStructure<R, A> implements SendStructure<R, A> { 78 class LogicalAndStructure<R, A> implements SendStructure<R, A> {
64 const LogicalAndStructure(); 79 const LogicalAndStructure();
65 80
66 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 81 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
67 return visitor.visitLogicalAnd( 82 return visitor.visitLogicalAnd(
68 node, 83 node,
69 node.receiver, 84 node.receiver,
70 node.arguments.single, 85 node.arguments.single,
71 arg); 86 arg);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 169
155 /// The [CallStructure] of the invocation. 170 /// The [CallStructure] of the invocation.
156 // TODO(johnniwinther): Store this directly for static invocations. 171 // TODO(johnniwinther): Store this directly for static invocations.
157 CallStructure get callStructure => selector.callStructure; 172 CallStructure get callStructure => selector.callStructure;
158 173
159 InvokeStructure(this.semantics, this.selector); 174 InvokeStructure(this.semantics, this.selector);
160 175
161 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 176 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
162 switch (semantics.kind) { 177 switch (semantics.kind) {
163 case AccessKind.DYNAMIC_PROPERTY: 178 case AccessKind.DYNAMIC_PROPERTY:
179 if (node.isConditional) {
180 return visitor.visitIfNotNullDynamicPropertyInvoke(
181 node,
182 node.receiver,
183 node.argumentsNode,
184 selector,
185 arg);
186 }
164 return visitor.visitDynamicPropertyInvoke( 187 return visitor.visitDynamicPropertyInvoke(
165 node, 188 node,
166 node.receiver, 189 node.receiver,
167 node.argumentsNode, 190 node.argumentsNode,
168 selector, 191 selector,
169 arg); 192 arg);
170 case AccessKind.LOCAL_FUNCTION: 193 case AccessKind.LOCAL_FUNCTION:
171 return visitor.visitLocalFunctionInvoke( 194 return visitor.visitLocalFunctionInvoke(
172 node, 195 node,
173 semantics.element, 196 semantics.element,
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 final AccessSemantics semantics; 440 final AccessSemantics semantics;
418 441
419 /// The [Selector] for the getter invocation. 442 /// The [Selector] for the getter invocation.
420 final Selector selector; 443 final Selector selector;
421 444
422 GetStructure(this.semantics, this.selector); 445 GetStructure(this.semantics, this.selector);
423 446
424 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 447 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
425 switch (semantics.kind) { 448 switch (semantics.kind) {
426 case AccessKind.DYNAMIC_PROPERTY: 449 case AccessKind.DYNAMIC_PROPERTY:
450 if (node.isConditional) {
451 return visitor.visitIfNotNullDynamicPropertyGet(
452 node,
453 node.receiver,
454 selector,
455 arg);
456 }
427 return visitor.visitDynamicPropertyGet( 457 return visitor.visitDynamicPropertyGet(
428 node, 458 node,
429 node.receiver, 459 node.receiver,
430 selector, 460 selector,
431 arg); 461 arg);
432 case AccessKind.LOCAL_FUNCTION: 462 case AccessKind.LOCAL_FUNCTION:
433 return visitor.visitLocalFunctionGet( 463 return visitor.visitLocalFunctionGet(
434 node, 464 node,
435 semantics.element, 465 semantics.element,
436 arg); 466 arg);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 final AccessSemantics semantics; 601 final AccessSemantics semantics;
572 602
573 /// The [Selector] for the setter invocation. 603 /// The [Selector] for the setter invocation.
574 final Selector selector; 604 final Selector selector;
575 605
576 SetStructure(this.semantics, this.selector); 606 SetStructure(this.semantics, this.selector);
577 607
578 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 608 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
579 switch (semantics.kind) { 609 switch (semantics.kind) {
580 case AccessKind.DYNAMIC_PROPERTY: 610 case AccessKind.DYNAMIC_PROPERTY:
581 return visitor.visitDynamicPropertySet( 611 if (node.isConditional) {
612 return visitor.visitIfNotNullDynamicPropertySet(
582 node, 613 node,
583 node.receiver, 614 node.receiver,
584 selector, 615 selector,
585 node.arguments.single, 616 node.arguments.single,
586 arg); 617 arg);
618 }
619 return visitor.visitDynamicPropertySet(
620 node,
621 node.receiver,
622 selector,
623 node.arguments.single,
624 arg);
587 case AccessKind.LOCAL_FUNCTION: 625 case AccessKind.LOCAL_FUNCTION:
588 return visitor.visitLocalFunctionSet( 626 return visitor.visitLocalFunctionSet(
589 node, 627 node,
590 semantics.element, 628 semantics.element,
591 node.arguments.single, 629 node.arguments.single,
592 arg); 630 arg);
593 case AccessKind.LOCAL_VARIABLE: 631 case AccessKind.LOCAL_VARIABLE:
594 return visitor.visitLocalVariableSet( 632 return visitor.visitLocalVariableSet(
595 node, 633 node,
596 semantics.element, 634 semantics.element,
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 final Selector setterSelector; 1288 final Selector setterSelector;
1251 1289
1252 CompoundStructure(this.semantics, 1290 CompoundStructure(this.semantics,
1253 this.operator, 1291 this.operator,
1254 this.getterSelector, 1292 this.getterSelector,
1255 this.setterSelector); 1293 this.setterSelector);
1256 1294
1257 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 1295 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1258 switch (semantics.kind) { 1296 switch (semantics.kind) {
1259 case AccessKind.DYNAMIC_PROPERTY: 1297 case AccessKind.DYNAMIC_PROPERTY:
1298 if (node.isConditional) {
1299 return visitor.visitIfNotNullDynamicPropertyCompound(
1300 node,
1301 node.receiver,
1302 operator,
1303 node.arguments.single,
1304 getterSelector,
1305 setterSelector,
1306 arg);
1307 }
1260 return visitor.visitDynamicPropertyCompound( 1308 return visitor.visitDynamicPropertyCompound(
1261 node, 1309 node,
1262 node.receiver, 1310 node.receiver,
1263 operator, 1311 operator,
1264 node.arguments.single, 1312 node.arguments.single,
1265 getterSelector, 1313 getterSelector,
1266 setterSelector, 1314 setterSelector,
1267 arg); 1315 arg);
1268 case AccessKind.LOCAL_FUNCTION: 1316 case AccessKind.LOCAL_FUNCTION:
1269 return visitor.visitLocalFunctionCompound( 1317 return visitor.visitLocalFunctionCompound(
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 final Selector setterSelector; 1715 final Selector setterSelector;
1668 1716
1669 PrefixStructure(this.semantics, 1717 PrefixStructure(this.semantics,
1670 this.operator, 1718 this.operator,
1671 this.getterSelector, 1719 this.getterSelector,
1672 this.setterSelector); 1720 this.setterSelector);
1673 1721
1674 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 1722 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1675 switch (semantics.kind) { 1723 switch (semantics.kind) {
1676 case AccessKind.DYNAMIC_PROPERTY: 1724 case AccessKind.DYNAMIC_PROPERTY:
1725 if (node.isConditional) {
1726 return visitor.visitIfNotNullDynamicPropertyPrefix(
1727 node,
1728 node.receiver,
1729 operator,
1730 getterSelector,
1731 setterSelector,
1732 arg);
1733 }
1677 return visitor.visitDynamicPropertyPrefix( 1734 return visitor.visitDynamicPropertyPrefix(
1678 node, 1735 node,
1679 node.receiver, 1736 node.receiver,
1680 operator, 1737 operator,
1681 getterSelector, 1738 getterSelector,
1682 setterSelector, 1739 setterSelector,
1683 arg); 1740 arg);
1684 case AccessKind.LOCAL_FUNCTION: 1741 case AccessKind.LOCAL_FUNCTION:
1685 return visitor.visitLocalFunctionPrefix( 1742 return visitor.visitLocalFunctionPrefix(
1686 node, 1743 node,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 final Selector setterSelector; 2032 final Selector setterSelector;
1976 2033
1977 PostfixStructure(this.semantics, 2034 PostfixStructure(this.semantics,
1978 this.operator, 2035 this.operator,
1979 this.getterSelector, 2036 this.getterSelector,
1980 this.setterSelector); 2037 this.setterSelector);
1981 2038
1982 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { 2039 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) {
1983 switch (semantics.kind) { 2040 switch (semantics.kind) {
1984 case AccessKind.DYNAMIC_PROPERTY: 2041 case AccessKind.DYNAMIC_PROPERTY:
2042 if (node.isConditional) {
2043 return visitor.visitIfNotNullDynamicPropertyPostfix(
2044 node,
2045 node.receiver,
2046 operator,
2047 getterSelector,
2048 setterSelector,
2049 arg);
2050 }
1985 return visitor.visitDynamicPropertyPostfix( 2051 return visitor.visitDynamicPropertyPostfix(
1986 node, 2052 node,
1987 node.receiver, 2053 node.receiver,
1988 operator, 2054 operator,
1989 getterSelector, 2055 getterSelector,
1990 setterSelector, 2056 setterSelector,
1991 arg); 2057 arg);
1992 case AccessKind.LOCAL_FUNCTION: 2058 case AccessKind.LOCAL_FUNCTION:
1993 return visitor.visitLocalFunctionPostfix( 2059 return visitor.visitLocalFunctionPostfix(
1994 node, 2060 node,
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2530 final ConstructorElement constructor; 2596 final ConstructorElement constructor;
2531 final Selector selector; 2597 final Selector selector;
2532 2598
2533 ThisConstructorInvokeStructure(this.constructor, this.selector); 2599 ThisConstructorInvokeStructure(this.constructor, this.selector);
2534 2600
2535 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) { 2601 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) {
2536 return visitor.visitThisConstructorInvoke( 2602 return visitor.visitThisConstructorInvoke(
2537 node, constructor, node.argumentsNode, selector, arg); 2603 node, constructor, node.argumentsNode, selector, arg);
2538 } 2604 }
2539 } 2605 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | pkg/compiler/lib/src/resolved_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698