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, |