/src/serenity/Userland/Libraries/LibJS/Runtime/ArrayIterator.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibJS/Runtime/Object.h> |
10 | | |
11 | | namespace JS { |
12 | | |
13 | | class ArrayIterator final : public Object { |
14 | | JS_OBJECT(ArrayIterator, Object); |
15 | | JS_DECLARE_ALLOCATOR(ArrayIterator); |
16 | | |
17 | | public: |
18 | | static NonnullGCPtr<ArrayIterator> create(Realm&, Value array, Object::PropertyKind iteration_kind); |
19 | | |
20 | | virtual ~ArrayIterator() override = default; |
21 | | |
22 | 0 | Value array() const { return m_array; } |
23 | 0 | Object::PropertyKind iteration_kind() const { return m_iteration_kind; } |
24 | 0 | size_t index() const { return m_index; } |
25 | | |
26 | | private: |
27 | | friend class ArrayIteratorPrototype; |
28 | | |
29 | | ArrayIterator(Value array, Object::PropertyKind iteration_kind, Object& prototype); |
30 | | |
31 | 0 | virtual bool is_array_iterator() const override { return true; } |
32 | | virtual void visit_edges(Cell::Visitor&) override; |
33 | | |
34 | | Value m_array; |
35 | | Object::PropertyKind m_iteration_kind; |
36 | | size_t m_index { 0 }; |
37 | | }; |
38 | | |
39 | | template<> |
40 | 0 | inline bool Object::fast_is<ArrayIterator>() const { return is_array_iterator(); } |
41 | | |
42 | | } |