1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibJS: Add Sub bytecode instruction (subtract values)

This commit is contained in:
Andreas Kling 2021-06-03 18:32:33 +02:00
parent 23a4448862
commit 2b9fbd10ed
3 changed files with 35 additions and 3 deletions

View file

@ -2264,12 +2264,15 @@ Optional<Bytecode::Register> BinaryExpression::generate_bytecode(Bytecode::Gener
VERIFY(lhs_reg.has_value());
VERIFY(rhs_reg.has_value());
auto dst_reg = generator.allocate_register();
switch (m_op) {
case BinaryOp::Addition: {
auto dst_reg = generator.allocate_register();
case BinaryOp::Addition:
generator.emit<Bytecode::Op::Add>(dst_reg, *lhs_reg, *rhs_reg);
return dst_reg;
}
case BinaryOp::Subtraction:
generator.emit<Bytecode::Op::Sub>(dst_reg, *lhs_reg, *rhs_reg);
return dst_reg;
default:
TODO();
}