mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:47:47 +00:00
LibJS: Generate bytecode for do...while statements :^)
This was quite straightforward using the same label/jump machinery that we added for while statements. The main addition here is a new JumpIfTrue bytecode instruction.
This commit is contained in:
parent
bd1a5e282a
commit
f2863b5a89
4 changed files with 45 additions and 0 deletions
|
@ -193,4 +193,23 @@ private:
|
|||
Optional<Label> m_target;
|
||||
};
|
||||
|
||||
class JumpIfTrue final : public Instruction {
|
||||
public:
|
||||
explicit JumpIfTrue(Register result, Optional<Label> target = {})
|
||||
: m_result(result)
|
||||
, m_target(move(target))
|
||||
{
|
||||
}
|
||||
|
||||
void set_target(Optional<Label> target) { m_target = move(target); }
|
||||
|
||||
virtual ~JumpIfTrue() override { }
|
||||
virtual void execute(Bytecode::Interpreter&) const override;
|
||||
virtual String to_string() const override;
|
||||
|
||||
private:
|
||||
Register m_result;
|
||||
Optional<Label> m_target;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue