8 m_min_id(std::numeric_limits<uint16_t>::max()), m_max_id(0)
15 for (
auto& [
id, val] :
m_data)
31 m_data.emplace_back(
id, std::move(val));
41 m_data.emplace_back(
id, val);
46 return m_min_id <=
id &&
id <= m_max_id && operator[](
id) !=
nullptr;
51 for (
auto& [
id, value] : m_data)
53 if (
id == id_to_look_for)
61 for (
const auto& [
id, value] : m_data)
63 if (
id == id_to_look_for)
71 for (
const auto& [
id, data] : m_data)
76 return std::numeric_limits<uint16_t>::max();
86 const std::size_t size = A.size();
89 if (A.m_min_id != B.m_min_id || A.m_max_id != B.m_max_id)
93 for (std::size_t i = 0; i < size; ++i)
95 if (A.m_data[i] != B.m_data[i])
The virtual machine scope system.
A class to handle the VM scope more efficiently.
void mergeRefInto(Scope &other)
Merge values from this scope as refs in the other scope.
bool has(uint16_t id) noexcept
Check if the scope has a specific symbol in memory.
std::vector< std::pair< uint16_t, Value > > m_data
void push_back(uint16_t id, Value &&val) noexcept
Put a value in the scope.
uint16_t idFromValue(const Value &val) const noexcept
Get the id of a variable based on its value ; used for debug only.
Value * operator[](uint16_t id_to_look_for) noexcept
Get a value from its symbol id.
std::size_t size() const noexcept
Return the size of the scope.
Scope() noexcept
Construct a new Scope object.
bool operator==(const Namespace &A, const Namespace &B)