mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-07 17:15:26 +00:00
LibJS/Bytecode: Move iterator_to_object to CommonImplementations
This commit is contained in:
committed by
Andreas Kling
parent
d247744a3e
commit
d416cef9bb
@@ -523,4 +523,16 @@ ThrowCompletionOr<NonnullGCPtr<Object>> super_call_with_argument_array(VM& vm, V
|
||||
return result;
|
||||
}
|
||||
|
||||
// FIXME: Since the accumulator is a Value, we store an object there and have to convert back and forth between that an Iterator records. Not great.
|
||||
// Make sure to put this into the accumulator before the iterator object disappears from the stack to prevent the members from being GC'd.
|
||||
Object* iterator_to_object(VM& vm, IteratorRecord iterator)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto object = Object::create(realm, nullptr);
|
||||
object->define_direct_property(vm.names.iterator, iterator.iterator, 0);
|
||||
object->define_direct_property(vm.names.next, iterator.next_method, 0);
|
||||
object->define_direct_property(vm.names.done, Value(iterator.done), 0);
|
||||
return object;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user