mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
LibJS: Add JumpUndefined bytecode
This commit is contained in:
parent
3ee627909a
commit
f39ab2e60a
4 changed files with 31 additions and 1 deletions
|
@ -195,6 +195,17 @@ void JumpNullish::execute_impl(Bytecode::Interpreter& interpreter) const
|
|||
interpreter.jump(m_false_target.value());
|
||||
}
|
||||
|
||||
void JumpUndefined::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
VERIFY(m_true_target.has_value());
|
||||
VERIFY(m_false_target.has_value());
|
||||
auto result = interpreter.accumulator();
|
||||
if (result.is_undefined())
|
||||
interpreter.jump(m_true_target.value());
|
||||
else
|
||||
interpreter.jump(m_false_target.value());
|
||||
}
|
||||
|
||||
void Call::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto callee = interpreter.reg(m_callee);
|
||||
|
@ -439,6 +450,13 @@ String JumpNullish::to_string_impl(Bytecode::Executable const&) const
|
|||
return String::formatted("JumpNullish null:{} nonnull:{}", true_string, false_string);
|
||||
}
|
||||
|
||||
String JumpUndefined::to_string_impl(Bytecode::Executable const&) const
|
||||
{
|
||||
auto true_string = m_true_target.has_value() ? String::formatted("{}", *m_true_target) : "<empty>";
|
||||
auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>";
|
||||
return String::formatted("JumpUndefined undefined:{} not undefined:{}", true_string, false_string);
|
||||
}
|
||||
|
||||
String Call::to_string_impl(Bytecode::Executable const&) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue