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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 737353002: cps-ir: Implement boolean conversion in and use it to implement '&&', '||', and '?:'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index 9dbaad40aa98b688eb834730d87bc21b3207a19c..cee19b10aad1137a3daed34d5d8092300c1a6adf 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -79,6 +79,14 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
body = new js.Block(accumulator);
}
+ js.Expression visit(tree_ir.Expression node) {
+ js.Expression result = node.accept(this);
+ if (result == null) {
+ glue.reportInternalError('$node did not produce code.');
+ }
+ return result;
+ }
+
/// Generates a name for the given variable. First trying with the name of
/// the [Variable.element] if it is non-null.
String getVariableName(tree_ir.Variable variable) {
@@ -128,8 +136,10 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitConditional(tree_ir.Conditional node) {
- return giveup(node);
- // TODO: implement visitConditional
+ return new js.Conditional(
+ visit(node.condition),
+ visit(node.thenExpression),
+ visit(node.elseExpression));
}
@override
@@ -187,8 +197,7 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitLogicalOperator(tree_ir.LogicalOperator node) {
- return giveup(node);
- // TODO: implement visitLogicalOperator
+ return new js.Binary(node.operator, visit(node.left), visit(node.right));
}
@override

Powered by Google App Engine
This is Rietveld 408576698