Files
ladybird/Libraries/LibJS/Runtime/Symbol.h
Andreas Kling 277551c40f LibJS: Account promise storage as external memory
Add shared helpers for estimating external string and container storage.
Use them for symbols, bound function arguments, promise reactions,
and promise combinator value lists.
2026-05-07 10:03:09 +02:00

42 lines
970 B
C++

/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Utf16String.h>
#include <LibGC/CellAllocator.h>
#include <LibJS/Export.h>
#include <LibJS/Heap/Cell.h>
namespace JS {
class JS_API Symbol final : public Cell {
GC_CELL(Symbol, Cell);
GC_DECLARE_ALLOCATOR(Symbol);
public:
[[nodiscard]] static GC::Ref<Symbol> create(VM&, Optional<Utf16String> description, bool is_global);
virtual ~Symbol() = default;
Optional<Utf16String> const& description() const { return m_description; }
bool is_global() const { return m_is_global; }
Utf16String descriptive_string() const;
Optional<Utf16String> key() const;
private:
virtual size_t external_memory_size() const override;
Symbol(Optional<Utf16String>, bool);
Optional<Utf16String> m_description;
bool m_is_global;
};
}