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

Side by Side Diff: pkg/compiler/lib/src/typechecker.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.typechecker; 5 library dart2js.typechecker;
6 6
7 import 'common/tasks.dart' show 7 import 'common/tasks.dart' show
8 CompilerTask; 8 CompilerTask;
9 import 'compiler.dart' show 9 import 'compiler.dart' show
10 Compiler; 10 Compiler;
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 void pushCascadeType(DartType type) { 595 void pushCascadeType(DartType type) {
596 cascadeTypes = cascadeTypes.prepend(type); 596 cascadeTypes = cascadeTypes.prepend(type);
597 } 597 }
598 598
599 DartType popCascadeType() { 599 DartType popCascadeType() {
600 DartType type = cascadeTypes.head; 600 DartType type = cascadeTypes.head;
601 cascadeTypes = cascadeTypes.tail; 601 cascadeTypes = cascadeTypes.tail;
602 return type; 602 return type;
603 } 603 }
604 604
605 DartType visitAssert(Assert node) {
606 analyze(node.condition);
607 if (node.hasMessage) analyze(node.message);
608 return const StatementType();
609 }
610
605 DartType visitBlock(Block node) { 611 DartType visitBlock(Block node) {
606 return analyze(node.statements); 612 return analyze(node.statements);
607 } 613 }
608 614
609 DartType visitCascade(Cascade node) { 615 DartType visitCascade(Cascade node) {
610 analyze(node.expression); 616 analyze(node.expression);
611 return popCascadeType(); 617 return popCascadeType();
612 } 618 }
613 619
614 DartType visitCascadeReceiver(CascadeReceiver node) { 620 DartType visitCascadeReceiver(CascadeReceiver node) {
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 // This should be the case but we double-check. 1169 // This should be the case but we double-check.
1164 // TODO(johnniwinther): Ensure that we don't suggest malbounded types. 1170 // TODO(johnniwinther): Ensure that we don't suggest malbounded types.
1165 return shownTypeGeneric; 1171 return shownTypeGeneric;
1166 } 1172 }
1167 } 1173 }
1168 return null; 1174 return null;
1169 1175
1170 } 1176 }
1171 1177
1172 DartType visitSend(Send node) { 1178 DartType visitSend(Send node) {
1173 if (elements.isAssert(node)) {
1174 return analyzeInvocation(node, const AssertAccess());
1175 }
1176
1177 Element element = elements[node]; 1179 Element element = elements[node];
1178 1180
1179 if (element != null && element.isConstructor) { 1181 if (element != null && element.isConstructor) {
1180 DartType receiverType; 1182 DartType receiverType;
1181 if (node.receiver != null) { 1183 if (node.receiver != null) {
1182 receiverType = analyze(node.receiver); 1184 receiverType = analyze(node.receiver);
1183 } else if (node.selector.isSuper()) { 1185 } else if (node.selector.isSuper()) {
1184 // TODO(johnniwinther): Lookup super-member in class members. 1186 // TODO(johnniwinther): Lookup super-member in class members.
1185 receiverType = superType; 1187 receiverType = superType;
1186 } else { 1188 } else {
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 1928
1927 visitTypedef(Typedef node) { 1929 visitTypedef(Typedef node) {
1928 // Do not typecheck [Typedef] nodes. 1930 // Do not typecheck [Typedef] nodes.
1929 } 1931 }
1930 1932
1931 visitNode(Node node) { 1933 visitNode(Node node) {
1932 compiler.internalError(node, 1934 compiler.internalError(node,
1933 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 1935 'Unexpected node ${node.getObjectDescription()} in the type checker.');
1934 } 1936 }
1935 } 1937 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698