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

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: Reintroduce assertHelper for asserts without messages. 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 2888 matching lines...) Expand 10 before | Expand all | Expand 10 after
2936 @override 2928 @override
2937 R visitAs( 2929 R visitAs(
2938 Send node, 2930 Send node,
2939 Node expression, 2931 Node expression,
2940 DartType type, 2932 DartType type,
2941 A arg) { 2933 A arg) {
2942 return bulkHandleNode(node, 'As cast `#` unhandled.', arg); 2934 return bulkHandleNode(node, 'As cast `#` unhandled.', arg);
2943 } 2935 }
2944 2936
2945 @override 2937 @override
2946 R visitAssert(
2947 Send node,
2948 Node expression,
2949 A arg) {
2950 return bulkHandleNode(node, 'Assert `#` unhandled.', arg);
2951 }
2952
2953 @override
2954 R visitIs( 2938 R visitIs(
2955 Send node, 2939 Send node,
2956 Node expression, 2940 Node expression,
2957 DartType type, 2941 DartType type,
2958 A arg) { 2942 A arg) {
2959 return bulkHandleNode(node, 'Is test `#` unhandled.', arg); 2943 return bulkHandleNode(node, 'Is test `#` unhandled.', arg);
2960 } 2944 }
2961 2945
2962 @override 2946 @override
2963 R visitIsNot( 2947 R visitIsNot(
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
4528 R visitAs( 4512 R visitAs(
4529 Send node, 4513 Send node,
4530 Node expression, 4514 Node expression,
4531 DartType type, 4515 DartType type,
4532 A arg) { 4516 A arg) {
4533 apply(expression, arg); 4517 apply(expression, arg);
4534 return null; 4518 return null;
4535 } 4519 }
4536 4520
4537 @override 4521 @override
4538 R visitAssert(
4539 Send node,
4540 Node expression,
4541 A arg) {
4542 apply(expression, arg);
4543 return null;
4544 }
4545
4546 @override
4547 R visitBinary( 4522 R visitBinary(
4548 Send node, 4523 Send node,
4549 Node left, 4524 Node left,
4550 BinaryOperator operator, 4525 BinaryOperator operator,
4551 Node right, 4526 Node right,
4552 A arg) { 4527 A arg) {
4553 apply(left, arg); 4528 apply(left, arg);
4554 apply(right, arg); 4529 apply(right, arg);
4555 return null; 4530 return null;
4556 } 4531 }
(...skipping 7824 matching lines...) Expand 10 before | Expand all | Expand 10 after
12381 NewExpression node, 12356 NewExpression node,
12382 ConstructorElement constructor, 12357 ConstructorElement constructor,
12383 InterfaceType type, 12358 InterfaceType type,
12384 NodeList arguments, 12359 NodeList arguments,
12385 CallStructure callStructure, 12360 CallStructure callStructure,
12386 A arg) { 12361 A arg) {
12387 return handleConstructorInvoke( 12362 return handleConstructorInvoke(
12388 node, constructor, type, arguments, callStructure, arg); 12363 node, constructor, type, arguments, callStructure, arg);
12389 } 12364 }
12390 } 12365 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698