2020-07-09 18:58:20 -03:00
|
|
|
/*
|
2021-04-22 20:53:07 -03:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2020-07-09 18:58:20 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-09 18:58:20 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/ArrayIterator.h>
|
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(ArrayIterator);
|
2023-11-19 05:45:05 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
|
2020-07-09 18:58:20 -03:00
|
|
|
{
|
2024-11-13 13:50:17 -03:00
|
|
|
return realm.create<ArrayIterator>(array, iteration_kind, realm.intrinsics().array_iterator_prototype());
|
2020-07-09 18:58:20 -03:00
|
|
|
}
|
|
|
|
|
|
2021-06-19 19:21:08 -03:00
|
|
|
ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)
|
2022-12-14 08:17:58 -03:00
|
|
|
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
2020-07-09 18:58:20 -03:00
|
|
|
, m_array(array)
|
|
|
|
|
, m_iteration_kind(iteration_kind)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-28 10:33:36 -03:00
|
|
|
void ArrayIterator::visit_edges(Cell::Visitor& visitor)
|
2020-09-08 11:20:13 -03:00
|
|
|
{
|
2020-11-28 10:33:36 -03:00
|
|
|
Base::visit_edges(visitor);
|
2020-09-08 11:20:13 -03:00
|
|
|
visitor.visit(m_array);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-09 18:58:20 -03:00
|
|
|
}
|