/* * Copyright (c) 2026-present, the Ladybird developers. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace JS::Bytecode { class JS_API PropertyNameIterator final : public Object , public BuiltinIterator { JS_OBJECT(PropertyNameIterator, Object); GC_DECLARE_ALLOCATOR(PropertyNameIterator); public: using FastPath = ObjectPropertyIteratorFastPath; static GC::Ref create(Realm&, GC::Ref, Vector, FastPath = FastPath::None, u32 indexed_property_count = 0, GC::Ptr = nullptr, GC::Ptr = nullptr); static GC::Ref create(Realm&, GC::Ref, ObjectPropertyIteratorCacheData&, ObjectPropertyIteratorCache* = nullptr); virtual ~PropertyNameIterator() override = default; BuiltinIterator* as_builtin_iterator_if_next_is_not_redefined(Value) override { return this; } ThrowCompletionOr next(VM&, bool& done, Value& value) override; void reset_with_cache_data(GC::Ref, ObjectPropertyIteratorCacheData&, ObjectPropertyIteratorCache*); private: PropertyNameIterator(Realm&, GC::Ref, Vector, FastPath, u32 indexed_property_count, GC::Ptr, GC::Ptr); PropertyNameIterator(Realm&, GC::Ref, ObjectPropertyIteratorCacheData&, ObjectPropertyIteratorCache*); ReadonlySpan property_list() const; ReadonlySpan property_value_list() const; bool fast_path_still_valid() const; void disable_fast_path(); virtual void visit_edges(Visitor&) override; GC::Ptr m_object; Vector m_owned_properties; GC::Ptr m_property_cache; GC::Ptr m_shape; GC::Ptr m_prototype_chain_validity; ObjectPropertyIteratorCache* m_iterator_cache_slot { nullptr }; u32 m_indexed_property_count { 0 }; u32 m_next_indexed_property { 0 }; size_t m_next_property { 0 }; bool m_shape_is_dictionary { false }; u32 m_shape_dictionary_generation { 0 }; FastPath m_fast_path { FastPath::None }; }; }