SetIterator.cpp 830 B

12345678910111213141516171819202122232425262728293031
  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/SetIterator.h>
  8. namespace JS {
  9. NonnullGCPtr<SetIterator> SetIterator::create(Realm& realm, Set& set, Object::PropertyKind iteration_kind)
  10. {
  11. return realm.heap().allocate<SetIterator>(realm, set, iteration_kind, realm.intrinsics().set_iterator_prototype());
  12. }
  13. SetIterator::SetIterator(Set& set, Object::PropertyKind iteration_kind, Object& prototype)
  14. : Object(ConstructWithPrototypeTag::Tag, prototype)
  15. , m_set(set)
  16. , m_iteration_kind(iteration_kind)
  17. , m_iterator(static_cast<Set const&>(set).begin())
  18. {
  19. }
  20. void SetIterator::visit_edges(Cell::Visitor& visitor)
  21. {
  22. Base::visit_edges(visitor);
  23. visitor.visit(m_set);
  24. }
  25. }