85template <
typename Key,
typename Value>
86 requires std::equality_comparable<Key>
110 for (
size_t i = bindings.size(); i > 0; --i)
111 if (bindings.access(i - 1).key == key)
112 return &bindings.access(i - 1).value;
118 for (
size_t i = bindings.size(); i > 0; --i)
119 if (bindings.access(i - 1).key == key)
120 return &bindings.access(i - 1).value;
218 if (
find_value(frame.bindings, key) !=
nullptr)
220 frame.bindings.append({key,
value});
232 if (
find_value(frame.bindings, key) !=
nullptr)
234 frame.bindings.append({std::move(key), std::move(
value)});
273 for (
size_t i =
frames.size(); i > 0; --i)
282 for (
size_t i =
frames.size(); i > 0; --i)
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_unless(C)
Throws std::runtime_error if condition does NOT hold.
size_t size_t int32_t value
Lexical scope stack for Key to Value associations.
void clear() noexcept
Resets the structure by removing all frames and bindings.
size_t enter_scope()
Creates a new visibility level.
static const Value * find_value(const DynArray< Binding > &bindings, const Key &key) noexcept
Value * lookup(const Key &key) noexcept
Searches for a key traversing all active scopes (from inside out).
bool empty() const noexcept
Indicates if the structure is empty of frames.
bool insert(const Key &key, const Value &value)
Registers a new association in the current scope.
const Value * lookup_local(const Key &key) const noexcept
Constant version of lookup_local().
Value * lookup_local(const Key &key) noexcept
Searches for a key only in the innermost (current) scope.
void leave_scope()
Destroys the current visibility level and all its associations.
Scope()=default
Default constructor.
bool insert(Key &&key, Value &&value)
Move version of insert().
const Frame & current_frame() const
const Value * lookup(const Key &key) const noexcept
Constant version of lookup().
size_t depth() const noexcept
Queries the current depth of the scope stack.
static Value * find_value(DynArray< Binding > &bindings, const Key &key) noexcept
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
@ Value
Regular runtime payload stored as Interpreter_Value.
Individual entry in a lexical frame.
Key key
Search key (e.g., variable name).
Value value
Associated value (e.g., type or address).
DynArray< Binding > bindings
Lazy and scalable dynamic array implementation.