2020-04-29 23:25:21 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2022-12-06 22:25:43 +00:00
|
|
|
* Copyright (c) 2022, 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
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2022-03-16 18:26:49 -06:00
|
|
|
#include <AK/StringView.h>
|
2021-05-17 19:50:20 +02:00
|
|
|
#include <LibJS/Heap/Cell.h>
|
2020-04-29 23:25:21 -07:00
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
|
|
class Symbol final : public Cell {
|
2022-08-28 22:11:20 +02:00
|
|
|
JS_CELL(Symbol, Cell);
|
2020-07-06 16:57:22 -07:00
|
|
|
|
2020-04-29 23:25:21 -07:00
|
|
|
public:
|
2022-12-06 22:25:43 +00:00
|
|
|
[[nodiscard]] static NonnullGCPtr<Symbol> create(VM&, Optional<DeprecatedString> description, bool is_global);
|
|
|
|
|
|
2022-03-14 10:25:06 -06:00
|
|
|
virtual ~Symbol() = default;
|
2020-04-29 23:25:21 -07:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString description() const { return m_description.value_or(""); }
|
|
|
|
|
Optional<DeprecatedString> const& raw_description() const { return m_description; }
|
2020-04-29 23:25:21 -07:00
|
|
|
bool is_global() const { return m_is_global; }
|
2022-12-06 01:12:49 +00:00
|
|
|
DeprecatedString to_deprecated_string() const { return DeprecatedString::formatted("Symbol({})", description()); }
|
2020-04-29 23:25:21 -07:00
|
|
|
|
|
|
|
|
private:
|
2022-12-04 18:02:33 +00:00
|
|
|
Symbol(Optional<DeprecatedString>, bool);
|
2022-08-28 23:51:28 +02:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
Optional<DeprecatedString> m_description;
|
2020-07-07 21:38:46 -07:00
|
|
|
bool m_is_global;
|
2020-04-29 23:25:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|