ArrayIterator.cpp 815 B

1234567891011121314151617181920212223242526272829303132
  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. GC_DEFINE_ALLOCATOR(ArrayIterator);
  10. GC::Ref<ArrayIterator> ArrayIterator::create(Realm& realm, Value array, Object::PropertyKind iteration_kind)
  11. {
  12. return realm.create<ArrayIterator>(array, iteration_kind, realm.intrinsics().array_iterator_prototype());
  13. }
  14. ArrayIterator::ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype)
  15. : Object(ConstructWithPrototypeTag::Tag, prototype)
  16. , m_array(array)
  17. , m_iteration_kind(iteration_kind)
  18. {
  19. }
  20. void ArrayIterator::visit_edges(Cell::Visitor& visitor)
  21. {
  22. Base::visit_edges(visitor);
  23. visitor.visit(m_array);
  24. }
  25. }