MapIterator.cpp 865 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/GlobalObject.h>
  7. #include <LibJS/Runtime/MapIterator.h>
  8. namespace JS {
  9. JS_DEFINE_ALLOCATOR(MapIterator);
  10. NonnullGCPtr<MapIterator> MapIterator::create(Realm& realm, Map& map, Object::PropertyKind iteration_kind)
  11. {
  12. return realm.heap().allocate<MapIterator>(realm, map, iteration_kind, realm.intrinsics().map_iterator_prototype());
  13. }
  14. MapIterator::MapIterator(Map& map, Object::PropertyKind iteration_kind, Object& prototype)
  15. : Object(ConstructWithPrototypeTag::Tag, prototype)
  16. , m_map(map)
  17. , m_iteration_kind(iteration_kind)
  18. , m_iterator(static_cast<Map const&>(map).begin())
  19. {
  20. }
  21. void MapIterator::visit_edges(Cell::Visitor& visitor)
  22. {
  23. Base::visit_edges(visitor);
  24. visitor.visit(m_map);
  25. }
  26. }