ArrayIterator.cpp 799 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/ArrayIterator.h>
  7. #include <LibJS/Runtime/GlobalObject.h>
  8. namespace JS {
  9. NonnullGCPtr<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
  10. {
  11. return realm.heap().allocate<ArrayIterator>(realm, array, iteration_kind, realm.intrinsics().array_iterator_prototype());
  12. }
  13. ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)
  14. : Object(ConstructWithPrototypeTag::Tag, prototype)
  15. , m_array(array)
  16. , m_iteration_kind(iteration_kind)
  17. {
  18. }
  19. void ArrayIterator::visit_edges(Cell::Visitor& visitor)
  20. {
  21. Base::visit_edges(visitor);
  22. visitor.visit(m_array);
  23. }
  24. }