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:
parent
2c10bd72f2
commit
93eae063a1
4 changed files with 34 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue