mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-20 14:44: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:
committed by
Andreas Kling
parent
2c10bd72f2
commit
93eae063a1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user