Array.h 1000 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@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 Array : public Object {
  10. JS_OBJECT(Array, Object);
  11. public:
  12. static Array* create(GlobalObject&, size_t length, Object* prototype = nullptr);
  13. static Array* create_from(GlobalObject&, Vector<Value> const&);
  14. explicit Array(Object& prototype);
  15. virtual ~Array() override;
  16. virtual Optional<PropertyDescriptor> internal_get_own_property(PropertyName const&) const override;
  17. virtual bool internal_define_own_property(PropertyName const&, PropertyDescriptor const&) override;
  18. virtual bool internal_delete(PropertyName const&) override;
  19. virtual MarkedValueList internal_own_property_keys() const override;
  20. [[nodiscard]] bool length_is_writable() const { return m_length_writable; };
  21. private:
  22. bool set_length(PropertyDescriptor const&);
  23. bool m_length_writable { true };
  24. };
  25. }