1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

LibJS: Make sure that if expressions yield the correct value

When evaluated as an expression "if (true) { 3 } else { 5 }"
should yield 3. This updates the bytecode interpreter to make
it so.
This commit is contained in:
Gunnar Beutner 2021-06-07 22:05:09 +02:00 committed by Andreas Kling
parent 2c10bd72f2
commit 93eae063a1
4 changed files with 34 additions and 5 deletions

View file

@ -32,6 +32,23 @@ private:
Value m_value;
};
class LoadRegister final : public Instruction {
public:
LoadRegister(Register dst, Register src)
: Instruction(Type::LoadRegister)
, m_dst(dst)
, m_src(src)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string() const;
private:
Register m_dst;
Register m_src;
};
class Add final : public Instruction {
public:
Add(Register dst, Register src1, Register src2)