Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: pkg/compiler/lib/src/resolution/semantic_visitor_mixins.dart

Issue 1325843003: Add optional message to assert in Dart2js. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
38 R errorNonConstantConstructorInvoke( 30 R errorNonConstantConstructorInvoke(
39 NewExpression node, 31 NewExpression node,
40 Element element, 32 Element element,
41 DartType type, 33 DartType type,
42 NodeList arguments, 34 NodeList arguments,
43 CallStructure callStructure, 35 CallStructure callStructure,
44 A arg) { 36 A arg) {
45 return bulkHandleError(node, null, arg); 37 return bulkHandleError(node, null, arg);
46 } 38 }
47 39
(...skipping 2516 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 @override 2556 @override
2565 R visitAs( 2557 R visitAs(
2566 Send node, 2558 Send node,
2567 Node expression, 2559 Node expression,
2568 DartType type, 2560 DartType type,
2569 A arg) { 2561 A arg) {
2570 return bulkHandleNode(node, 'As cast `#` unhandled.', arg); 2562 return bulkHandleNode(node, 'As cast `#` unhandled.', arg);
2571 } 2563 }
2572 2564
2573 @override 2565 @override
2574 R visitAssert(
2575 Send node,
2576 Node expression,
2577 A arg) {
2578 return bulkHandleNode(node, 'Assert `#` unhandled.', arg);
2579 }
2580
2581 @override
2582 R visitIs( 2566 R visitIs(
2583 Send node, 2567 Send node,
2584 Node expression, 2568 Node expression,
2585 DartType type, 2569 DartType type,
2586 A arg) { 2570 A arg) {
2587 return bulkHandleNode(node, 'Is test `#` unhandled.', arg); 2571 return bulkHandleNode(node, 'Is test `#` unhandled.', arg);
2588 } 2572 }
2589 2573
2590 @override 2574 @override
2591 R visitIsNot( 2575 R visitIsNot(
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 } 3646 }
3663 3647
3664 @override 3648 @override
3665 void previsitDeferredAccess( 3649 void previsitDeferredAccess(
3666 Send node, 3650 Send node,
3667 PrefixElement prefix, 3651 PrefixElement prefix,
3668 A arg) { 3652 A arg) {
3669 } 3653 }
3670 3654
3671 @override 3655 @override
3672 R errorInvalidAssert(
3673 Send node,
3674 NodeList arguments,
3675 A arg) {
3676 apply(arguments, arg);
3677 return null;
3678 }
3679
3680 @override
3681 R errorInvalidCompound( 3656 R errorInvalidCompound(
3682 Send node, 3657 Send node,
3683 ErroneousElement error, 3658 ErroneousElement error,
3684 AssignmentOperator operator, 3659 AssignmentOperator operator,
3685 Node rhs, 3660 Node rhs,
3686 A arg) { 3661 A arg) {
3687 apply(rhs, arg); 3662 apply(rhs, arg);
3688 return null; 3663 return null;
3689 } 3664 }
3690 3665
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
4155 R visitAs( 4130 R visitAs(
4156 Send node, 4131 Send node,
4157 Node expression, 4132 Node expression,
4158 DartType type, 4133 DartType type,
4159 A arg) { 4134 A arg) {
4160 apply(expression, arg); 4135 apply(expression, arg);
4161 return null; 4136 return null;
4162 } 4137 }
4163 4138
4164 @override 4139 @override
4165 R visitAssert(
4166 Send node,
4167 Node expression,
4168 A arg) {
4169 apply(expression, arg);
4170 return null;
4171 }
4172
4173 @override
4174 R visitBinary( 4140 R visitBinary(
4175 Send node, 4141 Send node,
4176 Node left, 4142 Node left,
4177 BinaryOperator operator, 4143 BinaryOperator operator,
4178 Node right, 4144 Node right,
4179 A arg) { 4145 A arg) {
4180 apply(left, arg); 4146 apply(left, arg);
4181 apply(right, arg); 4147 apply(right, arg);
4182 return null; 4148 return null;
4183 } 4149 }
(...skipping 6867 matching lines...) Expand 10 before | Expand all | Expand 10 after
11051 NewExpression node, 11017 NewExpression node,
11052 ConstructorElement constructor, 11018 ConstructorElement constructor,
11053 InterfaceType type, 11019 InterfaceType type,
11054 NodeList arguments, 11020 NodeList arguments,
11055 CallStructure callStructure, 11021 CallStructure callStructure,
11056 A arg) { 11022 A arg) {
11057 return handleConstructorInvoke( 11023 return handleConstructorInvoke(
11058 node, constructor, type, arguments, callStructure, arg); 11024 node, constructor, type, arguments, callStructure, arg);
11059 } 11025 }
11060 } 11026 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698