Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 2a330ca87059de709f9d3ab3c91039b6738ee064..a84924463f325022663cb59ab7655d4ed857f7b9 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -118,7 +118,19 @@ void BytecodeGenerator::VisitEmptyStatement(EmptyStatement* stmt) { |
| } |
| -void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) { UNIMPLEMENTED(); } |
| +void BytecodeGenerator::VisitIfStatement(IfStatement* stmt) { |
| + // TODO(oth): condition may need a ToBoolean cast - not if a |
| + // sequence of test operations. |
|
rmcilroy
2015/09/18 10:42:23
Could you add the ToBoolean unconditionally for no
oth
2015/09/23 10:46:55
Done.
|
| + // TODO(oth): spot easy cases if (true/1/false/0)? |
| + BytecodeLabel else_start, else_end; |
| + stmt->condition()->Accept(this); |
| + builder().JumpIfFalse(&else_start); |
|
Benedikt Meurer
2015/09/17 17:04:17
Oh thank god, this is so much better to just mater
|
| + Visit(stmt->then_statement()); |
| + builder().Jump(&else_end); |
| + builder().Bind(&else_start); |
| + Visit(stmt->else_statement()); |
| + builder().Bind(&else_end); |
| +} |
| void BytecodeGenerator::VisitContinueStatement(ContinueStatement* stmt) { |
| @@ -452,7 +464,18 @@ void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) { |
| void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| - UNIMPLEMENTED(); |
| + Token::Value op = expr->op(); |
| + Expression* left = expr->left(); |
| + Expression* right = expr->right(); |
| + |
| + TemporaryRegisterScope temporary_register_scope(&builder_); |
| + Register temporary = temporary_register_scope.NewRegister(); |
| + |
| + Visit(left); |
| + builder().StoreAccumulatorInRegister(temporary); |
| + Visit(right); |
| + // TODO(oth): ast-graph-builder has language_mode() option for LT/LE/etc. |
|
rmcilroy
2015/09/18 10:42:23
Could you pass the language mode here and do UNIMP
oth
2015/09/23 10:46:55
Done.
|
| + builder().CompareOperation(op, temporary); |
| } |