8 m_storage(storage), m_start(start), m_size(0), m_min_id(std::numeric_limits<uint16_t>::max()), m_max_id(0)
18 m_storage[m_start + m_size] = std::make_pair(
id, std::move(val));
29 m_storage[m_start + m_size] = std::make_pair(
id, val);
35 return m_min_id <=
id &&
id <= m_max_id;
40 if (!maybeHas(id_to_look_for))
43 for (std::size_t i = m_start; i < m_start + m_size; ++i)
45 auto& [id, value] = m_storage[i];
46 if (
id == id_to_look_for)
54 if (!maybeHas(id_to_look_for))
57 for (std::size_t i = m_start; i < m_start + m_size; ++i)
59 auto& [id, value] = m_storage[i];
60 if (
id == id_to_look_for)
68 for (std::size_t i = m_start; i < m_start + m_size; ++i)
70 const auto& [id, value] = m_storage[i];
74 return std::numeric_limits<uint16_t>::max();
80 m_min_id = std::numeric_limits<uint16_t>::max();
88 return A.m_size == B.m_size && A.m_start == B.m_start;
A class to handle the VM scope more efficiently.
ScopeView()=delete
Deleted constructor to avoid creating ScopeViews pointing to nothing. Helps catch bugs at compile tim...
bool maybeHas(uint16_t id) const noexcept
Check if the scope maybe holds a specific symbol in memory.
uint16_t m_max_id
Maximum stored ID, used for a basic bloom filter.
std::pair< uint16_t, Value > pair_t
Value * operator[](uint16_t id_to_look_for) noexcept
Get a value from its symbol id.
void push_back(uint16_t id, Value &&val) noexcept
Put a value in the scope.
void reset() noexcept
Reset size, min and max id for the scope, to signify it's empty.
uint16_t m_min_id
Minimum stored ID, used for a basic bloom filter.
uint16_t idFromValue(const Value &val) const noexcept
Get the id of a variable based on its value ; used for debug only.
bool operator==(const Namespace &A, const Namespace &B)