14 m_data.emplace_back(std::move(
id), std::move(val));
19 m_data.emplace_back(
id, val);
24 return operator[](
id) !=
nullptr;
29 for (std::size_t i = 0, end = m_data.size(); i < end; ++i)
31 if (m_data[i].first ==
id)
32 return &m_data[i].second;
39 for (std::size_t i = 0, end = m_data.size(); i < end; ++i)
41 if (m_data[i].second == val)
42 return m_data[i].first;
44 return std::numeric_limits<uint16_t>::max();
The virtual machine scope system.
Value * operator[](uint16_t id) noexcept
Get a value from its symbol id.
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.
std::size_t size() const noexcept
Return the size of the scope.
Scope() noexcept
Construct a new Scope object.