diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp index c902cdc38f2..ee8f9bcfa30 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp @@ -535,4 +535,13 @@ Object* iterator_to_object(VM& vm, IteratorRecord iterator) return object; } +IteratorRecord object_to_iterator(VM& vm, Object& object) +{ + return IteratorRecord { + .iterator = &MUST(object.get(vm.names.iterator)).as_object(), + .next_method = MUST(object.get(vm.names.next)), + .done = MUST(object.get(vm.names.done)).as_bool() + }; +} + } diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h index f8ee84bec66..bdef78d9bd5 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h @@ -36,5 +36,6 @@ ThrowCompletionOr create_variable(VM&, DeprecatedFlyString const& name, Op ThrowCompletionOr new_class(VM&, ClassExpression const&, Optional const& lhs_name); ThrowCompletionOr> super_call_with_argument_array(VM&, Value argument_array, bool is_synthetic); Object* iterator_to_object(VM&, IteratorRecord); +IteratorRecord object_to_iterator(VM&, Object&); } diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 69d8cf85573..62a5812e80b 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -645,15 +645,6 @@ ThrowCompletionOr ImportCall::execute_impl(Bytecode::Interpreter& interpre return {}; } -static IteratorRecord object_to_iterator(VM& vm, Object& object) -{ - return IteratorRecord { - .iterator = &MUST(object.get(vm.names.iterator)).as_object(), - .next_method = MUST(object.get(vm.names.next)), - .done = MUST(object.get(vm.names.done)).as_bool() - }; -} - ThrowCompletionOr IteratorToArray::execute_impl(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm();