ArrayIterator.h 924 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. JS_DECLARE_ALLOCATOR(ArrayIterator);
  12. public:
  13. static NonnullGCPtr<ArrayIterator> create(Realm&, Value array, Object::PropertyKind iteration_kind);
  14. virtual ~ArrayIterator() override = default;
  15. Value array() const { return m_array; }
  16. Object::PropertyKind iteration_kind() const { return m_iteration_kind; }
  17. size_t index() const { return m_index; }
  18. private:
  19. friend class ArrayIteratorPrototype;
  20. ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype);
  21. virtual void visit_edges(Cell::Visitor&) override;
  22. Value m_array;
  23. Object::PropertyKind m_iteration_kind;
  24. size_t m_index { 0 };
  25. };
  26. }