Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 8c791db5e3d9ddbab25e65145c45bccffcb413e1..150439091610e14cbd58d8e09a2cecc3ccfc9e88 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -656,7 +656,26 @@ void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { |
} |
-void BytecodeGenerator::VisitConditional(Conditional* expr) { UNIMPLEMENTED(); } |
+void BytecodeGenerator::VisitConditional(Conditional* expr) { |
+ // TODO(rmcilroy): Spot easy cases where there code would not need to |
+ // emit the then block or the else block, e.g. condition is |
+ // obviously true/1/false/0. |
oth
2015/10/23 15:24:29
We should use ToBooleanIsFalse/True for the easy c
rmcilroy
2015/10/27 12:03:35
Ack, I'll do this in a followup CL.
|
+ |
+ BytecodeLabel else_label, end_label; |
+ |
+ VisitForAccumulatorValue(expr->condition()); |
+ builder()->CastAccumulatorToBoolean(); |
+ builder()->JumpIfFalse(&else_label); |
+ |
+ VisitForAccumulatorValue(expr->then_expression()); |
+ builder()->Jump(&end_label); |
+ |
+ builder()->Bind(&else_label); |
+ VisitForAccumulatorValue(expr->else_expression()); |
+ builder()->Bind(&end_label); |
+ |
+ execution_result()->SetResultInAccumulator(); |
+} |
void BytecodeGenerator::VisitLiteral(Literal* expr) { |