/src/serenity/Userland/Libraries/LibJS/Runtime/StringObject.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020, Andreas Kling <kling@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 StringObject : public Object { |
14 | | JS_OBJECT(StringObject, Object); |
15 | | JS_DECLARE_ALLOCATOR(StringObject); |
16 | | |
17 | | public: |
18 | | [[nodiscard]] static NonnullGCPtr<StringObject> create(Realm&, PrimitiveString&, Object& prototype); |
19 | | |
20 | | virtual void initialize(Realm&) override; |
21 | | virtual ~StringObject() override = default; |
22 | | |
23 | 0 | PrimitiveString const& primitive_string() const { return m_string; } |
24 | 0 | PrimitiveString& primitive_string() { return m_string; } |
25 | | |
26 | | protected: |
27 | | StringObject(PrimitiveString&, Object& prototype); |
28 | | |
29 | | private: |
30 | | virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const override; |
31 | | virtual ThrowCompletionOr<bool> internal_define_own_property(PropertyKey const&, PropertyDescriptor const&, Optional<PropertyDescriptor>* precomputed_get_own_property = nullptr) override; |
32 | | virtual ThrowCompletionOr<MarkedVector<Value>> internal_own_property_keys() const override; |
33 | | |
34 | 0 | virtual bool is_string_object() const final { return true; } |
35 | | virtual void visit_edges(Visitor&) override; |
36 | | |
37 | | NonnullGCPtr<PrimitiveString> m_string; |
38 | | }; |
39 | | |
40 | | template<> |
41 | 0 | inline bool Object::fast_is<StringObject>() const { return is_string_object(); } |
42 | | |
43 | | } |