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 4a2f3e0de7ed64455e5387e51c9ff41b48e6a96d..9753787f7110b16d77dc54d53d526b9ebcd3a39d 100644 |
--- a/pkg/compiler/lib/src/ssa/builder.dart |
+++ b/pkg/compiler/lib/src/ssa/builder.dart |
@@ -2589,6 +2589,31 @@ class SsaBuilder extends ast.Visitor |
return pop(); |
} |
+ visitAssert(ast.Assert node) { |
+ if (!compiler.enableUserAssertions) return; |
+ |
+ void buildCondition() { |
+ visit(node.condition); |
+ var arguments = [pop()]; |
+ pushInvokeStatic(node, backend.assertConditionHelperMethod, arguments); |
+ } |
+ void fail() { |
+ var arguments = new List(); |
+ if (node.message != null) { |
+ visit(node.message); |
+ arguments.add(pop()); |
+ } else { |
+ arguments.add(graph.addConstantNull(compiler)); |
+ } |
+ pushInvokeStatic(node, backend.assertThrowMethod, arguments); |
+ pop(); |
+ } |
+ handleIf(node, |
Siggi Cherem (dart-lang)
2015/09/03 16:13:24
What does the final output endup looking like?
In
Lasse Reichstein Nielsen
2015/09/09 12:02:46
Ack, it's the latter, only uglier: if (....helper(
|
+ visitCondition: buildCondition, |
+ visitThen: () {}, |
+ visitElse: fail); |
+ } |
+ |
visitBlock(ast.Block node) { |
assert(!isAborted()); |
if (!isReachable) return; // This can only happen when inlining. |
@@ -5162,18 +5187,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"); |
} |
@@ -8231,14 +8244,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, |