| OLD | NEW |
| 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.resolution.send_structure; | 5 library dart2js.resolution.send_structure; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| 11 import '../resolution/tree_elements.dart' show TreeElements; | 11 import '../resolution/tree_elements.dart' show TreeElements; |
| 12 import '../tree/tree.dart'; | 12 import '../tree/tree.dart'; |
| 13 import '../universe/call_structure.dart' show CallStructure; | 13 import '../universe/call_structure.dart' show CallStructure; |
| 14 import '../universe/selector.dart' show Selector; | 14 import '../universe/selector.dart' show Selector; |
| 15 | 15 |
| 16 import 'access_semantics.dart'; | 16 import 'access_semantics.dart'; |
| 17 import 'operators.dart'; | 17 import 'operators.dart'; |
| 18 import 'semantic_visitor.dart'; | 18 import 'semantic_visitor.dart'; |
| 19 | 19 |
| 20 /// Interface for the structure of the semantics of a [Send] or [NewExpression] | 20 /// Interface for the structure of the semantics of a [Send] or [NewExpression] |
| 21 /// node. | 21 /// node. |
| 22 abstract class SemanticSendStructure<R, A> { | 22 abstract class SemanticSendStructure<R, A> { |
| 23 /// Calls the matching visit method on [visitor] with [node] and [arg]. | 23 /// Calls the matching visit method on [visitor] with [node] and [arg]. |
| 24 R dispatch(SemanticSendVisitor<R, A> visitor, Node node, A arg); | 24 R dispatch(SemanticSendVisitor<R, A> visitor, Node node, A arg); |
| 25 } | 25 } |
| 26 | 26 |
| 27 enum SendStructureKind { |
| 28 IF_NULL, |
| 29 LOGICAL_AND, |
| 30 LOGICAL_OR, |
| 31 IS, |
| 32 IS_NOT, |
| 33 AS, |
| 34 INVOKE, |
| 35 INCOMPATIBLE_INVOKE, |
| 36 GET, |
| 37 SET, |
| 38 NOT, |
| 39 UNARY, |
| 40 INVALID_UNARY, |
| 41 INDEX, |
| 42 EQUALS, |
| 43 NOT_EQUALS, |
| 44 BINARY, |
| 45 INVALID_BINARY, |
| 46 INDEX_SET, |
| 47 INDEX_PREFIX, |
| 48 INDEX_POSTFIX, |
| 49 COMPOUND, |
| 50 SET_IF_NULL, |
| 51 COMPOUND_INDEX_SET, |
| 52 INDEX_SET_IF_NULL, |
| 53 PREFIX, |
| 54 POSTFIX, |
| 55 DEFERRED_PREFIX, |
| 56 } |
| 57 |
| 27 /// Interface for the structure of the semantics of a [Send] node. | 58 /// Interface for the structure of the semantics of a [Send] node. |
| 28 /// | 59 /// |
| 29 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, | 60 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, |
| 30 /// `a.b`, `a.b(c)`, etc. | 61 /// `a.b`, `a.b(c)`, etc. |
| 31 abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> { | 62 abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> { |
| 32 /// Calls the matching visit method on [visitor] with [send] and [arg]. | 63 /// Calls the matching visit method on [visitor] with [send] and [arg]. |
| 33 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); | 64 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); |
| 65 |
| 66 SendStructureKind get kind; |
| 34 } | 67 } |
| 35 | 68 |
| 36 /// The structure for a [Send] of the form `a ?? b`. | 69 /// The structure for a [Send] of the form `a ?? b`. |
| 37 class IfNullStructure<R, A> implements SendStructure<R, A> { | 70 class IfNullStructure<R, A> implements SendStructure<R, A> { |
| 38 const IfNullStructure(); | 71 const IfNullStructure(); |
| 39 | 72 |
| 40 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 73 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 41 return visitor.visitIfNull(node, node.receiver, node.arguments.single, arg); | 74 return visitor.visitIfNull(node, node.receiver, node.arguments.single, arg); |
| 42 } | 75 } |
| 43 | 76 |
| 77 @override |
| 78 SendStructureKind get kind => SendStructureKind.IF_NULL; |
| 79 |
| 44 String toString() => '??'; | 80 String toString() => '??'; |
| 45 } | 81 } |
| 46 | 82 |
| 47 /// The structure for a [Send] of the form `a && b`. | 83 /// The structure for a [Send] of the form `a && b`. |
| 48 class LogicalAndStructure<R, A> implements SendStructure<R, A> { | 84 class LogicalAndStructure<R, A> implements SendStructure<R, A> { |
| 49 const LogicalAndStructure(); | 85 const LogicalAndStructure(); |
| 50 | 86 |
| 51 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 87 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 52 return visitor.visitLogicalAnd( | 88 return visitor.visitLogicalAnd( |
| 53 node, node.receiver, node.arguments.single, arg); | 89 node, node.receiver, node.arguments.single, arg); |
| 54 } | 90 } |
| 55 | 91 |
| 92 @override |
| 93 SendStructureKind get kind => SendStructureKind.LOGICAL_AND; |
| 94 |
| 56 String toString() => '&&'; | 95 String toString() => '&&'; |
| 57 } | 96 } |
| 58 | 97 |
| 59 /// The structure for a [Send] of the form `a || b`. | 98 /// The structure for a [Send] of the form `a || b`. |
| 60 class LogicalOrStructure<R, A> implements SendStructure<R, A> { | 99 class LogicalOrStructure<R, A> implements SendStructure<R, A> { |
| 61 const LogicalOrStructure(); | 100 const LogicalOrStructure(); |
| 62 | 101 |
| 63 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 102 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 64 return visitor.visitLogicalOr( | 103 return visitor.visitLogicalOr( |
| 65 node, node.receiver, node.arguments.single, arg); | 104 node, node.receiver, node.arguments.single, arg); |
| 66 } | 105 } |
| 67 | 106 |
| 107 @override |
| 108 SendStructureKind get kind => SendStructureKind.LOGICAL_OR; |
| 109 |
| 68 String toString() => '||'; | 110 String toString() => '||'; |
| 69 } | 111 } |
| 70 | 112 |
| 71 /// The structure for a [Send] of the form `a is T`. | 113 /// The structure for a [Send] of the form `a is T`. |
| 72 class IsStructure<R, A> implements SendStructure<R, A> { | 114 class IsStructure<R, A> implements SendStructure<R, A> { |
| 73 /// The type that the expression is tested against. | 115 /// The type that the expression is tested against. |
| 74 final DartType type; | 116 final DartType type; |
| 75 | 117 |
| 76 IsStructure(this.type); | 118 IsStructure(this.type); |
| 77 | 119 |
| 78 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 120 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 79 return visitor.visitIs(node, node.receiver, type, arg); | 121 return visitor.visitIs(node, node.receiver, type, arg); |
| 80 } | 122 } |
| 81 | 123 |
| 124 @override |
| 125 SendStructureKind get kind => SendStructureKind.IS; |
| 126 |
| 82 String toString() => 'is $type'; | 127 String toString() => 'is $type'; |
| 83 } | 128 } |
| 84 | 129 |
| 85 /// The structure for a [Send] of the form `a is! T`. | 130 /// The structure for a [Send] of the form `a is! T`. |
| 86 class IsNotStructure<R, A> implements SendStructure<R, A> { | 131 class IsNotStructure<R, A> implements SendStructure<R, A> { |
| 87 /// The type that the expression is tested against. | 132 /// The type that the expression is tested against. |
| 88 final DartType type; | 133 final DartType type; |
| 89 | 134 |
| 90 IsNotStructure(this.type); | 135 IsNotStructure(this.type); |
| 91 | 136 |
| 92 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 137 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 93 return visitor.visitIsNot(node, node.receiver, type, arg); | 138 return visitor.visitIsNot(node, node.receiver, type, arg); |
| 94 } | 139 } |
| 95 | 140 |
| 141 @override |
| 142 SendStructureKind get kind => SendStructureKind.IS_NOT; |
| 143 |
| 96 String toString() => 'is! $type'; | 144 String toString() => 'is! $type'; |
| 97 } | 145 } |
| 98 | 146 |
| 99 /// The structure for a [Send] of the form `a as T`. | 147 /// The structure for a [Send] of the form `a as T`. |
| 100 class AsStructure<R, A> implements SendStructure<R, A> { | 148 class AsStructure<R, A> implements SendStructure<R, A> { |
| 101 /// The type that the expression is cast to. | 149 /// The type that the expression is cast to. |
| 102 final DartType type; | 150 final DartType type; |
| 103 | 151 |
| 104 AsStructure(this.type); | 152 AsStructure(this.type); |
| 105 | 153 |
| 106 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 154 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 107 return visitor.visitAs(node, node.receiver, type, arg); | 155 return visitor.visitAs(node, node.receiver, type, arg); |
| 108 } | 156 } |
| 109 | 157 |
| 158 @override |
| 159 SendStructureKind get kind => SendStructureKind.AS; |
| 160 |
| 110 String toString() => 'as $type'; | 161 String toString() => 'as $type'; |
| 111 } | 162 } |
| 112 | 163 |
| 113 /// The structure for a [Send] that is an invocation. | 164 /// The structure for a [Send] that is an invocation. |
| 114 class InvokeStructure<R, A> implements SendStructure<R, A> { | 165 class InvokeStructure<R, A> implements SendStructure<R, A> { |
| 115 /// The target of the invocation. | 166 /// The target of the invocation. |
| 116 final AccessSemantics semantics; | 167 final AccessSemantics semantics; |
| 117 | 168 |
| 118 /// The [Selector] for the invocation. | 169 /// The [Selector] for the invocation. |
| 119 // TODO(johnniwinther): Store this only for dynamic invocations. | 170 // TODO(johnniwinther): Store this only for dynamic invocations. |
| 120 final Selector selector; | 171 final Selector selector; |
| 121 | 172 |
| 122 /// The [CallStructure] of the invocation. | 173 /// The [CallStructure] of the invocation. |
| 123 // TODO(johnniwinther): Store this directly for static invocations. | 174 // TODO(johnniwinther): Store this directly for static invocations. |
| 124 CallStructure get callStructure => selector.callStructure; | 175 CallStructure get callStructure => selector.callStructure; |
| 125 | 176 |
| 126 InvokeStructure(this.semantics, this.selector); | 177 InvokeStructure(this.semantics, this.selector); |
| 127 | 178 |
| 179 @override |
| 180 SendStructureKind get kind => SendStructureKind.INVOKE; |
| 181 |
| 128 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 182 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 129 switch (semantics.kind) { | 183 switch (semantics.kind) { |
| 130 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: | 184 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: |
| 131 return visitor.visitIfNotNullDynamicPropertyInvoke( | 185 return visitor.visitIfNotNullDynamicPropertyInvoke( |
| 132 node, node.receiver, node.argumentsNode, selector, arg); | 186 node, node.receiver, node.argumentsNode, selector, arg); |
| 133 case AccessKind.DYNAMIC_PROPERTY: | 187 case AccessKind.DYNAMIC_PROPERTY: |
| 134 return visitor.visitDynamicPropertyInvoke( | 188 return visitor.visitDynamicPropertyInvoke( |
| 135 node, node.receiver, node.argumentsNode, selector, arg); | 189 node, node.receiver, node.argumentsNode, selector, arg); |
| 136 case AccessKind.LOCAL_FUNCTION: | 190 case AccessKind.LOCAL_FUNCTION: |
| 137 return visitor.visitLocalFunctionInvoke( | 191 return visitor.visitLocalFunctionInvoke( |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 /// The [Selector] for the invocation. | 307 /// The [Selector] for the invocation. |
| 254 // TODO(johnniwinther): Store this only for dynamic invocations. | 308 // TODO(johnniwinther): Store this only for dynamic invocations. |
| 255 final Selector selector; | 309 final Selector selector; |
| 256 | 310 |
| 257 /// The [CallStructure] of the invocation. | 311 /// The [CallStructure] of the invocation. |
| 258 // TODO(johnniwinther): Store this directly for static invocations. | 312 // TODO(johnniwinther): Store this directly for static invocations. |
| 259 CallStructure get callStructure => selector.callStructure; | 313 CallStructure get callStructure => selector.callStructure; |
| 260 | 314 |
| 261 IncompatibleInvokeStructure(this.semantics, this.selector); | 315 IncompatibleInvokeStructure(this.semantics, this.selector); |
| 262 | 316 |
| 317 @override |
| 318 SendStructureKind get kind => SendStructureKind.INCOMPATIBLE_INVOKE; |
| 319 |
| 263 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 320 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 264 switch (semantics.kind) { | 321 switch (semantics.kind) { |
| 265 case AccessKind.STATIC_METHOD: | 322 case AccessKind.STATIC_METHOD: |
| 266 return visitor.visitStaticFunctionIncompatibleInvoke( | 323 return visitor.visitStaticFunctionIncompatibleInvoke( |
| 267 node, semantics.element, node.argumentsNode, callStructure, arg); | 324 node, semantics.element, node.argumentsNode, callStructure, arg); |
| 268 case AccessKind.SUPER_METHOD: | 325 case AccessKind.SUPER_METHOD: |
| 269 return visitor.visitSuperMethodIncompatibleInvoke( | 326 return visitor.visitSuperMethodIncompatibleInvoke( |
| 270 node, semantics.element, node.argumentsNode, callStructure, arg); | 327 node, semantics.element, node.argumentsNode, callStructure, arg); |
| 271 case AccessKind.TOPLEVEL_METHOD: | 328 case AccessKind.TOPLEVEL_METHOD: |
| 272 return visitor.visitTopLevelFunctionIncompatibleInvoke( | 329 return visitor.visitTopLevelFunctionIncompatibleInvoke( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 285 String toString() => 'incompatible-invoke($selector, $semantics)'; | 342 String toString() => 'incompatible-invoke($selector, $semantics)'; |
| 286 } | 343 } |
| 287 | 344 |
| 288 /// The structure for a [Send] that is a read access. | 345 /// The structure for a [Send] that is a read access. |
| 289 class GetStructure<R, A> implements SendStructure<R, A> { | 346 class GetStructure<R, A> implements SendStructure<R, A> { |
| 290 /// The target of the read access. | 347 /// The target of the read access. |
| 291 final AccessSemantics semantics; | 348 final AccessSemantics semantics; |
| 292 | 349 |
| 293 GetStructure(this.semantics); | 350 GetStructure(this.semantics); |
| 294 | 351 |
| 352 @override |
| 353 SendStructureKind get kind => SendStructureKind.GET; |
| 354 |
| 295 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 355 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 296 switch (semantics.kind) { | 356 switch (semantics.kind) { |
| 297 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: | 357 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: |
| 298 return visitor.visitIfNotNullDynamicPropertyGet( | 358 return visitor.visitIfNotNullDynamicPropertyGet( |
| 299 node, node.receiver, semantics.name, arg); | 359 node, node.receiver, semantics.name, arg); |
| 300 case AccessKind.DYNAMIC_PROPERTY: | 360 case AccessKind.DYNAMIC_PROPERTY: |
| 301 return visitor.visitDynamicPropertyGet( | 361 return visitor.visitDynamicPropertyGet( |
| 302 node, node.receiver, semantics.name, arg); | 362 node, node.receiver, semantics.name, arg); |
| 303 case AccessKind.LOCAL_FUNCTION: | 363 case AccessKind.LOCAL_FUNCTION: |
| 304 return visitor.visitLocalFunctionGet(node, semantics.element, arg); | 364 return visitor.visitLocalFunctionGet(node, semantics.element, arg); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 String toString() => 'get($semantics)'; | 432 String toString() => 'get($semantics)'; |
| 373 } | 433 } |
| 374 | 434 |
| 375 /// The structure for a [Send] that is an assignment. | 435 /// The structure for a [Send] that is an assignment. |
| 376 class SetStructure<R, A> implements SendStructure<R, A> { | 436 class SetStructure<R, A> implements SendStructure<R, A> { |
| 377 /// The target of the assignment. | 437 /// The target of the assignment. |
| 378 final AccessSemantics semantics; | 438 final AccessSemantics semantics; |
| 379 | 439 |
| 380 SetStructure(this.semantics); | 440 SetStructure(this.semantics); |
| 381 | 441 |
| 442 @override |
| 443 SendStructureKind get kind => SendStructureKind.SET; |
| 444 |
| 382 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 445 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 383 switch (semantics.kind) { | 446 switch (semantics.kind) { |
| 384 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: | 447 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: |
| 385 return visitor.visitIfNotNullDynamicPropertySet( | 448 return visitor.visitIfNotNullDynamicPropertySet( |
| 386 node, node.receiver, semantics.name, node.arguments.single, arg); | 449 node, node.receiver, semantics.name, node.arguments.single, arg); |
| 387 case AccessKind.DYNAMIC_PROPERTY: | 450 case AccessKind.DYNAMIC_PROPERTY: |
| 388 return visitor.visitDynamicPropertySet( | 451 return visitor.visitDynamicPropertySet( |
| 389 node, node.receiver, semantics.name, node.arguments.single, arg); | 452 node, node.receiver, semantics.name, node.arguments.single, arg); |
| 390 case AccessKind.LOCAL_FUNCTION: | 453 case AccessKind.LOCAL_FUNCTION: |
| 391 return visitor.visitLocalFunctionSet( | 454 return visitor.visitLocalFunctionSet( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 554 } |
| 492 | 555 |
| 493 /// The structure for a [Send] that is a negation, i.e. of the form `!e`. | 556 /// The structure for a [Send] that is a negation, i.e. of the form `!e`. |
| 494 class NotStructure<R, A> implements SendStructure<R, A> { | 557 class NotStructure<R, A> implements SendStructure<R, A> { |
| 495 const NotStructure(); | 558 const NotStructure(); |
| 496 | 559 |
| 497 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 560 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 498 return visitor.visitNot(node, node.receiver, arg); | 561 return visitor.visitNot(node, node.receiver, arg); |
| 499 } | 562 } |
| 500 | 563 |
| 564 @override |
| 565 SendStructureKind get kind => SendStructureKind.NOT; |
| 566 |
| 501 String toString() => 'not()'; | 567 String toString() => 'not()'; |
| 502 } | 568 } |
| 503 | 569 |
| 504 /// The structure for a [Send] that is an invocation of a user definable unary | 570 /// The structure for a [Send] that is an invocation of a user definable unary |
| 505 /// operator. | 571 /// operator. |
| 506 class UnaryStructure<R, A> implements SendStructure<R, A> { | 572 class UnaryStructure<R, A> implements SendStructure<R, A> { |
| 507 /// The target of the unary operation. | 573 /// The target of the unary operation. |
| 508 final AccessSemantics semantics; | 574 final AccessSemantics semantics; |
| 509 | 575 |
| 510 /// The user definable unary operator. | 576 /// The user definable unary operator. |
| 511 final UnaryOperator operator; | 577 final UnaryOperator operator; |
| 512 | 578 |
| 513 UnaryStructure(this.semantics, this.operator); | 579 UnaryStructure(this.semantics, this.operator); |
| 514 | 580 |
| 581 @override |
| 582 SendStructureKind get kind => SendStructureKind.UNARY; |
| 583 |
| 515 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 584 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 516 switch (semantics.kind) { | 585 switch (semantics.kind) { |
| 517 case AccessKind.EXPRESSION: | 586 case AccessKind.EXPRESSION: |
| 518 return visitor.visitUnary(node, operator, node.receiver, arg); | 587 return visitor.visitUnary(node, operator, node.receiver, arg); |
| 519 case AccessKind.SUPER_METHOD: | 588 case AccessKind.SUPER_METHOD: |
| 520 return visitor.visitSuperUnary(node, operator, semantics.element, arg); | 589 return visitor.visitSuperUnary(node, operator, semantics.element, arg); |
| 521 case AccessKind.UNRESOLVED_SUPER: | 590 case AccessKind.UNRESOLVED_SUPER: |
| 522 return visitor.visitUnresolvedSuperUnary( | 591 return visitor.visitUnresolvedSuperUnary( |
| 523 node, operator, semantics.element, arg); | 592 node, operator, semantics.element, arg); |
| 524 case AccessKind.INVALID: | 593 case AccessKind.INVALID: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 538 /// operator. | 607 /// operator. |
| 539 class InvalidUnaryStructure<R, A> implements SendStructure<R, A> { | 608 class InvalidUnaryStructure<R, A> implements SendStructure<R, A> { |
| 540 const InvalidUnaryStructure(); | 609 const InvalidUnaryStructure(); |
| 541 | 610 |
| 542 @override | 611 @override |
| 543 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 612 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 544 return visitor.errorUndefinedUnaryExpression( | 613 return visitor.errorUndefinedUnaryExpression( |
| 545 node, node.selector, node.receiver, arg); | 614 node, node.selector, node.receiver, arg); |
| 546 } | 615 } |
| 547 | 616 |
| 617 @override |
| 618 SendStructureKind get kind => SendStructureKind.INVALID_UNARY; |
| 619 |
| 548 String toString() => 'invalid unary'; | 620 String toString() => 'invalid unary'; |
| 549 } | 621 } |
| 550 | 622 |
| 551 /// The structure for a [Send] that is an index expression, i.e. of the form | 623 /// The structure for a [Send] that is an index expression, i.e. of the form |
| 552 /// `a[b]`. | 624 /// `a[b]`. |
| 553 class IndexStructure<R, A> implements SendStructure<R, A> { | 625 class IndexStructure<R, A> implements SendStructure<R, A> { |
| 554 /// The target of the left operand. | 626 /// The target of the left operand. |
| 555 final AccessSemantics semantics; | 627 final AccessSemantics semantics; |
| 556 | 628 |
| 557 IndexStructure(this.semantics); | 629 IndexStructure(this.semantics); |
| 558 | 630 |
| 631 @override |
| 632 SendStructureKind get kind => SendStructureKind.INDEX; |
| 633 |
| 559 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 634 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 560 switch (semantics.kind) { | 635 switch (semantics.kind) { |
| 561 case AccessKind.EXPRESSION: | 636 case AccessKind.EXPRESSION: |
| 562 return visitor.visitIndex( | 637 return visitor.visitIndex( |
| 563 node, node.receiver, node.arguments.single, arg); | 638 node, node.receiver, node.arguments.single, arg); |
| 564 case AccessKind.SUPER_METHOD: | 639 case AccessKind.SUPER_METHOD: |
| 565 return visitor.visitSuperIndex( | 640 return visitor.visitSuperIndex( |
| 566 node, semantics.element, node.arguments.single, arg); | 641 node, semantics.element, node.arguments.single, arg); |
| 567 case AccessKind.UNRESOLVED_SUPER: | 642 case AccessKind.UNRESOLVED_SUPER: |
| 568 return visitor.visitUnresolvedSuperIndex( | 643 return visitor.visitUnresolvedSuperIndex( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 579 } | 654 } |
| 580 | 655 |
| 581 /// The structure for a [Send] that is an equals test, i.e. of the form | 656 /// The structure for a [Send] that is an equals test, i.e. of the form |
| 582 /// `a == b`. | 657 /// `a == b`. |
| 583 class EqualsStructure<R, A> implements SendStructure<R, A> { | 658 class EqualsStructure<R, A> implements SendStructure<R, A> { |
| 584 /// The target of the left operand. | 659 /// The target of the left operand. |
| 585 final AccessSemantics semantics; | 660 final AccessSemantics semantics; |
| 586 | 661 |
| 587 EqualsStructure(this.semantics); | 662 EqualsStructure(this.semantics); |
| 588 | 663 |
| 664 @override |
| 665 SendStructureKind get kind => SendStructureKind.EQUALS; |
| 666 |
| 589 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 667 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 590 switch (semantics.kind) { | 668 switch (semantics.kind) { |
| 591 case AccessKind.EXPRESSION: | 669 case AccessKind.EXPRESSION: |
| 592 return visitor.visitEquals( | 670 return visitor.visitEquals( |
| 593 node, node.receiver, node.arguments.single, arg); | 671 node, node.receiver, node.arguments.single, arg); |
| 594 case AccessKind.SUPER_METHOD: | 672 case AccessKind.SUPER_METHOD: |
| 595 return visitor.visitSuperEquals( | 673 return visitor.visitSuperEquals( |
| 596 node, semantics.element, node.arguments.single, arg); | 674 node, semantics.element, node.arguments.single, arg); |
| 597 case AccessKind.INVALID: | 675 case AccessKind.INVALID: |
| 598 return visitor.errorInvalidEquals( | 676 return visitor.errorInvalidEquals( |
| 599 node, semantics.element, node.arguments.single, arg); | 677 node, semantics.element, node.arguments.single, arg); |
| 600 default: | 678 default: |
| 601 // This is not a valid case. | 679 // This is not a valid case. |
| 602 break; | 680 break; |
| 603 } | 681 } |
| 604 throw new SpannableAssertionFailure(node, "Invalid equals: ${semantics}"); | 682 throw new SpannableAssertionFailure(node, "Invalid equals: ${semantics}"); |
| 605 } | 683 } |
| 606 | 684 |
| 607 String toString() => '==($semantics)'; | 685 String toString() => '==($semantics)'; |
| 608 } | 686 } |
| 609 | 687 |
| 610 /// The structure for a [Send] that is a not-equals test, i.e. of the form | 688 /// The structure for a [Send] that is a not-equals test, i.e. of the form |
| 611 /// `a != b`. | 689 /// `a != b`. |
| 612 class NotEqualsStructure<R, A> implements SendStructure<R, A> { | 690 class NotEqualsStructure<R, A> implements SendStructure<R, A> { |
| 613 /// The target of the left operand. | 691 /// The target of the left operand. |
| 614 final AccessSemantics semantics; | 692 final AccessSemantics semantics; |
| 615 | 693 |
| 616 NotEqualsStructure(this.semantics); | 694 NotEqualsStructure(this.semantics); |
| 617 | 695 |
| 696 @override |
| 697 SendStructureKind get kind => SendStructureKind.NOT_EQUALS; |
| 698 |
| 618 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 699 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 619 switch (semantics.kind) { | 700 switch (semantics.kind) { |
| 620 case AccessKind.EXPRESSION: | 701 case AccessKind.EXPRESSION: |
| 621 return visitor.visitNotEquals( | 702 return visitor.visitNotEquals( |
| 622 node, node.receiver, node.arguments.single, arg); | 703 node, node.receiver, node.arguments.single, arg); |
| 623 case AccessKind.SUPER_METHOD: | 704 case AccessKind.SUPER_METHOD: |
| 624 return visitor.visitSuperNotEquals( | 705 return visitor.visitSuperNotEquals( |
| 625 node, semantics.element, node.arguments.single, arg); | 706 node, semantics.element, node.arguments.single, arg); |
| 626 case AccessKind.INVALID: | 707 case AccessKind.INVALID: |
| 627 return visitor.errorInvalidNotEquals( | 708 return visitor.errorInvalidNotEquals( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 641 /// operator. | 722 /// operator. |
| 642 class BinaryStructure<R, A> implements SendStructure<R, A> { | 723 class BinaryStructure<R, A> implements SendStructure<R, A> { |
| 643 /// The target of the left operand. | 724 /// The target of the left operand. |
| 644 final AccessSemantics semantics; | 725 final AccessSemantics semantics; |
| 645 | 726 |
| 646 /// The user definable binary operator. | 727 /// The user definable binary operator. |
| 647 final BinaryOperator operator; | 728 final BinaryOperator operator; |
| 648 | 729 |
| 649 BinaryStructure(this.semantics, this.operator); | 730 BinaryStructure(this.semantics, this.operator); |
| 650 | 731 |
| 732 @override |
| 733 SendStructureKind get kind => SendStructureKind.BINARY; |
| 734 |
| 651 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 735 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 652 switch (semantics.kind) { | 736 switch (semantics.kind) { |
| 653 case AccessKind.EXPRESSION: | 737 case AccessKind.EXPRESSION: |
| 654 return visitor.visitBinary( | 738 return visitor.visitBinary( |
| 655 node, node.receiver, operator, node.arguments.single, arg); | 739 node, node.receiver, operator, node.arguments.single, arg); |
| 656 case AccessKind.SUPER_METHOD: | 740 case AccessKind.SUPER_METHOD: |
| 657 return visitor.visitSuperBinary( | 741 return visitor.visitSuperBinary( |
| 658 node, semantics.element, operator, node.arguments.single, arg); | 742 node, semantics.element, operator, node.arguments.single, arg); |
| 659 case AccessKind.UNRESOLVED_SUPER: | 743 case AccessKind.UNRESOLVED_SUPER: |
| 660 return visitor.visitUnresolvedSuperBinary( | 744 return visitor.visitUnresolvedSuperBinary( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 676 /// operator. | 760 /// operator. |
| 677 class InvalidBinaryStructure<R, A> implements SendStructure<R, A> { | 761 class InvalidBinaryStructure<R, A> implements SendStructure<R, A> { |
| 678 const InvalidBinaryStructure(); | 762 const InvalidBinaryStructure(); |
| 679 | 763 |
| 680 @override | 764 @override |
| 681 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 765 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 682 return visitor.errorUndefinedBinaryExpression( | 766 return visitor.errorUndefinedBinaryExpression( |
| 683 node, node.receiver, node.selector, node.arguments.single, arg); | 767 node, node.receiver, node.selector, node.arguments.single, arg); |
| 684 } | 768 } |
| 685 | 769 |
| 770 @override |
| 771 SendStructureKind get kind => SendStructureKind.INVALID_BINARY; |
| 772 |
| 686 String toString() => 'invalid binary'; | 773 String toString() => 'invalid binary'; |
| 687 } | 774 } |
| 688 | 775 |
| 689 /// The structure for a [Send] that is of the form `a[b] = c`. | 776 /// The structure for a [Send] that is of the form `a[b] = c`. |
| 690 class IndexSetStructure<R, A> implements SendStructure<R, A> { | 777 class IndexSetStructure<R, A> implements SendStructure<R, A> { |
| 691 /// The target of the index set operation. | 778 /// The target of the index set operation. |
| 692 final AccessSemantics semantics; | 779 final AccessSemantics semantics; |
| 693 | 780 |
| 694 IndexSetStructure(this.semantics); | 781 IndexSetStructure(this.semantics); |
| 695 | 782 |
| 783 @override |
| 784 SendStructureKind get kind => SendStructureKind.INDEX_SET; |
| 785 |
| 696 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 786 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 697 switch (semantics.kind) { | 787 switch (semantics.kind) { |
| 698 case AccessKind.EXPRESSION: | 788 case AccessKind.EXPRESSION: |
| 699 return visitor.visitIndexSet(node, node.receiver, node.arguments.first, | 789 return visitor.visitIndexSet(node, node.receiver, node.arguments.first, |
| 700 node.arguments.tail.head, arg); | 790 node.arguments.tail.head, arg); |
| 701 case AccessKind.SUPER_METHOD: | 791 case AccessKind.SUPER_METHOD: |
| 702 return visitor.visitSuperIndexSet(node, semantics.element, | 792 return visitor.visitSuperIndexSet(node, semantics.element, |
| 703 node.arguments.first, node.arguments.tail.head, arg); | 793 node.arguments.first, node.arguments.tail.head, arg); |
| 704 case AccessKind.UNRESOLVED_SUPER: | 794 case AccessKind.UNRESOLVED_SUPER: |
| 705 case AccessKind.UNRESOLVED: | 795 case AccessKind.UNRESOLVED: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 723 /// expression, i.e. of the form `--a[b]`. | 813 /// expression, i.e. of the form `--a[b]`. |
| 724 class IndexPrefixStructure<R, A> implements SendStructure<R, A> { | 814 class IndexPrefixStructure<R, A> implements SendStructure<R, A> { |
| 725 /// The target of the left operand. | 815 /// The target of the left operand. |
| 726 final AccessSemantics semantics; | 816 final AccessSemantics semantics; |
| 727 | 817 |
| 728 /// The `++` or `--` operator used in the operation. | 818 /// The `++` or `--` operator used in the operation. |
| 729 final IncDecOperator operator; | 819 final IncDecOperator operator; |
| 730 | 820 |
| 731 IndexPrefixStructure(this.semantics, this.operator); | 821 IndexPrefixStructure(this.semantics, this.operator); |
| 732 | 822 |
| 823 @override |
| 824 SendStructureKind get kind => SendStructureKind.INDEX_PREFIX; |
| 825 |
| 733 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 826 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 734 switch (semantics.kind) { | 827 switch (semantics.kind) { |
| 735 case AccessKind.EXPRESSION: | 828 case AccessKind.EXPRESSION: |
| 736 return visitor.visitIndexPrefix( | 829 return visitor.visitIndexPrefix( |
| 737 node, node.receiver, node.arguments.single, operator, arg); | 830 node, node.receiver, node.arguments.single, operator, arg); |
| 738 case AccessKind.UNRESOLVED_SUPER: | 831 case AccessKind.UNRESOLVED_SUPER: |
| 739 return visitor.visitUnresolvedSuperIndexPrefix( | 832 return visitor.visitUnresolvedSuperIndexPrefix( |
| 740 node, semantics.element, node.arguments.single, operator, arg); | 833 node, semantics.element, node.arguments.single, operator, arg); |
| 741 case AccessKind.INVALID: | 834 case AccessKind.INVALID: |
| 742 return visitor.errorInvalidIndexPrefix( | 835 return visitor.errorInvalidIndexPrefix( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 /// expression, i.e. of the form `a[b]++`. | 874 /// expression, i.e. of the form `a[b]++`. |
| 782 class IndexPostfixStructure<R, A> implements SendStructure<R, A> { | 875 class IndexPostfixStructure<R, A> implements SendStructure<R, A> { |
| 783 /// The target of the left operand. | 876 /// The target of the left operand. |
| 784 final AccessSemantics semantics; | 877 final AccessSemantics semantics; |
| 785 | 878 |
| 786 /// The `++` or `--` operator used in the operation. | 879 /// The `++` or `--` operator used in the operation. |
| 787 final IncDecOperator operator; | 880 final IncDecOperator operator; |
| 788 | 881 |
| 789 IndexPostfixStructure(this.semantics, this.operator); | 882 IndexPostfixStructure(this.semantics, this.operator); |
| 790 | 883 |
| 884 @override |
| 885 SendStructureKind get kind => SendStructureKind.INDEX_POSTFIX; |
| 886 |
| 791 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 887 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 792 switch (semantics.kind) { | 888 switch (semantics.kind) { |
| 793 case AccessKind.EXPRESSION: | 889 case AccessKind.EXPRESSION: |
| 794 return visitor.visitIndexPostfix( | 890 return visitor.visitIndexPostfix( |
| 795 node, node.receiver, node.arguments.single, operator, arg); | 891 node, node.receiver, node.arguments.single, operator, arg); |
| 796 case AccessKind.UNRESOLVED_SUPER: | 892 case AccessKind.UNRESOLVED_SUPER: |
| 797 return visitor.visitUnresolvedSuperIndexPostfix( | 893 return visitor.visitUnresolvedSuperIndexPostfix( |
| 798 node, semantics.element, node.arguments.single, operator, arg); | 894 node, semantics.element, node.arguments.single, operator, arg); |
| 799 case AccessKind.INVALID: | 895 case AccessKind.INVALID: |
| 800 return visitor.errorInvalidIndexPostfix( | 896 return visitor.errorInvalidIndexPostfix( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 /// `a += b`. | 940 /// `a += b`. |
| 845 class CompoundStructure<R, A> implements SendStructure<R, A> { | 941 class CompoundStructure<R, A> implements SendStructure<R, A> { |
| 846 /// The target of the compound assignment, i.e. the left-hand side. | 942 /// The target of the compound assignment, i.e. the left-hand side. |
| 847 final AccessSemantics semantics; | 943 final AccessSemantics semantics; |
| 848 | 944 |
| 849 /// The assignment operator used in the compound assignment. | 945 /// The assignment operator used in the compound assignment. |
| 850 final AssignmentOperator operator; | 946 final AssignmentOperator operator; |
| 851 | 947 |
| 852 CompoundStructure(this.semantics, this.operator); | 948 CompoundStructure(this.semantics, this.operator); |
| 853 | 949 |
| 950 @override |
| 951 SendStructureKind get kind => SendStructureKind.COMPOUND; |
| 952 |
| 854 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 953 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 855 switch (semantics.kind) { | 954 switch (semantics.kind) { |
| 856 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: | 955 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: |
| 857 return visitor.visitIfNotNullDynamicPropertyCompound( | 956 return visitor.visitIfNotNullDynamicPropertyCompound( |
| 858 node, | 957 node, |
| 859 node.receiver, | 958 node.receiver, |
| 860 semantics.name, | 959 semantics.name, |
| 861 operator, | 960 operator, |
| 862 node.arguments.single, | 961 node.arguments.single, |
| 863 arg); | 962 arg); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 } | 1190 } |
| 1092 | 1191 |
| 1093 /// The structure for a [Send] that is an if-null assignment. For instance | 1192 /// The structure for a [Send] that is an if-null assignment. For instance |
| 1094 /// `a ??= b`. | 1193 /// `a ??= b`. |
| 1095 class SetIfNullStructure<R, A> implements SendStructure<R, A> { | 1194 class SetIfNullStructure<R, A> implements SendStructure<R, A> { |
| 1096 /// The target of the if-null assignment, i.e. the left-hand side. | 1195 /// The target of the if-null assignment, i.e. the left-hand side. |
| 1097 final AccessSemantics semantics; | 1196 final AccessSemantics semantics; |
| 1098 | 1197 |
| 1099 SetIfNullStructure(this.semantics); | 1198 SetIfNullStructure(this.semantics); |
| 1100 | 1199 |
| 1200 @override |
| 1201 SendStructureKind get kind => SendStructureKind.SET_IF_NULL; |
| 1202 |
| 1101 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1203 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1102 switch (semantics.kind) { | 1204 switch (semantics.kind) { |
| 1103 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: | 1205 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: |
| 1104 return visitor.visitIfNotNullDynamicPropertySetIfNull( | 1206 return visitor.visitIfNotNullDynamicPropertySetIfNull( |
| 1105 node, node.receiver, semantics.name, node.arguments.single, arg); | 1207 node, node.receiver, semantics.name, node.arguments.single, arg); |
| 1106 case AccessKind.DYNAMIC_PROPERTY: | 1208 case AccessKind.DYNAMIC_PROPERTY: |
| 1107 return visitor.visitDynamicPropertySetIfNull( | 1209 return visitor.visitDynamicPropertySetIfNull( |
| 1108 node, node.receiver, semantics.name, node.arguments.single, arg); | 1210 node, node.receiver, semantics.name, node.arguments.single, arg); |
| 1109 case AccessKind.LOCAL_FUNCTION: | 1211 case AccessKind.LOCAL_FUNCTION: |
| 1110 return visitor.visitLocalFunctionSetIfNull( | 1212 return visitor.visitLocalFunctionSetIfNull( |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 /// operator. For instance `a[b] += c`. | 1423 /// operator. For instance `a[b] += c`. |
| 1322 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> { | 1424 class CompoundIndexSetStructure<R, A> implements SendStructure<R, A> { |
| 1323 /// The target of the index operations. | 1425 /// The target of the index operations. |
| 1324 final AccessSemantics semantics; | 1426 final AccessSemantics semantics; |
| 1325 | 1427 |
| 1326 /// The assignment operator used in the compound assignment. | 1428 /// The assignment operator used in the compound assignment. |
| 1327 final AssignmentOperator operator; | 1429 final AssignmentOperator operator; |
| 1328 | 1430 |
| 1329 CompoundIndexSetStructure(this.semantics, this.operator); | 1431 CompoundIndexSetStructure(this.semantics, this.operator); |
| 1330 | 1432 |
| 1433 @override |
| 1434 SendStructureKind get kind => SendStructureKind.COMPOUND_INDEX_SET; |
| 1435 |
| 1331 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1436 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1332 switch (semantics.kind) { | 1437 switch (semantics.kind) { |
| 1333 case AccessKind.EXPRESSION: | 1438 case AccessKind.EXPRESSION: |
| 1334 return visitor.visitCompoundIndexSet(node, node.receiver, | 1439 return visitor.visitCompoundIndexSet(node, node.receiver, |
| 1335 node.arguments.first, operator, node.arguments.tail.head, arg); | 1440 node.arguments.first, operator, node.arguments.tail.head, arg); |
| 1336 case AccessKind.UNRESOLVED_SUPER: | 1441 case AccessKind.UNRESOLVED_SUPER: |
| 1337 return visitor.visitUnresolvedSuperCompoundIndexSet( | 1442 return visitor.visitUnresolvedSuperCompoundIndexSet( |
| 1338 node, | 1443 node, |
| 1339 semantics.element, | 1444 semantics.element, |
| 1340 node.arguments.first, | 1445 node.arguments.first, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 } | 1496 } |
| 1392 | 1497 |
| 1393 /// The structure for a [Send] that is a if-null assignment on the index | 1498 /// The structure for a [Send] that is a if-null assignment on the index |
| 1394 /// operator. For instance `a[b] ??= c`. | 1499 /// operator. For instance `a[b] ??= c`. |
| 1395 class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> { | 1500 class IndexSetIfNullStructure<R, A> implements SendStructure<R, A> { |
| 1396 /// The target of the index operations. | 1501 /// The target of the index operations. |
| 1397 final AccessSemantics semantics; | 1502 final AccessSemantics semantics; |
| 1398 | 1503 |
| 1399 IndexSetIfNullStructure(this.semantics); | 1504 IndexSetIfNullStructure(this.semantics); |
| 1400 | 1505 |
| 1506 @override |
| 1507 SendStructureKind get kind => SendStructureKind.INDEX_SET; |
| 1508 |
| 1401 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1509 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1402 switch (semantics.kind) { | 1510 switch (semantics.kind) { |
| 1403 case AccessKind.EXPRESSION: | 1511 case AccessKind.EXPRESSION: |
| 1404 return visitor.visitIndexSetIfNull(node, node.receiver, | 1512 return visitor.visitIndexSetIfNull(node, node.receiver, |
| 1405 node.arguments.first, node.arguments.tail.head, arg); | 1513 node.arguments.first, node.arguments.tail.head, arg); |
| 1406 case AccessKind.UNRESOLVED_SUPER: | 1514 case AccessKind.UNRESOLVED_SUPER: |
| 1407 return visitor.visitUnresolvedSuperIndexSetIfNull( | 1515 return visitor.visitUnresolvedSuperIndexSetIfNull( |
| 1408 node, | 1516 node, |
| 1409 semantics.element, | 1517 semantics.element, |
| 1410 node.arguments.first, | 1518 node.arguments.first, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 /// `++a`. | 1568 /// `++a`. |
| 1461 class PrefixStructure<R, A> implements SendStructure<R, A> { | 1569 class PrefixStructure<R, A> implements SendStructure<R, A> { |
| 1462 /// The target of the prefix operation. | 1570 /// The target of the prefix operation. |
| 1463 final AccessSemantics semantics; | 1571 final AccessSemantics semantics; |
| 1464 | 1572 |
| 1465 /// The `++` or `--` operator used in the operation. | 1573 /// The `++` or `--` operator used in the operation. |
| 1466 final IncDecOperator operator; | 1574 final IncDecOperator operator; |
| 1467 | 1575 |
| 1468 PrefixStructure(this.semantics, this.operator); | 1576 PrefixStructure(this.semantics, this.operator); |
| 1469 | 1577 |
| 1578 @override |
| 1579 SendStructureKind get kind => SendStructureKind.PREFIX; |
| 1580 |
| 1470 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1581 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1471 switch (semantics.kind) { | 1582 switch (semantics.kind) { |
| 1472 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: | 1583 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: |
| 1473 return visitor.visitIfNotNullDynamicPropertyPrefix( | 1584 return visitor.visitIfNotNullDynamicPropertyPrefix( |
| 1474 node, node.receiver, semantics.name, operator, arg); | 1585 node, node.receiver, semantics.name, operator, arg); |
| 1475 case AccessKind.DYNAMIC_PROPERTY: | 1586 case AccessKind.DYNAMIC_PROPERTY: |
| 1476 return visitor.visitDynamicPropertyPrefix( | 1587 return visitor.visitDynamicPropertyPrefix( |
| 1477 node, node.receiver, semantics.name, operator, arg); | 1588 node, node.receiver, semantics.name, operator, arg); |
| 1478 case AccessKind.LOCAL_FUNCTION: | 1589 case AccessKind.LOCAL_FUNCTION: |
| 1479 return visitor.visitLocalFunctionPrefix( | 1590 return visitor.visitLocalFunctionPrefix( |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 /// `a++`. | 1807 /// `a++`. |
| 1697 class PostfixStructure<R, A> implements SendStructure<R, A> { | 1808 class PostfixStructure<R, A> implements SendStructure<R, A> { |
| 1698 /// The target of the postfix operation. | 1809 /// The target of the postfix operation. |
| 1699 final AccessSemantics semantics; | 1810 final AccessSemantics semantics; |
| 1700 | 1811 |
| 1701 /// The `++` or `--` operator used in the operation. | 1812 /// The `++` or `--` operator used in the operation. |
| 1702 final IncDecOperator operator; | 1813 final IncDecOperator operator; |
| 1703 | 1814 |
| 1704 PostfixStructure(this.semantics, this.operator); | 1815 PostfixStructure(this.semantics, this.operator); |
| 1705 | 1816 |
| 1817 @override |
| 1818 SendStructureKind get kind => SendStructureKind.POSTFIX; |
| 1819 |
| 1706 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 1820 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 1707 switch (semantics.kind) { | 1821 switch (semantics.kind) { |
| 1708 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: | 1822 case AccessKind.CONDITIONAL_DYNAMIC_PROPERTY: |
| 1709 return visitor.visitIfNotNullDynamicPropertyPostfix( | 1823 return visitor.visitIfNotNullDynamicPropertyPostfix( |
| 1710 node, node.receiver, semantics.name, operator, arg); | 1824 node, node.receiver, semantics.name, operator, arg); |
| 1711 case AccessKind.DYNAMIC_PROPERTY: | 1825 case AccessKind.DYNAMIC_PROPERTY: |
| 1712 return visitor.visitDynamicPropertyPostfix( | 1826 return visitor.visitDynamicPropertyPostfix( |
| 1713 node, node.receiver, semantics.name, operator, arg); | 1827 node, node.receiver, semantics.name, operator, arg); |
| 1714 case AccessKind.LOCAL_FUNCTION: | 1828 case AccessKind.LOCAL_FUNCTION: |
| 1715 return visitor.visitLocalFunctionPostfix( | 1829 return visitor.visitLocalFunctionPostfix( |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 /// The send structure for the whole [Send] node. For instance a | 2044 /// The send structure for the whole [Send] node. For instance a |
| 1931 /// [GetStructure] for `deferred.a` where `a` is a top level member of the | 2045 /// [GetStructure] for `deferred.a` where `a` is a top level member of the |
| 1932 /// deferred library. | 2046 /// deferred library. |
| 1933 final SendStructure sendStructure; | 2047 final SendStructure sendStructure; |
| 1934 | 2048 |
| 1935 DeferredPrefixStructure(this.prefix, this.sendStructure) { | 2049 DeferredPrefixStructure(this.prefix, this.sendStructure) { |
| 1936 assert(sendStructure != null); | 2050 assert(sendStructure != null); |
| 1937 } | 2051 } |
| 1938 | 2052 |
| 1939 @override | 2053 @override |
| 2054 SendStructureKind get kind => SendStructureKind.DEFERRED_PREFIX; |
| 2055 |
| 2056 @override |
| 1940 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg) { | 2057 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg) { |
| 1941 visitor.previsitDeferredAccess(send, prefix, arg); | 2058 visitor.previsitDeferredAccess(send, prefix, arg); |
| 1942 return sendStructure.dispatch(visitor, send, arg); | 2059 return sendStructure.dispatch(visitor, send, arg); |
| 1943 } | 2060 } |
| 1944 } | 2061 } |
| 1945 | 2062 |
| 2063 enum NewStructureKind { NEW_INVOKE, CONST_INVOKE, LATE_CONST, } |
| 2064 |
| 1946 /// The structure for a [NewExpression] of a new invocation. | 2065 /// The structure for a [NewExpression] of a new invocation. |
| 1947 abstract class NewStructure<R, A> implements SemanticSendStructure<R, A> { | 2066 abstract class NewStructure<R, A> implements SemanticSendStructure<R, A> { |
| 1948 /// Calls the matching visit method on [visitor] with [node] and [arg]. | 2067 /// Calls the matching visit method on [visitor] with [node] and [arg]. |
| 1949 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg); | 2068 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg); |
| 2069 |
| 2070 NewStructureKind get kind; |
| 1950 } | 2071 } |
| 1951 | 2072 |
| 1952 /// The structure for a [NewExpression] of a new invocation. For instance | 2073 /// The structure for a [NewExpression] of a new invocation. For instance |
| 1953 /// `new C()`. | 2074 /// `new C()`. |
| 1954 class NewInvokeStructure<R, A> extends NewStructure<R, A> { | 2075 class NewInvokeStructure<R, A> extends NewStructure<R, A> { |
| 1955 final ConstructorAccessSemantics semantics; | 2076 final ConstructorAccessSemantics semantics; |
| 1956 final Selector selector; | 2077 final Selector selector; |
| 1957 | 2078 |
| 1958 NewInvokeStructure(this.semantics, this.selector); | 2079 NewInvokeStructure(this.semantics, this.selector); |
| 1959 | 2080 |
| 2081 @override |
| 2082 NewStructureKind get kind => NewStructureKind.NEW_INVOKE; |
| 2083 |
| 1960 CallStructure get callStructure => selector.callStructure; | 2084 CallStructure get callStructure => selector.callStructure; |
| 1961 | 2085 |
| 1962 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { | 2086 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { |
| 1963 switch (semantics.kind) { | 2087 switch (semantics.kind) { |
| 1964 case ConstructorAccessKind.GENERATIVE: | 2088 case ConstructorAccessKind.GENERATIVE: |
| 1965 ConstructorElement constructor = semantics.element; | 2089 ConstructorElement constructor = semantics.element; |
| 1966 if (constructor.isRedirectingGenerative) { | 2090 if (constructor.isRedirectingGenerative) { |
| 1967 return visitor.visitRedirectingGenerativeConstructorInvoke( | 2091 return visitor.visitRedirectingGenerativeConstructorInvoke( |
| 1968 node, | 2092 node, |
| 1969 constructor, | 2093 constructor, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 enum ConstantInvokeKind { | 2186 enum ConstantInvokeKind { |
| 2063 CONSTRUCTED, | 2187 CONSTRUCTED, |
| 2064 BOOL_FROM_ENVIRONMENT, | 2188 BOOL_FROM_ENVIRONMENT, |
| 2065 INT_FROM_ENVIRONMENT, | 2189 INT_FROM_ENVIRONMENT, |
| 2066 STRING_FROM_ENVIRONMENT, | 2190 STRING_FROM_ENVIRONMENT, |
| 2067 } | 2191 } |
| 2068 | 2192 |
| 2069 /// The structure for a [NewExpression] of a constant invocation. For instance | 2193 /// The structure for a [NewExpression] of a constant invocation. For instance |
| 2070 /// `const C()`. | 2194 /// `const C()`. |
| 2071 class ConstInvokeStructure<R, A> extends NewStructure<R, A> { | 2195 class ConstInvokeStructure<R, A> extends NewStructure<R, A> { |
| 2072 final ConstantInvokeKind kind; | 2196 final ConstantInvokeKind constantInvokeKind; |
| 2073 final ConstantExpression constant; | 2197 final ConstantExpression constant; |
| 2074 | 2198 |
| 2075 ConstInvokeStructure(this.kind, this.constant); | 2199 ConstInvokeStructure(this.constantInvokeKind, this.constant); |
| 2200 |
| 2201 @override |
| 2202 NewStructureKind get kind => NewStructureKind.CONST_INVOKE; |
| 2076 | 2203 |
| 2077 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { | 2204 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { |
| 2078 switch (kind) { | 2205 switch (constantInvokeKind) { |
| 2079 case ConstantInvokeKind.CONSTRUCTED: | 2206 case ConstantInvokeKind.CONSTRUCTED: |
| 2080 return visitor.visitConstConstructorInvoke(node, constant, arg); | 2207 return visitor.visitConstConstructorInvoke(node, constant, arg); |
| 2081 case ConstantInvokeKind.BOOL_FROM_ENVIRONMENT: | 2208 case ConstantInvokeKind.BOOL_FROM_ENVIRONMENT: |
| 2082 return visitor.visitBoolFromEnvironmentConstructorInvoke( | 2209 return visitor.visitBoolFromEnvironmentConstructorInvoke( |
| 2083 node, constant, arg); | 2210 node, constant, arg); |
| 2084 case ConstantInvokeKind.INT_FROM_ENVIRONMENT: | 2211 case ConstantInvokeKind.INT_FROM_ENVIRONMENT: |
| 2085 return visitor.visitIntFromEnvironmentConstructorInvoke( | 2212 return visitor.visitIntFromEnvironmentConstructorInvoke( |
| 2086 node, constant, arg); | 2213 node, constant, arg); |
| 2087 case ConstantInvokeKind.STRING_FROM_ENVIRONMENT: | 2214 case ConstantInvokeKind.STRING_FROM_ENVIRONMENT: |
| 2088 return visitor.visitStringFromEnvironmentConstructorInvoke( | 2215 return visitor.visitStringFromEnvironmentConstructorInvoke( |
| 2089 node, constant, arg); | 2216 node, constant, arg); |
| 2090 } | 2217 } |
| 2091 } | 2218 } |
| 2092 } | 2219 } |
| 2093 | 2220 |
| 2094 /// A constant constructor invocation that couldn't be determined fully during | 2221 /// A constant constructor invocation that couldn't be determined fully during |
| 2095 /// resolution. | 2222 /// resolution. |
| 2096 // TODO(johnniwinther): Remove this when all constants are computed during | 2223 // TODO(johnniwinther): Remove this when all constants are computed during |
| 2097 // resolution. | 2224 // resolution. |
| 2098 class LateConstInvokeStructure<R, A> extends NewStructure<R, A> { | 2225 class LateConstInvokeStructure<R, A> extends NewStructure<R, A> { |
| 2099 final TreeElements elements; | 2226 final TreeElements elements; |
| 2100 | 2227 |
| 2101 LateConstInvokeStructure(this.elements); | 2228 LateConstInvokeStructure(this.elements); |
| 2102 | 2229 |
| 2230 @override |
| 2231 NewStructureKind get kind => NewStructureKind.LATE_CONST; |
| 2232 |
| 2103 /// Convert this new structure into a regular new structure using the data | 2233 /// Convert this new structure into a regular new structure using the data |
| 2104 /// available in [elements]. | 2234 /// available in [elements]. |
| 2105 NewStructure resolve(NewExpression node) { | 2235 NewStructure resolve(NewExpression node) { |
| 2106 Element element = elements[node.send]; | 2236 Element element = elements[node.send]; |
| 2107 Selector selector = elements.getSelector(node.send); | 2237 Selector selector = elements.getSelector(node.send); |
| 2108 DartType type = elements.getType(node); | 2238 DartType type = elements.getType(node); |
| 2109 ConstantExpression constant = elements.getConstant(node); | 2239 ConstantExpression constant = elements.getConstant(node); |
| 2110 if (element.isMalformed || | 2240 if (element.isMalformed || |
| 2111 constant == null || | 2241 constant == null || |
| 2112 constant.kind == ConstantExpressionKind.ERRONEOUS) { | 2242 constant.kind == ConstantExpressionKind.ERRONEOUS) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2380 ThisConstructorInvokeStructure( | 2510 ThisConstructorInvokeStructure( |
| 2381 this.node, this.constructor, this.callStructure); | 2511 this.node, this.constructor, this.callStructure); |
| 2382 | 2512 |
| 2383 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { | 2513 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { |
| 2384 return visitor.visitThisConstructorInvoke( | 2514 return visitor.visitThisConstructorInvoke( |
| 2385 node, constructor, node.argumentsNode, callStructure, arg); | 2515 node, constructor, node.argumentsNode, callStructure, arg); |
| 2386 } | 2516 } |
| 2387 | 2517 |
| 2388 bool get isConstructorInvoke => true; | 2518 bool get isConstructorInvoke => true; |
| 2389 } | 2519 } |
| OLD | NEW |