OLD | NEW |
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 import 'dart:collection' show IterableMixin; | 5 import 'dart:collection' show IterableMixin; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../elements/elements.dart' show MetadataAnnotation; | 8 import '../elements/elements.dart' show MetadataAnnotation; |
9 import '../resolution/secret_tree_element.dart' | 9 import '../resolution/secret_tree_element.dart' |
10 show NullTreeElementMixin, StoredTreeElementMixin; | 10 show NullTreeElementMixin, StoredTreeElementMixin; |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 * A message send aka method invocation. In Dart, most operations can | 586 * A message send aka method invocation. In Dart, most operations can |
587 * (and should) be considered as message sends. Getters and setters | 587 * (and should) be considered as message sends. Getters and setters |
588 * are just methods with a special syntax. Consequently, we model | 588 * are just methods with a special syntax. Consequently, we model |
589 * property access, assignment, operators, and method calls with this | 589 * property access, assignment, operators, and method calls with this |
590 * one node. | 590 * one node. |
591 */ | 591 */ |
592 class Send extends Expression with StoredTreeElementMixin { | 592 class Send extends Expression with StoredTreeElementMixin { |
593 final Node receiver; | 593 final Node receiver; |
594 final Node selector; | 594 final Node selector; |
595 final NodeList argumentsNode; | 595 final NodeList argumentsNode; |
| 596 final NodeList typeArgumentsNode; |
596 | 597 |
597 /// Whether this is a conditional send of the form `a?.b`. | 598 /// Whether this is a conditional send of the form `a?.b`. |
598 final bool isConditional; | 599 final bool isConditional; |
599 | 600 |
600 Link<Node> get arguments => argumentsNode.nodes; | 601 Link<Node> get arguments => argumentsNode.nodes; |
601 | 602 |
602 Send( | 603 Send( |
603 [this.receiver, | 604 [this.receiver, |
604 this.selector, | 605 this.selector, |
605 this.argumentsNode, | 606 this.argumentsNode, |
| 607 this.typeArgumentsNode, |
606 this.isConditional = false]); | 608 this.isConditional = false]); |
607 Send.postfix(this.receiver, this.selector, | 609 Send.postfix(this.receiver, this.selector, |
608 [Node argument = null, this.isConditional = false]) | 610 [Node argument = null, this.isConditional = false]) |
609 : argumentsNode = (argument == null) | 611 : argumentsNode = (argument == null) |
610 ? new Postfix() | 612 ? new Postfix() |
611 : new Postfix.singleton(argument); | 613 : new Postfix.singleton(argument), |
| 614 typeArgumentsNode = null; |
612 Send.prefix(this.receiver, this.selector, | 615 Send.prefix(this.receiver, this.selector, |
613 [Node argument = null, this.isConditional = false]) | 616 [Node argument = null, this.isConditional = false]) |
614 : argumentsNode = | 617 : argumentsNode = |
615 (argument == null) ? new Prefix() : new Prefix.singleton(argument); | 618 (argument == null) ? new Prefix() : new Prefix.singleton(argument), |
| 619 typeArgumentsNode = null; |
616 | 620 |
617 Send asSend() => this; | 621 Send asSend() => this; |
618 | 622 |
619 accept(Visitor visitor) => visitor.visitSend(this); | 623 accept(Visitor visitor) => visitor.visitSend(this); |
620 | 624 |
621 accept1(Visitor1 visitor, arg) => visitor.visitSend(this, arg); | 625 accept1(Visitor1 visitor, arg) => visitor.visitSend(this, arg); |
622 | 626 |
623 visitChildren(Visitor visitor) { | 627 visitChildren(Visitor visitor) { |
624 if (receiver != null) receiver.accept(visitor); | 628 if (receiver != null) receiver.accept(visitor); |
625 if (selector != null) selector.accept(visitor); | 629 if (selector != null) selector.accept(visitor); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 if (!isPostfix && argumentsNode != null) { | 692 if (!isPostfix && argumentsNode != null) { |
689 Token token = argumentsNode.getEndToken(); | 693 Token token = argumentsNode.getEndToken(); |
690 if (token != null) return token; | 694 if (token != null) return token; |
691 } | 695 } |
692 if (selector != null) return selector.getEndToken(); | 696 if (selector != null) return selector.getEndToken(); |
693 return getBeginToken(); | 697 return getBeginToken(); |
694 } | 698 } |
695 | 699 |
696 Send copyWithReceiver(Node newReceiver, bool isConditional) { | 700 Send copyWithReceiver(Node newReceiver, bool isConditional) { |
697 assert(receiver == null); | 701 assert(receiver == null); |
698 return new Send(newReceiver, selector, argumentsNode, isConditional); | 702 return new Send( |
| 703 newReceiver, selector, argumentsNode, typeArgumentsNode, isConditional); |
699 } | 704 } |
700 } | 705 } |
701 | 706 |
702 class Postfix extends NodeList { | 707 class Postfix extends NodeList { |
703 Postfix() : super(null, const Link<Node>()); | 708 Postfix() : super(null, const Link<Node>()); |
704 Postfix.singleton(Node argument) : super.singleton(argument); | 709 Postfix.singleton(Node argument) : super.singleton(argument); |
705 } | 710 } |
706 | 711 |
707 class Prefix extends NodeList { | 712 class Prefix extends NodeList { |
708 Prefix() : super(null, const Link<Node>()); | 713 Prefix() : super(null, const Link<Node>()); |
709 Prefix.singleton(Node argument) : super.singleton(argument); | 714 Prefix.singleton(Node argument) : super.singleton(argument); |
710 } | 715 } |
711 | 716 |
712 class SendSet extends Send { | 717 class SendSet extends Send { |
713 final Operator assignmentOperator; | 718 final Operator assignmentOperator; |
714 SendSet(receiver, selector, this.assignmentOperator, argumentsNode, | 719 SendSet(receiver, selector, this.assignmentOperator, argumentsNode, |
715 [bool isConditional = false]) | 720 [bool isConditional = false]) |
716 : super(receiver, selector, argumentsNode, isConditional); | 721 : super(receiver, selector, argumentsNode, null, isConditional); |
717 SendSet.postfix(receiver, selector, this.assignmentOperator, | 722 SendSet.postfix(receiver, selector, this.assignmentOperator, |
718 [Node argument = null, bool isConditional = false]) | 723 [Node argument = null, bool isConditional = false]) |
719 : super.postfix(receiver, selector, argument, isConditional); | 724 : super.postfix(receiver, selector, argument, isConditional); |
720 SendSet.prefix(receiver, selector, this.assignmentOperator, | 725 SendSet.prefix(receiver, selector, this.assignmentOperator, |
721 [Node argument = null, bool isConditional = false]) | 726 [Node argument = null, bool isConditional = false]) |
722 : super.prefix(receiver, selector, argument, isConditional); | 727 : super.prefix(receiver, selector, argument, isConditional); |
723 | 728 |
724 SendSet asSendSet() => this; | 729 SendSet asSendSet() => this; |
725 | 730 |
726 accept(Visitor visitor) => visitor.visitSendSet(this); | 731 accept(Visitor visitor) => visitor.visitSendSet(this); |
(...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 | 3131 |
3127 // VariableDefinitions. | 3132 // VariableDefinitions. |
3128 get metadata => null; | 3133 get metadata => null; |
3129 get type => null; | 3134 get type => null; |
3130 | 3135 |
3131 // Typedef. | 3136 // Typedef. |
3132 get typeParameters => null; | 3137 get typeParameters => null; |
3133 get formals => null; | 3138 get formals => null; |
3134 get typedefKeyword => null; | 3139 get typedefKeyword => null; |
3135 } | 3140 } |
OLD | NEW |