mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +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:
committed by
Ali Mohammad Pur
parent
d5791c85b4
commit
e1cd36559d
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user