Index: src/interpreter/bytecode-array-builder.cc |
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc |
index 8e52ecd7fd287b1d475b2971f5f24df86c5edd84..e100491bb06c0be3bb592659e67d469c097f3251 100644 |
--- a/src/interpreter/bytecode-array-builder.cc |
+++ b/src/interpreter/bytecode-array-builder.cc |
@@ -151,6 +151,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; |
@@ -428,6 +439,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. |
@@ -724,6 +743,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: |