mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 23:25:20 +00:00
LibJS: Add basic support for "continue" in the bytecode VM
Unlike the convoluted unwind-until-scope-type mechanism in the AST interpreter, "continue" maps to a simple Bytecode::Op::Jump here. :^) We know where to jump based on a stack of "continuable scopes" that we now maintain on the Bytecode::Generator as we go. Note that this only supports bare "continue", not continue-with-label.
This commit is contained in:
@@ -47,4 +47,19 @@ Label Generator::make_label() const
|
||||
return Label { m_block->instructions().size() };
|
||||
}
|
||||
|
||||
Label Generator::nearest_continuable_scope() const
|
||||
{
|
||||
return m_continuable_scopes.last();
|
||||
}
|
||||
|
||||
void Generator::begin_continuable_scope()
|
||||
{
|
||||
m_continuable_scopes.append(make_label());
|
||||
}
|
||||
|
||||
void Generator::end_continuable_scope()
|
||||
{
|
||||
m_continuable_scopes.take_last();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user