mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibJS: Make the BC generator.next(value) work
This used to put the value in the previous frame's accumulator register, which is only correct for the first invocation of the generator.
This commit is contained in:
parent
d5791c85b4
commit
e1cd36559d
1 changed files with 6 additions and 1 deletions
|
@ -100,12 +100,17 @@ ThrowCompletionOr<Value> GeneratorObject::next_impl(VM& vm, GlobalObject& global
|
|||
bytecode_interpreter->accumulator() = js_undefined();
|
||||
return throw_completion(value_to_throw.release_value());
|
||||
}
|
||||
bytecode_interpreter->accumulator() = next_argument.value_or(js_undefined());
|
||||
|
||||
Bytecode::RegisterWindow* frame = nullptr;
|
||||
if (m_frame.has_value())
|
||||
frame = &m_frame.value();
|
||||
|
||||
auto next_value = next_argument.value_or(js_undefined());
|
||||
if (frame)
|
||||
frame->registers[0] = next_value;
|
||||
else
|
||||
bytecode_interpreter->accumulator() = next_value;
|
||||
|
||||
auto next_result = bytecode_interpreter->run_and_return_frame(*m_generating_function->bytecode_executable(), next_block, frame);
|
||||
|
||||
vm.pop_execution_context();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue