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 {
|
|
|
|
|
2022-12-13 20:49:50 +00:00
|
|
|
NonnullGCPtr<MapIterator> MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind)
|
2021-06-12 20:58:03 +00:00
|
|
|
{
|
2023-08-13 11:05:26 +00:00
|
|
|
return realm.heap().allocate<MapIterator>(realm, 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
|
|
|
}
|
|
|
|
|
|
|
|
}
|