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 '../dart_types.dart'; | 7 import '../dart_types.dart'; |
8 import '../diagnostics/spannable.dart' show | 8 import '../diagnostics/spannable.dart' show |
9 SpannableAssertionFailure; | 9 SpannableAssertionFailure; |
10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 /// Interface for the structure of the semantics of a [Send] node. | 29 /// Interface for the structure of the semantics of a [Send] node. |
30 /// | 30 /// |
31 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, | 31 /// Subclasses handle each of the [Send] variations; `assert(e)`, `a && b`, |
32 /// `a.b`, `a.b(c)`, etc. | 32 /// `a.b`, `a.b(c)`, etc. |
33 abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> { | 33 abstract class SendStructure<R, A> extends SemanticSendStructure<R, A> { |
34 /// Calls the matching visit method on [visitor] with [send] and [arg]. | 34 /// Calls the matching visit method on [visitor] with [send] and [arg]. |
35 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); | 35 R dispatch(SemanticSendVisitor<R, A> visitor, Send send, A arg); |
36 } | 36 } |
37 | 37 |
| 38 /// The structure for a [Send] of the form `assert(e)`. |
| 39 class AssertStructure<R, A> implements SendStructure<R, A> { |
| 40 const AssertStructure(); |
| 41 |
| 42 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 43 return visitor.visitAssert( |
| 44 node, |
| 45 node.arguments.single, |
| 46 arg); |
| 47 } |
| 48 |
| 49 String toString() => 'assert'; |
| 50 } |
| 51 |
| 52 /// The structure for a [Send] of the form an `assert` with less or more than |
| 53 /// one argument. |
| 54 class InvalidAssertStructure<R, A> implements SendStructure<R, A> { |
| 55 const InvalidAssertStructure(); |
| 56 |
| 57 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
| 58 return visitor.errorInvalidAssert( |
| 59 node, |
| 60 node.argumentsNode, |
| 61 arg); |
| 62 } |
| 63 |
| 64 String toString() => 'invalid assert'; |
| 65 } |
| 66 |
38 /// The structure for a [Send] of the form `a ?? b`. | 67 /// The structure for a [Send] of the form `a ?? b`. |
39 class IfNullStructure<R, A> implements SendStructure<R, A> { | 68 class IfNullStructure<R, A> implements SendStructure<R, A> { |
40 const IfNullStructure(); | 69 const IfNullStructure(); |
41 | 70 |
42 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { | 71 R dispatch(SemanticSendVisitor<R, A> visitor, Send node, A arg) { |
43 return visitor.visitIfNull( | 72 return visitor.visitIfNull( |
44 node, | 73 node, |
45 node.receiver, | 74 node.receiver, |
46 node.arguments.single, | 75 node.arguments.single, |
47 arg); | 76 arg); |
(...skipping 2902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 ThisConstructorInvokeStructure( | 2979 ThisConstructorInvokeStructure( |
2951 this.node, this.constructor, this.callStructure); | 2980 this.node, this.constructor, this.callStructure); |
2952 | 2981 |
2953 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { | 2982 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { |
2954 return visitor.visitThisConstructorInvoke( | 2983 return visitor.visitThisConstructorInvoke( |
2955 node, constructor, node.argumentsNode, callStructure, arg); | 2984 node, constructor, node.argumentsNode, callStructure, arg); |
2956 } | 2985 } |
2957 | 2986 |
2958 bool get isConstructorInvoke => true; | 2987 bool get isConstructorInvoke => true; |
2959 } | 2988 } |
OLD | NEW |