|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Nested runtime environment with lexical lookup semantics. More...
#include <Interpreter_Runtime.H>
Public Member Functions | |
| Interpreter_Environment (Interpreter_Environment *parent=nullptr) noexcept | |
| Builds an environment with optional lexical parent. | |
| void | set_parent (Interpreter_Environment *parent) noexcept |
| Changes the lexical parent for this environment. | |
| Interpreter_Environment * | parent () const noexcept |
| Returns the lexical parent, if any. | |
| void | clear () noexcept |
| Drops all bindings from this environment only. | |
| bool | is_empty () const noexcept |
| Returns whether this environment is empty. | |
| size_t | size () const noexcept |
| Returns the number of bindings in this environment. | |
| const DynArray< Interpreter_Binding > & | bindings () const noexcept |
| Returns read-only access to the local bindings. | |
| bool | define (const std::string &name, const Interpreter_Value &value) |
| Defines one local binding. | |
| Interpreter_Value * | lookup (const std::string &name) noexcept |
| Finds a visible binding recursively. | |
| const Interpreter_Value * | lookup (const std::string &name) const noexcept |
| Finds a visible binding recursively. | |
| bool | assign (const std::string &name, const Interpreter_Value &value) |
| Assigns an existing visible binding. | |
Private Member Functions | |
| Interpreter_Value * | find_local (const std::string &name) noexcept |
| const Interpreter_Value * | find_local (const std::string &name) const noexcept |
Private Attributes | |
| Interpreter_Environment * | parent_env = nullptr |
| DynArray< Interpreter_Binding > | bindings_ |
Nested runtime environment with lexical lookup semantics.
Definition at line 576 of file Interpreter_Runtime.H.
|
inlineexplicitnoexcept |
Builds an environment with optional lexical parent.
Definition at line 599 of file Interpreter_Runtime.H.
|
inline |
Assigns an existing visible binding.
| name | Binding name to update. |
| value | New runtime value. |
true if a visible binding was updated. Definition at line 687 of file Interpreter_Runtime.H.
References assign(), Aleph::blossom_maximum_cardinality_matching(), find_local(), parent_env, and value.
Referenced by assign().
|
inlinenoexcept |
Returns read-only access to the local bindings.
The bindings are stored in insertion order, which keeps dumps deterministic.
Definition at line 638 of file Interpreter_Runtime.H.
References bindings_.
|
inlinenoexcept |
Drops all bindings from this environment only.
Definition at line 616 of file Interpreter_Runtime.H.
References bindings_.
Referenced by Aleph::Interpreter_Runtime::reset().
|
inline |
Defines one local binding.
| name | New binding name. |
| value | Runtime value to store. |
false if name already exists in this environment. Definition at line 649 of file Interpreter_Runtime.H.
References bindings_, find_local(), and value.
Referenced by Aleph::Interpreter_Runtime::bind_host_function(), Aleph::Interpreter_Runtime::call_hir_function(), and Aleph::Interpreter_Runtime::install_module_function().
|
inlineprivatenoexcept |
Definition at line 589 of file Interpreter_Runtime.H.
References bindings_.
|
inlineprivatenoexcept |
|
inlinenoexcept |
Returns whether this environment is empty.
Definition at line 622 of file Interpreter_Runtime.H.
References bindings_.
|
inlinenoexcept |
Finds a visible binding recursively.
| name | Binding name to resolve. |
nullptr. Definition at line 674 of file Interpreter_Runtime.H.
References find_local(), lookup(), parent_env, and value.
|
inlinenoexcept |
Finds a visible binding recursively.
| name | Binding name to resolve. |
nullptr. Definition at line 662 of file Interpreter_Runtime.H.
References find_local(), lookup(), parent_env, and value.
Referenced by Aleph::Interpreter_Runtime::call(), lookup(), and lookup().
|
inlinenoexcept |
Returns the lexical parent, if any.
Definition at line 610 of file Interpreter_Runtime.H.
References parent_env.
Referenced by set_parent().
|
inlinenoexcept |
Changes the lexical parent for this environment.
Definition at line 604 of file Interpreter_Runtime.H.
References parent(), and parent_env.
Referenced by Aleph::Interpreter_Runtime::call_hir_function(), and Aleph::Interpreter_Runtime::reset().
|
inlinenoexcept |
Returns the number of bindings in this environment.
Definition at line 628 of file Interpreter_Runtime.H.
References bindings_.
|
private |
Definition at line 579 of file Interpreter_Runtime.H.
Referenced by bindings(), clear(), define(), find_local(), find_local(), is_empty(), and size().
|
private |
Definition at line 578 of file Interpreter_Runtime.H.
Referenced by assign(), lookup(), lookup(), parent(), and set_parent().