Chromium Code Reviews| 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 bf19f704d2f38d7464a25d478aef4f0fc640f61a..dadb4c112f6116a904cb63e85fac6d1f8033f8b1 100644 |
| --- a/pkg/compiler/lib/src/ssa/builder.dart |
| +++ b/pkg/compiler/lib/src/ssa/builder.dart |
| @@ -2608,6 +2608,33 @@ class SsaBuilder extends ast.Visitor |
| return pop(); |
| } |
| + visitAssert(ast.Assert node) { |
| + if (!compiler.enableUserAssertions) return; |
| + |
| + if (!node.hasMessage) { |
|
Lasse Reichstein Nielsen
2015/09/16 06:00:56
Document that this does
assertHelper(condition);
sra1
2015/09/17 03:47:54
Done.
|
| + visit(node.condition); |
| + pushInvokeStatic(node, backend.assertHelperMethod, [pop()]); |
| + pop(); |
| + return; |
| + } |
| + // Assert has message. Generate: |
| + // |
| + // if (assertTest(condition)) assertThrow(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. |
| @@ -5183,18 +5210,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"); |
| } |
| @@ -8311,14 +8326,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, |