Skip to content

Commit 661dbbc

Browse files
skyrisingawesomekling
authored andcommitted
LibJS/Bytecode: Move object_to_iterator to CommonImplementations
1 parent 4f8f8b7 commit 661dbbc

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,4 +535,13 @@ Object* iterator_to_object(VM& vm, IteratorRecord iterator)
535535
return object;
536536
}
537537

538+
IteratorRecord object_to_iterator(VM& vm, Object& object)
539+
{
540+
return IteratorRecord {
541+
.iterator = &MUST(object.get(vm.names.iterator)).as_object(),
542+
.next_method = MUST(object.get(vm.names.next)),
543+
.done = MUST(object.get(vm.names.done)).as_bool()
544+
};
545+
}
546+
538547
}

Userland/Libraries/LibJS/Bytecode/CommonImplementations.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ ThrowCompletionOr<void> create_variable(VM&, DeprecatedFlyString const& name, Op
3636
ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM&, ClassExpression const&, Optional<IdentifierTableIndex> const& lhs_name);
3737
ThrowCompletionOr<NonnullGCPtr<Object>> super_call_with_argument_array(VM&, Value argument_array, bool is_synthetic);
3838
Object* iterator_to_object(VM&, IteratorRecord);
39+
IteratorRecord object_to_iterator(VM&, Object&);
3940

4041
}

Userland/Libraries/LibJS/Bytecode/Interpreter.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,6 @@ ThrowCompletionOr<void> ImportCall::execute_impl(Bytecode::Interpreter& interpre
645645
return {};
646646
}
647647

648-
static IteratorRecord object_to_iterator(VM& vm, Object& object)
649-
{
650-
return IteratorRecord {
651-
.iterator = &MUST(object.get(vm.names.iterator)).as_object(),
652-
.next_method = MUST(object.get(vm.names.next)),
653-
.done = MUST(object.get(vm.names.done)).as_bool()
654-
};
655-
}
656-
657648
ThrowCompletionOr<void> IteratorToArray::execute_impl(Bytecode::Interpreter& interpreter) const
658649
{
659650
auto& vm = interpreter.vm();

0 commit comments

Comments
 (0)