Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart b/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart |
| index 0626d3869b615ada955f8d0b1602e0b8f3e974fa..3e6c6c3820cffbca3a1b8e1d4fe4ddcf4cd98f3a 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart |
| @@ -950,6 +950,35 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> { |
| } |
| } |
| + ir.Primitive translateNot(ir.Primitive condition) { |
|
Kevin Millikin (Google)
2014/06/20 09:18:14
Maybe "translate" is the wrong name, it's not tran
sigurdm
2014/06/23 08:08:57
Much better name, thanks
|
| + // ! e is translated as e ? false : true |
| + |
| + // Add a continuation parameter for the result of the expression. |
| + ir.Parameter resultParameter = new ir.Parameter(null); |
| + |
| + ir.Continuation joinContinuation = new ir.Continuation([resultParameter]); |
| + ir.Continuation thenContinuation = new ir.Continuation([]); |
| + ir.Continuation elseContinuation = new ir.Continuation([]); |
| + |
| + ir.Constant trueConstant = |
| + new ir.Constant(constantSystem.createBool(true)); |
| + ir.Constant falseConstant = |
| + new ir.Constant(constantSystem.createBool(false)); |
| + |
| + thenContinuation.body = new ir.LetPrim(falseConstant) |
| + ..plug(new ir.InvokeContinuation(joinContinuation, [falseConstant])); |
| + elseContinuation.body = new ir.LetPrim(trueConstant) |
| + ..plug(new ir.InvokeContinuation(joinContinuation, [trueConstant])); |
| + |
| + add(new ir.LetCont(joinContinuation, |
| + new ir.LetCont(thenContinuation, |
| + new ir.LetCont(elseContinuation, |
| + new ir.Branch(new ir.IsTrue(condition), |
| + thenContinuation, |
| + elseContinuation))))); |
| + return resultParameter; |
| + } |
| + |
| ir.Primitive translateLogicalOperator(ast.Operator op, |
| ast.Expression left, |
| ast.Expression right) { |
| @@ -1051,6 +1080,17 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> { |
| assert(node.arguments.tail.isEmpty); |
| return translateLogicalOperator(op, node.receiver, node.arguments.head); |
| } |
| + if (op.source == "!") { |
| + assert(node.receiver != null); |
| + assert(node.arguments.isEmpty); |
| + return translateNot(visit(node.receiver)); |
| + } |
| + if (op.source == "!=") { |
| + assert(node.receiver != null); |
| + assert(!node.arguments.isEmpty); |
| + assert(node.arguments.tail.isEmpty); |
| + return translateNot(visitDynamicSend(node)); |
| + } |
| return giveup(); |
| } |