2021-06-09 08:02:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
#include <AK/ByteString.h>
|
2021-06-09 08:02:01 +00:00
|
|
|
#include <AK/DistinctNumeric.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
|
2024-05-10 05:12:45 +00:00
|
|
|
AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u32, StringTableIndex, Comparison);
|
2021-06-09 08:02:01 +00:00
|
|
|
|
|
|
|
class StringTable {
|
|
|
|
AK_MAKE_NONMOVABLE(StringTable);
|
|
|
|
AK_MAKE_NONCOPYABLE(StringTable);
|
|
|
|
|
|
|
|
public:
|
|
|
|
StringTable() = default;
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
StringTableIndex insert(ByteString);
|
|
|
|
ByteString const& get(StringTableIndex) const;
|
2021-06-09 08:02:01 +00:00
|
|
|
void dump() const;
|
|
|
|
bool is_empty() const { return m_strings.is_empty(); }
|
|
|
|
|
|
|
|
private:
|
2023-12-16 14:19:34 +00:00
|
|
|
Vector<ByteString> m_strings;
|
2021-06-09 08:02:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|