LibJS: Integrate labels into the Interpreter

The interpreter now considers a statement or block's label when
considering whether or not to break. All statements can be labelled.
This commit is contained in:
Matthew Olsson 2020-05-28 13:36:59 -07:00 committed by Andreas Kling
commit d52ea37717
Notes: sideshowbarker 2024-07-19 05:59:30 +09:00
6 changed files with 87 additions and 21 deletions

View file

@ -72,8 +72,11 @@ Value Interpreter::run(const Statement& statement, ArgumentVector arguments, Sco
m_last_value = js_undefined();
for (auto& node : block.children()) {
m_last_value = node.execute(*this);
if (m_unwind_until != ScopeType::None)
if (should_unwind()) {
if (should_unwind_until(ScopeType::Breakable, block.label()))
stop_unwind();
break;
}
}
bool did_return = m_unwind_until == ScopeType::Function;