ArrayIterator.h 883 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/Object.h>
  8. namespace JS {
  9. class ArrayIterator final : public Object {
  10. JS_OBJECT(ArrayIterator, Object);
  11. public:
  12. static NonnullGCPtr<ArrayIterator> create(Realm&, Value array, Object::PropertyKind iteration_kind);
  13. virtual ~ArrayIterator() override = default;
  14. Value array() const { return m_array; }
  15. Object::PropertyKind iteration_kind() const { return m_iteration_kind; }
  16. size_t index() const { return m_index; }
  17. private:
  18. friend class ArrayIteratorPrototype;
  19. ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype);
  20. virtual void visit_edges(Cell::Visitor&) override;
  21. Value m_array;
  22. Object::PropertyKind m_iteration_kind;
  23. size_t m_index { 0 };
  24. };
  25. }