mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibJS: Add support for "continue" inside "for" statements :^)
This commit is contained in:
@@ -215,6 +215,16 @@ Value ForStatement::execute(Interpreter& interpreter) const
|
||||
last_value = interpreter.run(*m_body);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
if (interpreter.should_unwind()) {
|
||||
if (interpreter.should_unwind_until(ScopeType::Continuable)) {
|
||||
interpreter.stop_unwind();
|
||||
} else if (interpreter.should_unwind_until(ScopeType::Breakable)) {
|
||||
interpreter.stop_unwind();
|
||||
break;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
if (m_update) {
|
||||
m_update->execute(interpreter);
|
||||
if (interpreter.exception())
|
||||
@@ -226,6 +236,16 @@ Value ForStatement::execute(Interpreter& interpreter) const
|
||||
last_value = interpreter.run(*m_body);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
if (interpreter.should_unwind()) {
|
||||
if (interpreter.should_unwind_until(ScopeType::Continuable)) {
|
||||
interpreter.stop_unwind();
|
||||
} else if (interpreter.should_unwind_until(ScopeType::Breakable)) {
|
||||
interpreter.stop_unwind();
|
||||
break;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
if (m_update) {
|
||||
m_update->execute(interpreter);
|
||||
if (interpreter.exception())
|
||||
@@ -759,7 +779,7 @@ Value VariableDeclaration::execute(Interpreter& interpreter) const
|
||||
return {};
|
||||
}
|
||||
|
||||
Value VariableDeclarator::execute(Interpreter &) const
|
||||
Value VariableDeclarator::execute(Interpreter&) const
|
||||
{
|
||||
// NOTE: This node is handled by VariableDeclaration.
|
||||
ASSERT_NOT_REACHED();
|
||||
@@ -1005,6 +1025,12 @@ Value BreakStatement::execute(Interpreter& interpreter) const
|
||||
return {};
|
||||
}
|
||||
|
||||
Value ContinueStatement::execute(Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.unwind(ScopeType::Continuable);
|
||||
return {};
|
||||
}
|
||||
|
||||
void SwitchStatement::dump(int indent) const
|
||||
{
|
||||
ASTNode::dump(indent);
|
||||
|
||||
Reference in New Issue
Block a user