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

Unified Diff: sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart

Issue 333823005: Add support for ! and != to the new IR builder (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename function Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b5b49d9489204debac99bdde253942b022fd10a1..9fe793057d88db1293663b76917d8cb03b9982a9 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 buildNegation(ir.Primitive condition) {
+ // ! 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 buildNegation(visit(node.receiver));
+ }
+ if (op.source == "!=") {
+ assert(node.receiver != null);
+ assert(!node.arguments.isEmpty);
+ assert(node.arguments.tail.isEmpty);
+ return buildNegation(visitDynamicSend(node));
+ }
return giveup();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698