/src/serenity/Userland/Libraries/LibJS/Bytecode/StringTable.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/ByteString.h> |
10 | | #include <AK/DistinctNumeric.h> |
11 | | #include <AK/Vector.h> |
12 | | |
13 | | namespace JS::Bytecode { |
14 | | |
15 | | AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(u32, StringTableIndex, Comparison); |
16 | | |
17 | | class StringTable { |
18 | | AK_MAKE_NONMOVABLE(StringTable); |
19 | | AK_MAKE_NONCOPYABLE(StringTable); |
20 | | |
21 | | public: |
22 | 23 | StringTable() = default; |
23 | | |
24 | | StringTableIndex insert(ByteString); |
25 | | ByteString const& get(StringTableIndex) const; |
26 | | void dump() const; |
27 | 0 | bool is_empty() const { return m_strings.is_empty(); } |
28 | | |
29 | | private: |
30 | | Vector<ByteString> m_strings; |
31 | | }; |
32 | | |
33 | | } |