2021-06-12 20:58:03 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
#include <LibJS/Runtime/MapIterator.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2024-11-14 15:01:23 +00:00
|
|
|
GC_DEFINE_ALLOCATOR(MapIterator);
|
2023-11-19 08:45:05 +00:00
|
|
|
|
2024-11-14 15:01:23 +00:00
|
|
|
GC::Ref<MapIterator> MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind)
|
2021-06-12 20:58:03 +00:00
|
|
|
{
|
2024-11-13 16:50:17 +00:00
|
|
|
return realm.create<MapIterator>(map, iteration_kind, realm.intrinsics().map_iterator_prototype());
|
2021-06-12 20:58:03 +00:00
|
|
|
}
|
|
|
|
|
2021-06-19 22:21:08 +00:00
|
|
|
MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)
|
2022-12-14 11:17:58 +00:00
|
|
|
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
2021-06-12 20:58:03 +00:00
|
|
|
, m_map(map)
|
|
|
|
, m_iteration_kind(iteration_kind)
|
2022-02-09 13:04:52 +00:00
|
|
|
, m_iterator(static_cast<Map const&>(map).begin())
|
2021-06-12 20:58:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MapIterator::visit_edges(Cell::Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
2023-02-26 23:09:02 +00:00
|
|
|
visitor.visit(m_map);
|
2021-06-12 20:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|