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 // TODO(johnniwinther): Ensure that all error methods have an | 23 // TODO(johnniwinther): Ensure that all error methods have an |
24 // [ErroneousElement]. | 24 // [ErroneousElement]. |
25 R bulkHandleError(Node node, ErroneousElement error, A arg) { | 25 R bulkHandleError(Node node, ErroneousElement error, A arg) { |
26 return bulkHandleNode(node, "Error expression `#` unhandled.", arg); | 26 return bulkHandleNode(node, "Error expression `#` unhandled.", arg); |
27 } | 27 } |
28 | 28 |
29 @override | 29 @override |
| 30 R errorInvalidAssert( |
| 31 Send node, |
| 32 NodeList arguments, |
| 33 A arg) { |
| 34 return bulkHandleError(node, null, arg); |
| 35 } |
| 36 |
| 37 @override |
30 R errorNonConstantConstructorInvoke( | 38 R errorNonConstantConstructorInvoke( |
31 NewExpression node, | 39 NewExpression node, |
32 Element element, | 40 Element element, |
33 DartType type, | 41 DartType type, |
34 NodeList arguments, | 42 NodeList arguments, |
35 CallStructure callStructure, | 43 CallStructure callStructure, |
36 A arg) { | 44 A arg) { |
37 return bulkHandleError(node, null, arg); | 45 return bulkHandleError(node, null, arg); |
38 } | 46 } |
39 | 47 |
(...skipping 2888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2928 @override | 2936 @override |
2929 R visitAs( | 2937 R visitAs( |
2930 Send node, | 2938 Send node, |
2931 Node expression, | 2939 Node expression, |
2932 DartType type, | 2940 DartType type, |
2933 A arg) { | 2941 A arg) { |
2934 return bulkHandleNode(node, 'As cast `#` unhandled.', arg); | 2942 return bulkHandleNode(node, 'As cast `#` unhandled.', arg); |
2935 } | 2943 } |
2936 | 2944 |
2937 @override | 2945 @override |
| 2946 R visitAssert( |
| 2947 Send node, |
| 2948 Node expression, |
| 2949 A arg) { |
| 2950 return bulkHandleNode(node, 'Assert `#` unhandled.', arg); |
| 2951 } |
| 2952 |
| 2953 @override |
2938 R visitIs( | 2954 R visitIs( |
2939 Send node, | 2955 Send node, |
2940 Node expression, | 2956 Node expression, |
2941 DartType type, | 2957 DartType type, |
2942 A arg) { | 2958 A arg) { |
2943 return bulkHandleNode(node, 'Is test `#` unhandled.', arg); | 2959 return bulkHandleNode(node, 'Is test `#` unhandled.', arg); |
2944 } | 2960 } |
2945 | 2961 |
2946 @override | 2962 @override |
2947 R visitIsNot( | 2963 R visitIsNot( |
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4512 R visitAs( | 4528 R visitAs( |
4513 Send node, | 4529 Send node, |
4514 Node expression, | 4530 Node expression, |
4515 DartType type, | 4531 DartType type, |
4516 A arg) { | 4532 A arg) { |
4517 apply(expression, arg); | 4533 apply(expression, arg); |
4518 return null; | 4534 return null; |
4519 } | 4535 } |
4520 | 4536 |
4521 @override | 4537 @override |
| 4538 R visitAssert( |
| 4539 Send node, |
| 4540 Node expression, |
| 4541 A arg) { |
| 4542 apply(expression, arg); |
| 4543 return null; |
| 4544 } |
| 4545 |
| 4546 @override |
4522 R visitBinary( | 4547 R visitBinary( |
4523 Send node, | 4548 Send node, |
4524 Node left, | 4549 Node left, |
4525 BinaryOperator operator, | 4550 BinaryOperator operator, |
4526 Node right, | 4551 Node right, |
4527 A arg) { | 4552 A arg) { |
4528 apply(left, arg); | 4553 apply(left, arg); |
4529 apply(right, arg); | 4554 apply(right, arg); |
4530 return null; | 4555 return null; |
4531 } | 4556 } |
(...skipping 7824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12356 NewExpression node, | 12381 NewExpression node, |
12357 ConstructorElement constructor, | 12382 ConstructorElement constructor, |
12358 InterfaceType type, | 12383 InterfaceType type, |
12359 NodeList arguments, | 12384 NodeList arguments, |
12360 CallStructure callStructure, | 12385 CallStructure callStructure, |
12361 A arg) { | 12386 A arg) { |
12362 return handleConstructorInvoke( | 12387 return handleConstructorInvoke( |
12363 node, constructor, type, arguments, callStructure, arg); | 12388 node, constructor, type, arguments, callStructure, arg); |
12364 } | 12389 } |
12365 } | 12390 } |
OLD | NEW |