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