mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +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
|
@ -52,6 +52,11 @@ void Load::execute(Bytecode::Interpreter& interpreter) const
|
|||
interpreter.reg(m_dst) = m_value;
|
||||
}
|
||||
|
||||
void LoadRegister::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.reg(m_dst) = interpreter.reg(m_src);
|
||||
}
|
||||
|
||||
void Add::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.reg(m_dst) = add(interpreter.global_object(), interpreter.reg(m_src1), interpreter.reg(m_src2));
|
||||
|
@ -284,6 +289,11 @@ String Load::to_string() const
|
|||
return String::formatted("Load dst:{}, value:{}", m_dst, m_value.to_string_without_side_effects());
|
||||
}
|
||||
|
||||
String LoadRegister::to_string() const
|
||||
{
|
||||
return String::formatted("LoadRegister dst:{}, src:{}", m_dst, m_src);
|
||||
}
|
||||
|
||||
String Add::to_string() const
|
||||
{
|
||||
return String::formatted("Add dst:{}, src1:{}, src2:{}", m_dst, m_src1, m_src2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue