blob: a369a6c53a344db72b942adba896d1e2c16c5f3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/*
* Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Bytecode/StringTable.h>
namespace JS::Bytecode {
StringTableIndex StringTable::insert(DeprecatedString string)
{
for (size_t i = 0; i < m_strings.size(); i++) {
if (m_strings[i] == string)
return i;
}
m_strings.append(move(string));
return m_strings.size() - 1;
}
DeprecatedString const& StringTable::get(StringTableIndex index) const
{
return m_strings[index.value()];
}
void StringTable::dump() const
{
outln("String Table:");
for (size_t i = 0; i < m_strings.size(); i++)
outln("{}: {}", i, m_strings[i]);
}
}
|