| 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 part of dart2js.semantics_visitor; | 5 part of dart2js.semantics_visitor; |
| 6 | 6 |
| 7 /// Interface for bulk handling of a [Node] in a semantic visitor. | 7 /// Interface for bulk handling of a [Node] in a semantic visitor. |
| 8 abstract class BulkHandle<R, A> { | 8 abstract class BulkHandle<R, A> { |
| 9 /// Handle [node] either regardless of semantics or to report that [node] is | 9 /// Handle [node] either regardless of semantics or to report that [node] is |
| 10 /// unhandled. [message] contains a message template for the latter case: | 10 /// unhandled. [message] contains a message template for the latter case: |
| 11 /// Replace '#' in [message] by `node.toString()` to create a message for the | 11 /// Replace '#' in [message] by `node.toString()` to create a message for the |
| 12 /// error. | 12 /// error. |
| 13 R bulkHandleNode(Node node, String message, A arg); | 13 R bulkHandleNode(Node node, String message, A arg); |
| 14 } | 14 } |
| 15 | 15 |
| 16 /// Mixin that implements all `errorX` methods of [SemanticSendVisitor] by | 16 /// Mixin that implements all `errorX` methods of [SemanticSendVisitor] by |
| 17 /// delegating to a bulk handler. | 17 /// delegating to a bulk handler. |
| 18 /// | 18 /// |
| 19 /// Use this mixin to provide a trivial implementation for all `errorX` methods. | 19 /// Use this mixin to provide a trivial implementation for all `errorX` methods. |
| 20 abstract class ErrorBulkMixin<R, A> | 20 abstract class ErrorBulkMixin<R, A> |
| 21 implements SemanticSendVisitor<R, A>, BulkHandle<R, A> { | 21 implements SemanticSendVisitor<R, A>, BulkHandle<R, A> { |
| 22 | 22 |
| 23 R bulkHandleError(Node node, A arg) { | 23 // TODO(johnniwinther): Ensure that all error methods have an |
| 24 // [ErroneousElement]. |
| 25 R bulkHandleError(Node node, ErroneousElement error, A arg) { |
| 24 return bulkHandleNode(node, "Error expression `#` unhandled.", arg); | 26 return bulkHandleNode(node, "Error expression `#` unhandled.", arg); |
| 25 } | 27 } |
| 26 | 28 |
| 27 @override | 29 @override |
| 28 R errorInvalidAssert( | 30 R errorInvalidAssert( |
| 29 Send node, | 31 Send node, |
| 30 NodeList arguments, | 32 NodeList arguments, |
| 31 A arg) { | 33 A arg) { |
| 32 return bulkHandleError(node, arg); | 34 return bulkHandleError(node, null, arg); |
| 33 } | 35 } |
| 34 | 36 |
| 35 @override | 37 @override |
| 36 R errorNonConstantConstructorInvoke( | 38 R errorNonConstantConstructorInvoke( |
| 37 NewExpression node, | 39 NewExpression node, |
| 38 Element element, | 40 Element element, |
| 39 DartType type, | 41 DartType type, |
| 40 NodeList arguments, | 42 NodeList arguments, |
| 41 CallStructure callStructure, | 43 CallStructure callStructure, |
| 42 A arg) { | 44 A arg) { |
| 43 return bulkHandleError(node, arg); | 45 return bulkHandleError(node, null, arg); |
| 44 } | 46 } |
| 45 | 47 |
| 46 @override | 48 @override |
| 47 R errorUndefinedUnaryExpression( | 49 R errorUndefinedUnaryExpression( |
| 48 Send node, | 50 Send node, |
| 49 Operator operator, | 51 Operator operator, |
| 50 Node expression, | 52 Node expression, |
| 51 A arg) { | 53 A arg) { |
| 52 return bulkHandleError(node, arg); | 54 return bulkHandleError(node, null, arg); |
| 53 } | 55 } |
| 54 | 56 |
| 55 @override | 57 @override |
| 56 R errorUndefinedBinaryExpression( | 58 R errorUndefinedBinaryExpression( |
| 57 Send node, | 59 Send node, |
| 58 Node left, | 60 Node left, |
| 59 Operator operator, | 61 Operator operator, |
| 60 Node right, | 62 Node right, |
| 61 A arg) { | 63 A arg) { |
| 62 return bulkHandleError(node, arg); | 64 return bulkHandleError(node, null, arg); |
| 65 } |
| 66 |
| 67 @override |
| 68 R errorInvalidCompound( |
| 69 Send node, |
| 70 ErroneousElement error, |
| 71 AssignmentOperator operator, |
| 72 Node rhs, |
| 73 A arg) { |
| 74 return bulkHandleError(node, error, arg); |
| 75 } |
| 76 |
| 77 @override |
| 78 R errorInvalidGet( |
| 79 Send node, |
| 80 ErroneousElement error, |
| 81 A arg) { |
| 82 return bulkHandleError(node, error, arg); |
| 83 } |
| 84 |
| 85 @override |
| 86 R errorInvalidInvoke( |
| 87 Send node, |
| 88 ErroneousElement error, |
| 89 NodeList arguments, |
| 90 Selector selector, |
| 91 A arg) { |
| 92 return bulkHandleError(node, error, arg); |
| 93 } |
| 94 |
| 95 @override |
| 96 R errorInvalidPostfix( |
| 97 Send node, |
| 98 ErroneousElement error, |
| 99 IncDecOperator operator, |
| 100 A arg) { |
| 101 return bulkHandleError(node, error, arg); |
| 102 } |
| 103 |
| 104 @override |
| 105 R errorInvalidPrefix( |
| 106 Send node, |
| 107 ErroneousElement error, |
| 108 IncDecOperator operator, |
| 109 A arg) { |
| 110 return bulkHandleError(node, error, arg); |
| 111 } |
| 112 |
| 113 @override |
| 114 R errorInvalidSet( |
| 115 Send node, |
| 116 ErroneousElement error, |
| 117 Node rhs, |
| 118 A arg) { |
| 119 return bulkHandleError(node, error, arg); |
| 63 } | 120 } |
| 64 } | 121 } |
| 65 | 122 |
| 66 /// Mixin that implements all `visitXPrefix` methods of [SemanticSendVisitor] by | 123 /// Mixin that implements all `visitXPrefix` methods of [SemanticSendVisitor] by |
| 67 /// delegating to a bulk handler. | 124 /// delegating to a bulk handler. |
| 68 /// | 125 /// |
| 69 /// Use this mixin to provide a trivial implementation for all `visitXPrefix` | 126 /// Use this mixin to provide a trivial implementation for all `visitXPrefix` |
| 70 /// methods. | 127 /// methods. |
| 71 abstract class PrefixBulkMixin<R, A> | 128 abstract class PrefixBulkMixin<R, A> |
| 72 implements SemanticSendVisitor<R, A>, BulkHandle<R, A> { | 129 implements SemanticSendVisitor<R, A>, BulkHandle<R, A> { |
| (...skipping 3454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3527 @override | 3584 @override |
| 3528 R errorInvalidAssert( | 3585 R errorInvalidAssert( |
| 3529 Send node, | 3586 Send node, |
| 3530 NodeList arguments, | 3587 NodeList arguments, |
| 3531 A arg) { | 3588 A arg) { |
| 3532 apply(arguments, arg); | 3589 apply(arguments, arg); |
| 3533 return null; | 3590 return null; |
| 3534 } | 3591 } |
| 3535 | 3592 |
| 3536 @override | 3593 @override |
| 3594 R errorInvalidCompound( |
| 3595 Send node, |
| 3596 ErroneousElement error, |
| 3597 AssignmentOperator operator, |
| 3598 Node rhs, |
| 3599 A arg) { |
| 3600 apply(rhs, arg); |
| 3601 return null; |
| 3602 } |
| 3603 |
| 3604 @override |
| 3605 R errorInvalidGet( |
| 3606 Send node, |
| 3607 ErroneousElement error, |
| 3608 A arg) { |
| 3609 return null; |
| 3610 } |
| 3611 |
| 3612 @override |
| 3613 R errorInvalidInvoke( |
| 3614 Send node, |
| 3615 ErroneousElement error, |
| 3616 NodeList arguments, |
| 3617 Selector selector, |
| 3618 A arg) { |
| 3619 apply(arguments, arg); |
| 3620 return null; |
| 3621 } |
| 3622 |
| 3623 @override |
| 3624 R errorInvalidPostfix( |
| 3625 Send node, |
| 3626 ErroneousElement error, |
| 3627 IncDecOperator operator, |
| 3628 A arg) { |
| 3629 return null; |
| 3630 } |
| 3631 |
| 3632 @override |
| 3633 R errorInvalidPrefix( |
| 3634 Send node, |
| 3635 ErroneousElement error, |
| 3636 IncDecOperator operator, |
| 3637 A arg) { |
| 3638 return null; |
| 3639 } |
| 3640 |
| 3641 @override |
| 3642 R errorInvalidSet( |
| 3643 Send node, |
| 3644 ErroneousElement error, |
| 3645 Node rhs, |
| 3646 A arg) { |
| 3647 apply(rhs, arg); |
| 3648 return null; |
| 3649 } |
| 3650 |
| 3651 @override |
| 3537 R visitClassTypeLiteralSet( | 3652 R visitClassTypeLiteralSet( |
| 3538 SendSet node, | 3653 SendSet node, |
| 3539 ConstantExpression constant, | 3654 ConstantExpression constant, |
| 3540 Node rhs, | 3655 Node rhs, |
| 3541 A arg) { | 3656 A arg) { |
| 3542 apply(rhs, arg); | 3657 apply(rhs, arg); |
| 3543 return null; | 3658 return null; |
| 3544 } | 3659 } |
| 3545 | 3660 |
| 3546 @override | 3661 @override |
| (...skipping 7205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10752 NewExpression node, | 10867 NewExpression node, |
| 10753 ConstructorElement constructor, | 10868 ConstructorElement constructor, |
| 10754 InterfaceType type, | 10869 InterfaceType type, |
| 10755 NodeList arguments, | 10870 NodeList arguments, |
| 10756 CallStructure callStructure, | 10871 CallStructure callStructure, |
| 10757 A arg) { | 10872 A arg) { |
| 10758 return handleConstructorInvoke( | 10873 return handleConstructorInvoke( |
| 10759 node, constructor, type, arguments, callStructure, arg); | 10874 node, constructor, type, arguments, callStructure, arg); |
| 10760 } | 10875 } |
| 10761 } | 10876 } |
| OLD | NEW |