mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
LibJS: Add basic "if" statement support to the bytecode VM :^)
This also required making Bytecode::Op::Jump support lazy linking to a target label. I left a FIXME here about having the "if" statement return the result value from the taken branch statement. That's what the AST interpreter does but I'm not sure if it's actually required.
This commit is contained in:
parent
80b1604b0a
commit
79eac08f5b
4 changed files with 30 additions and 5 deletions
|
@ -72,7 +72,7 @@ void PutById::execute(Bytecode::Interpreter& interpreter) const
|
|||
|
||||
void Jump::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.jump(m_target);
|
||||
interpreter.jump(*m_target);
|
||||
}
|
||||
|
||||
void JumpIfFalse::execute(Bytecode::Interpreter& interpreter) const
|
||||
|
@ -196,7 +196,7 @@ String GetById::to_string() const
|
|||
|
||||
String Jump::to_string() const
|
||||
{
|
||||
return String::formatted("Jump {}", m_target);
|
||||
return String::formatted("Jump {}", *m_target);
|
||||
}
|
||||
|
||||
String JumpIfFalse::to_string() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue