LibJS: Remove redundant completion type check in ScriptEvaluation
See editorial change to the ECMA-262 spec of: https://github.com/tc39/ecma262/commit/bc5b7fda5
This commit is contained in:
parent
d48a0aaa55
commit
8beb567088
Notes:
github-actions[bot]
2025-01-02 10:31:09 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/8beb5670888 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3091
1 changed files with 11 additions and 10 deletions
|
@ -229,6 +229,7 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record, GC::Ptr<Environ
|
|||
|
||||
// 13. If result.[[Type]] is normal, then
|
||||
if (result.type() == Completion::Type::Normal) {
|
||||
// a. Set result to Completion(Evaluation of script).
|
||||
auto executable_result = JS::Bytecode::Generator::generate_from_ast_node(vm, script, {});
|
||||
|
||||
if (executable_result.is_error()) {
|
||||
|
@ -251,21 +252,21 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record, GC::Ptr<Environ
|
|||
else
|
||||
result = result_or_error.return_register_value;
|
||||
}
|
||||
|
||||
// b. If result is a normal completion and result.[[Value]] is empty, then
|
||||
if (result.type() == Completion::Type::Normal && !result.value().has_value()) {
|
||||
// i. Set result to NormalCompletion(undefined).
|
||||
result = normal_completion(js_undefined());
|
||||
}
|
||||
}
|
||||
|
||||
// 14. If result.[[Type]] is normal and result.[[Value]] is empty, then
|
||||
if (result.type() == Completion::Type::Normal && !result.value().has_value()) {
|
||||
// a. Set result to NormalCompletion(undefined).
|
||||
result = normal_completion(js_undefined());
|
||||
}
|
||||
|
||||
// 15. Suspend scriptContext and remove it from the execution context stack.
|
||||
// 14. Suspend scriptContext and remove it from the execution context stack.
|
||||
vm.pop_execution_context();
|
||||
|
||||
// 16. Assert: The execution context stack is not empty.
|
||||
// 15. Assert: The execution context stack is not empty.
|
||||
VERIFY(!vm.execution_context_stack().is_empty());
|
||||
|
||||
// FIXME: 17. Resume the context that is now on the top of the execution context stack as the running execution context.
|
||||
// FIXME: 16. Resume the context that is now on the top of the execution context stack as the running execution context.
|
||||
|
||||
// At this point we may have already run any queued promise jobs via on_call_stack_emptied,
|
||||
// in which case this is a no-op.
|
||||
|
@ -279,7 +280,7 @@ ThrowCompletionOr<Value> Interpreter::run(Script& script_record, GC::Ptr<Environ
|
|||
|
||||
vm.finish_execution_generation();
|
||||
|
||||
// 18. Return ? result.
|
||||
// 17. Return ? result.
|
||||
if (result.is_abrupt()) {
|
||||
VERIFY(result.type() == Completion::Type::Throw);
|
||||
return result.release_error();
|
||||
|
|
Loading…
Add table
Reference in a new issue