ArrayIterator.h 875 B

123456789101112131415161718192021222324252627282930313233343536
  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 ArrayIterator* create(GlobalObject&, Value array, Object::PropertyKind iteration_kind);
  13. explicit ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype);
  14. virtual ~ArrayIterator() override;
  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. 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. }