2021-10-24 13:34:30 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
|
2021-10-24 13:34:30 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-01-09 00:23:00 +00:00
|
|
|
#include <AK/DeprecatedFlyString.h>
|
2021-10-24 13:34:30 +00:00
|
|
|
#include <AK/DistinctNumeric.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
|
2024-05-06 08:12:02 +00:00
|
|
|
struct IdentifierTableIndex {
|
|
|
|
bool is_valid() const { return value != NumericLimits<u32>::max(); }
|
|
|
|
u32 value { 0 };
|
|
|
|
};
|
2021-10-24 13:34:30 +00:00
|
|
|
|
|
|
|
class IdentifierTable {
|
|
|
|
AK_MAKE_NONMOVABLE(IdentifierTable);
|
|
|
|
AK_MAKE_NONCOPYABLE(IdentifierTable);
|
|
|
|
|
|
|
|
public:
|
|
|
|
IdentifierTable() = default;
|
|
|
|
|
2023-01-09 00:23:00 +00:00
|
|
|
IdentifierTableIndex insert(DeprecatedFlyString);
|
|
|
|
DeprecatedFlyString const& get(IdentifierTableIndex) const;
|
2021-10-24 13:34:30 +00:00
|
|
|
void dump() const;
|
|
|
|
bool is_empty() const { return m_identifiers.is_empty(); }
|
|
|
|
|
|
|
|
private:
|
2023-01-09 00:23:00 +00:00
|
|
|
Vector<DeprecatedFlyString> m_identifiers;
|
2021-10-24 13:34:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|