mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibJS: Add support for "continue" inside "for" statements :^)
This commit is contained in:
parent
e3b92caa6d
commit
9ebd066ac8
8 changed files with 65 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue