| 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 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2753 ThisConstructorInvokeStructure( | 2724 ThisConstructorInvokeStructure( |
| 2754 this.node, this.constructor, this.callStructure); | 2725 this.node, this.constructor, this.callStructure); |
| 2755 | 2726 |
| 2756 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { | 2727 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { |
| 2757 return visitor.visitThisConstructorInvoke( | 2728 return visitor.visitThisConstructorInvoke( |
| 2758 node, constructor, node.argumentsNode, callStructure, arg); | 2729 node, constructor, node.argumentsNode, callStructure, arg); |
| 2759 } | 2730 } |
| 2760 | 2731 |
| 2761 bool get isConstructorInvoke => true; | 2732 bool get isConstructorInvoke => true; |
| 2762 } | 2733 } |
| OLD | NEW |