Index: src/interpreter/bytecode-array-builder.cc |
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc |
index a41d332a307db4f2e6e57d1bde2f6fcb3873f996..7fb5e949a11b815d860618265f8fed5a43124264 100644 |
--- a/src/interpreter/bytecode-array-builder.cc |
+++ b/src/interpreter/bytecode-array-builder.cc |
@@ -172,6 +172,17 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op, |
} |
+BytecodeArrayBuilder& BytecodeArrayBuilder::CountOperation(Token::Value op, |
+ Strength strength) { |
+ if (is_strong(strength)) { |
+ UNIMPLEMENTED(); |
+ } |
+ |
+ Output(BytecodeForCountOperation(op)); |
+ return *this; |
+} |
+ |
+ |
BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { |
Output(Bytecode::kLogicalNot); |
return *this; |
@@ -465,6 +476,14 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToName() { |
} |
+BytecodeArrayBuilder& BytecodeArrayBuilder::CastAccumulatorToNumber() { |
+ // TODO(rmcilroy): consider omitting if the preceeding bytecode always returns |
+ // a number. |
+ Output(Bytecode::kToNumber); |
+ return *this; |
+} |
+ |
+ |
BytecodeArrayBuilder& BytecodeArrayBuilder::Bind(BytecodeLabel* label) { |
if (label->is_forward_target()) { |
// An earlier jump instruction refers to this label. Update it's location. |
@@ -827,6 +846,20 @@ Bytecode BytecodeArrayBuilder::BytecodeForBinaryOperation(Token::Value op) { |
// static |
+Bytecode BytecodeArrayBuilder::BytecodeForCountOperation(Token::Value op) { |
+ switch (op) { |
+ case Token::Value::ADD: |
+ return Bytecode::kInc; |
+ case Token::Value::SUB: |
+ return Bytecode::kDec; |
+ default: |
+ UNREACHABLE(); |
+ return static_cast<Bytecode>(-1); |
+ } |
+} |
+ |
+ |
+// static |
Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) { |
switch (op) { |
case Token::Value::EQ: |