10 m_storage(storage), m_start(start), m_size(0), m_min_id(
MaxValue16Bits), m_max_id(0)
20 m_storage[m_start + m_size] = std::make_pair(
id, std::move(val));
31 m_storage[m_start + m_size] = std::make_pair(
id, val);
37 const std::size_t offset_by = values.size();
41 for (std::size_t i = 0; i < m_size; ++i)
45 assert(m_storage[m_start + m_size - i - 1].second.valueType() !=
ValueType::Reference &&
"References can not be moved around!");
46 m_storage[m_start + m_size - i + offset_by - 1] = m_storage[m_start + m_size - i - 1];
50 for (
const pair_t& pair : values)
52 const uint16_t
id = pair.first;
58 m_storage[m_start + i] = pair;
67 return m_min_id <=
id &&
id <= m_max_id;
72 if (!maybeHas(id_to_look_for))
75 for (std::size_t i = m_start; i < m_start + m_size; ++i)
77 auto& [id, value] = m_storage[i];
78 if (
id == id_to_look_for)
86 if (!maybeHas(id_to_look_for))
89 for (std::size_t i = m_start; i < m_start + m_size; ++i)
91 auto& [id, value] = m_storage[i];
92 if (
id == id_to_look_for)
100 for (std::size_t i = m_start; i < m_start + m_size; ++i)
102 const auto& [id, value] = m_storage[i];
120 return A.m_size == B.m_size && A.m_start == B.m_start;
Constants used by ArkScript.
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.
void insertFront(const std::vector< pair_t > &values) noexcept
Insert one or more pairs at the beginning of the scope.
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 pushBack(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)
constexpr uint16_t MaxValue16Bits