2020-04-29 23:25:21 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2023-02-11 15:51:44 +00:00
|
|
|
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
2020-04-29 23:25:21 -07:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-29 23:25:21 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-02-11 16:14:41 +00:00
|
|
|
#include <AK/String.h>
|
2025-05-15 17:14:00 +03:00
|
|
|
#include <LibGC/CellAllocator.h>
|
2025-07-19 13:49:30 -07:00
|
|
|
#include <LibJS/Export.h>
|
2021-05-17 19:50:20 +02:00
|
|
|
#include <LibJS/Heap/Cell.h>
|
2020-04-29 23:25:21 -07:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2025-07-19 13:49:30 -07:00
|
|
|
class JS_API Symbol final : public Cell {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(Symbol, Cell);
|
|
|
|
GC_DECLARE_ALLOCATOR(Symbol);
|
2020-07-06 16:57:22 -07:00
|
|
|
|
2020-04-29 23:25:21 -07:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<Symbol> create(VM&, Optional<String> description, bool is_global);
|
2022-12-06 22:25:43 +00:00
|
|
|
|
2022-03-14 10:25:06 -06:00
|
|
|
virtual ~Symbol() = default;
|
2020-04-29 23:25:21 -07:00
|
|
|
|
2023-02-11 16:14:41 +00:00
|
|
|
Optional<String> const& description() const { return m_description; }
|
2020-04-29 23:25:21 -07:00
|
|
|
bool is_global() const { return m_is_global; }
|
2023-02-11 15:51:44 +00:00
|
|
|
|
2023-02-11 16:14:41 +00:00
|
|
|
ErrorOr<String> descriptive_string() const;
|
2023-04-12 23:12:54 +02:00
|
|
|
Optional<String> key() const;
|
2020-04-29 23:25:21 -07:00
|
|
|
|
|
|
|
private:
|
2023-02-11 16:14:41 +00:00
|
|
|
Symbol(Optional<String>, bool);
|
2022-08-28 23:51:28 +02:00
|
|
|
|
2023-02-11 16:14:41 +00:00
|
|
|
Optional<String> m_description;
|
2020-07-07 21:38:46 -07:00
|
|
|
bool m_is_global;
|
2020-04-29 23:25:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|