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.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'; |
11 import '../constants/expressions.dart'; | 11 import '../constants/expressions.dart'; |
12 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
13 import '../tree/tree.dart'; | 13 import '../tree/tree.dart'; |
14 import '../universe/universe.dart'; | 14 import '../universe/universe.dart'; |
15 import '../util/util.dart'; | 15 import '../util/util.dart'; |
16 | 16 |
| 17 /// Interface for the structure of the semantics of a [Send] or [NewExpression] |
| 18 /// node. |
| 19 abstract class SemanticSendStructure<R, A> { |
| 20 /// Calls the matching visit method on [visitor] with [node] and [arg]. |
| 21 R dispatch(SemanticSendVisitor<R, A> visitor, Node node, A arg); |
| 22 } |
| 23 |
17 /// Interface for the structure of the semantics of a [Send] node. | 24 /// Interface for the structure of the semantics of a [Send] node. |
18 /// | 25 /// |
19 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, | 26 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, |
20 /// `a.b`, `a.b(c)`, etc. | 27 /// `a.b`, `a.b(c)`, etc. |
21 abstract class SendStructure<R, A> { | 28 abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> { |
22 /// Calls the matching visit method on [visitor] with [send] and [arg]. | 29 /// Calls the matching visit method on [visitor] with [send] and [arg]. |
23 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); | 30 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); |
24 } | 31 } |
25 | 32 |
26 /// The structure for a [Send] of the form `assert(e)`. | 33 /// The structure for a [Send] of the form `assert(e)`. |
27 class AssertStructure<R, A> implements SendStructure<R, A> { | 34 class AssertStructure<R, A> implements SendStructure<R, A> { |
28 const AssertStructure(); | 35 const AssertStructure(); |
29 | 36 |
30 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 37 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
31 return visitor.visitAssert( | 38 return visitor.visitAssert( |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 } | 1811 } |
1805 } | 1812 } |
1806 throw new SpannableAssertionFailure(node, | 1813 throw new SpannableAssertionFailure(node, |
1807 "Invalid compound assigment: ${semantics}"); | 1814 "Invalid compound assigment: ${semantics}"); |
1808 } | 1815 } |
1809 | 1816 |
1810 String toString() => 'postfix($operator,$semantics)'; | 1817 String toString() => 'postfix($operator,$semantics)'; |
1811 } | 1818 } |
1812 | 1819 |
1813 /// The structure for a [NewExpression] of a new invocation. | 1820 /// The structure for a [NewExpression] of a new invocation. |
1814 abstract class NewStructure<R, A> { | 1821 abstract class NewStructure<R, A> implements SemanticSendStructure<R, A> { |
1815 /// Calls the matching visit method on [visitor] with [node] and [arg]. | 1822 /// Calls the matching visit method on [visitor] with [node] and [arg]. |
1816 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg); | 1823 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg); |
1817 } | 1824 } |
1818 | 1825 |
1819 /// The structure for a [NewExpression] of a new invocation. For instance | 1826 /// The structure for a [NewExpression] of a new invocation. For instance |
1820 /// `new C()`. | 1827 /// `new C()`. |
1821 class NewInvokeStructure<R, A> extends NewStructure<R, A> { | 1828 class NewInvokeStructure<R, A> extends NewStructure<R, A> { |
1822 final ConstructorAccessSemantics semantics; | 1829 final ConstructorAccessSemantics semantics; |
1823 final Selector selector; | 1830 final Selector selector; |
1824 | 1831 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 final ConstructorElement constructor; | 2077 final ConstructorElement constructor; |
2071 final Selector selector; | 2078 final Selector selector; |
2072 | 2079 |
2073 ThisConstructorInvokeStructure(this.constructor, this.selector); | 2080 ThisConstructorInvokeStructure(this.constructor, this.selector); |
2074 | 2081 |
2075 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) { | 2082 R dispatch(SemanticDeclarationVisitor<R, A> visitor, Send node, A arg) { |
2076 return visitor.visitThisConstructorInvoke( | 2083 return visitor.visitThisConstructorInvoke( |
2077 node, constructor, node.argumentsNode, selector, arg); | 2084 node, constructor, node.argumentsNode, selector, arg); |
2078 } | 2085 } |
2079 } | 2086 } |
OLD | NEW |