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

Unified Diff: pkg/compiler/lib/src/ssa/builder.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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 7239a44dd6c80d2d8cb97cf548457bd19f7440cc..c904ee044b1f7733cc7b52e059442d0e6002a662 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -2607,6 +2607,30 @@ class SsaBuilder extends ast.Visitor
return pop();
}
+ visitAssert(ast.Assert node) {
+ if (!compiler.enableTypeAssertions) return;
+
+ if (!node.hasMessage) {
+ visit(node.condition);
+ pushInvokeStatic(node, backend.assertHelperMethod, [pop()]);
+ pop();
+ return;
+ }
+ // Assert had message.
+ void buildCondition() {
+ visit(node.condition);
+ pushInvokeStatic(node, backend.assertTestMethod, [pop()]);
+ }
+ void fail() {
+ visit(node.message);
+ pushInvokeStatic(node, backend.assertThrowMethod, [pop()]);
+ pop();
+ }
+ handleIf(node,
+ visitCondition: buildCondition,
+ visitThen: fail);
+ }
+
visitBlock(ast.Block node) {
assert(!isAborted());
if (!isReachable) return; // This can only happen when inlining.
@@ -5182,18 +5206,6 @@ class SsaBuilder extends ast.Visitor
return false;
}
- @override
- visitAssert(ast.Send node, ast.Node expression, _) {
- if (!compiler.enableUserAssertions) {
- stack.add(graph.addConstantNull(compiler));
- return;
- }
- assert(invariant(node, node.arguments.tail.isEmpty,
- message: "Invalid assertion: $node"));
- generateStaticFunctionInvoke(
- node, backend.assertMethod, CallStructure.ONE_ARG);
- }
-
visitStaticSend(ast.Send node) {
internalError(node, "Unexpected visitStaticSend");
}
@@ -8310,14 +8322,6 @@ class SsaBuilder extends ast.Visitor
}
@override
- void errorInvalidAssert(
- ast.Send node,
- ast.NodeList arguments,
- _) {
- visitNode(node);
- }
-
- @override
void errorUndefinedBinaryExpression(
ast.Send node,
ast.Node left,

Powered by Google App Engine
This is Rietveld 408576698