From 661dbbc83d34abdddc91a34ba41dfa86ce178f15 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Sun, 29 Oct 2023 16:01:25 +0100 Subject: [PATCH] LibJS/Bytecode: Move object_to_iterator to CommonImplementations --- .../Libraries/LibJS/Bytecode/CommonImplementations.cpp | 9 +++++++++ .../Libraries/LibJS/Bytecode/CommonImplementations.h | 1 + Userland/Libraries/LibJS/Bytecode/Interpreter.cpp | 9 --------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp index c902cdc38f..ee8f9bcfa3 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 f8ee84bec6..bdef78d9bd 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 69d8cf8557..62a5812e80 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();