mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibJS: Implement bytecode ops for logical expressions
This commit is contained in:
parent
216d27d4c1
commit
6da587b59b
Notes:
sideshowbarker
2024-07-18 12:39:33 +09:00
Author: https://github.com/gunnarbeutner
Commit: 6da587b59b
Pull-request: https://github.com/SerenityOS/serenity/pull/7904
Reviewed-by: https://github.com/awesomekling
5 changed files with 83 additions and 0 deletions
|
@ -165,6 +165,14 @@ void JumpIfTrue::execute(Bytecode::Interpreter& interpreter) const
|
|||
interpreter.jump(m_target.value());
|
||||
}
|
||||
|
||||
void JumpIfNullish::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
VERIFY(m_target.has_value());
|
||||
auto result = interpreter.reg(m_result);
|
||||
if (result.is_nullish())
|
||||
interpreter.jump(m_target.value());
|
||||
}
|
||||
|
||||
void Call::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
auto callee = interpreter.reg(m_callee);
|
||||
|
@ -272,6 +280,13 @@ String JumpIfTrue::to_string() const
|
|||
return String::formatted("JumpIfTrue result:{}, target:<empty>", m_result);
|
||||
}
|
||||
|
||||
String JumpIfNullish::to_string() const
|
||||
{
|
||||
if (m_target.has_value())
|
||||
return String::formatted("JumpIfNullish result:{}, target:{}", m_result, m_target.value());
|
||||
return String::formatted("JumpIfNullish result:{}, target:<empty>", m_result);
|
||||
}
|
||||
|
||||
String Call::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue