2020-04-29 23:25:21 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@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
|
|
|
|
|
|
|
|
#include <AK/String.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 {
|
2020-08-26 21:52:24 +02:00
|
|
|
AK_MAKE_NONCOPYABLE(Symbol);
|
|
|
|
AK_MAKE_NONMOVABLE(Symbol);
|
2020-07-06 16:57:22 -07:00
|
|
|
|
2020-04-29 23:25:21 -07:00
|
|
|
public:
|
2021-06-15 02:40:55 +03:00
|
|
|
Symbol(Optional<String>, bool);
|
2020-04-29 23:25:21 -07:00
|
|
|
virtual ~Symbol();
|
|
|
|
|
2021-06-15 02:40:55 +03:00
|
|
|
String description() const { return m_description.value_or(""); }
|
|
|
|
const Optional<String>& raw_description() const { return m_description; }
|
2020-04-29 23:25:21 -07:00
|
|
|
bool is_global() const { return m_is_global; }
|
2020-10-04 15:18:12 +01:00
|
|
|
String to_string() const { return String::formatted("Symbol({})", description()); }
|
2020-04-29 23:25:21 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual const char* class_name() const override { return "Symbol"; }
|
|
|
|
|
2021-06-15 02:40:55 +03: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
|
|
|
};
|
|
|
|
|
2021-06-15 02:40:55 +03:00
|
|
|
Symbol* js_symbol(Heap&, Optional<String> description, bool is_global);
|
|
|
|
Symbol* js_symbol(VM&, Optional<String> description, bool is_global);
|
2020-04-29 23:25:21 -07:00
|
|
|
|
|
|
|
}
|