|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
One runtime value. More...
#include <Interpreter_Runtime.H>
Public Member Functions | |
| Interpreter_Value ()=default | |
| Builds a fresh value with no tuple storage. | |
| Interpreter_Value (const Interpreter_Value &other) | |
| Deep-copies one runtime value. | |
| Interpreter_Value (Interpreter_Value &&other) noexcept | |
| Moves one runtime value. | |
| ~Interpreter_Value () noexcept | |
| Releases tuple storage if present. | |
| Interpreter_Value & | operator= (const Interpreter_Value &other) |
| Assigns one runtime value by deep copy. | |
| Interpreter_Value & | operator= (Interpreter_Value &&other) noexcept |
| Assigns one runtime value by move. | |
| bool | is_unit () const noexcept |
| Returns whether this value is the Unit singleton. | |
| bool | is_callable () const noexcept |
| Returns whether this value is callable. | |
| const DynArray< Interpreter_Value > & | tuple_elements () const noexcept |
| Returns the tuple payload. | |
Static Public Member Functions | |
| static Interpreter_Value | make_invalid () |
| Builds an invalid value placeholder. | |
| static Interpreter_Value | make_unit () |
| Builds the Unit value. | |
| static Interpreter_Value | make_bool (const bool b) |
| Builds a boolean runtime value. | |
| static Interpreter_Value | make_integer (const long long i) |
| Builds an integer runtime value. | |
| static Interpreter_Value | make_string (std::string text) |
| Builds a string runtime value. | |
| static Interpreter_Value | make_character (const char ch) |
| Builds a character runtime value. | |
| static Interpreter_Value | make_tuple (const DynArray< Interpreter_Value > &elements) |
Builds a tuple runtime value by copying elements. | |
| static Interpreter_Value | make_tuple (DynArray< Interpreter_Value > &&elements) |
Builds a tuple runtime value by moving elements. | |
| static Interpreter_Value | make_function (const Compiler_HIR_Function *fn, Interpreter_Environment *env=nullptr) |
| Builds a callable value backed by HIR function code. | |
| static Interpreter_Value | make_host_function (std::string name, const Interpreter_Host_Function callback, void *user_data=nullptr) |
| Builds a callable value backed by host code. | |
Public Attributes | |
| Interpreter_Value_Kind | kind = Interpreter_Value_Kind::Invalid |
| Active value kind. | |
| bool | bool_value = false |
| Payload for Bool values. | |
| long long | integer_value = 0 |
| Payload for Int values. | |
| char | character_value = '\0' |
| Payload for Char values. | |
| std::string | string_value |
| Payload for String values. | |
| std::unique_ptr< Interpreter_Tuple_Storage > | tuple_storage |
| Payload for Tuple values. | |
| const Compiler_HIR_Function * | function = nullptr |
| Payload for HIR function values. | |
| Interpreter_Environment * | closure_environment = nullptr |
| Captured lexical parent for function values. | |
| Interpreter_Host_Function | host_function = nullptr |
| Payload for host function values. | |
| void * | host_user_data = nullptr |
| Embedding-specific payload for host functions. | |
| std::string | callable_name |
| Stable debug name for callable values. | |
One runtime value.
The representation is intentionally compact and explicit. Values can be copied freely, which keeps the MVP simple for interpreter experiments and tests.
Definition at line 190 of file Interpreter_Runtime.H.
|
default |
Builds a fresh value with no tuple storage.
|
inline |
Deep-copies one runtime value.
Definition at line 339 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), and tuple_storage.
|
inlinenoexcept |
Moves one runtime value.
Definition at line 350 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::Invalid.
|
inlinedefaultnoexcept |
Releases tuple storage if present.
|
inlinenoexcept |
Returns whether this value is callable.
Definition at line 311 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Function, Aleph::Host_Function, and kind.
|
inlinenoexcept |
Returns whether this value is the Unit singleton.
Definition at line 305 of file Interpreter_Runtime.H.
References kind, and Aleph::Unit.
|
inlinestatic |
Builds a boolean runtime value.
Definition at line 238 of file Interpreter_Runtime.H.
References Aleph::Bool, kind, and value.
Referenced by Aleph::Interpreter_Runtime::evaluate_expr(), and Aleph::Compiler_Bytecode_Value::make_bool().
|
inlinestatic |
Builds a character runtime value.
Definition at line 265 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Character, kind, and value.
Referenced by Aleph::Compiler_Bytecode_Value::make_character(), and Aleph::Interpreter_Runtime::parse_char_literal().
|
inlinestatic |
Builds a callable value backed by HIR function code.
Definition at line 280 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Function, kind, and value.
Referenced by Aleph::Interpreter_Runtime::install_module_function().
|
inlinestatic |
Builds a callable value backed by host code.
Definition at line 292 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Host_Function, kind, and value.
Referenced by Aleph::Interpreter_Runtime::bind_host_function(), and Aleph::Compiler_Bytecode_Value::make_host_function().
|
inlinestatic |
Builds an integer runtime value.
Definition at line 247 of file Interpreter_Runtime.H.
References Aleph::Integer, kind, and value.
Referenced by Aleph::Interpreter_Runtime::evaluate_expr(), main(), Aleph::Compiler_Bytecode_Value::make_integer(), Aleph::Interpreter_Runtime::parse_integer_literal(), TEST(), TEST(), and TEST().
|
inlinestatic |
Builds an invalid value placeholder.
Definition at line 224 of file Interpreter_Runtime.H.
Referenced by Aleph::Interpreter_Runtime::call_host_function(), Aleph::Compiler_Bytecode_VM::execute_host_call(), and Aleph::Interpreter_Runtime::runtime_error().
|
inlinestatic |
Builds a string runtime value.
Definition at line 256 of file Interpreter_Runtime.H.
References kind, Aleph::String, and value.
Referenced by Aleph::Compiler_Bytecode_Value::make_string(), and Aleph::Interpreter_Runtime::parse_string_literal().
|
inlinestatic |
Builds a tuple runtime value by copying elements.
Definition at line 406 of file Interpreter_Runtime.H.
References kind, Aleph::Tuple, and value.
Referenced by TEST().
|
inlinestatic |
Builds a tuple runtime value by moving elements.
Definition at line 414 of file Interpreter_Runtime.H.
References kind, Aleph::Tuple, and value.
|
inlinestatic |
Builds the Unit value.
Definition at line 230 of file Interpreter_Runtime.H.
References kind, Aleph::Unit, and value.
Referenced by Aleph::Interpreter_Runtime::evaluate_expr(), Aleph::Interpreter_Runtime::evaluate_stmt(), and Aleph::Compiler_Bytecode_Value::make_unit().
|
inline |
Assigns one runtime value by deep copy.
Definition at line 362 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), and kind.
|
inlinenoexcept |
Assigns one runtime value by move.
Definition at line 385 of file Interpreter_Runtime.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Invalid, and kind.
|
inlinenoexcept |
Returns the tuple payload.
kind == Tuple. Definition at line 422 of file Interpreter_Runtime.H.
References tuple_storage.
Referenced by Aleph::interpreter_values_equal().
Payload for Bool values.
Definition at line 193 of file Interpreter_Runtime.H.
Referenced by Aleph::interpreter_values_equal().
| std::string Aleph::Interpreter_Value::callable_name |
Stable debug name for callable values.
Definition at line 203 of file Interpreter_Runtime.H.
Referenced by Aleph::Interpreter_Runtime::call_host_function().
| char Aleph::Interpreter_Value::character_value = '\0' |
Payload for Char values.
Definition at line 195 of file Interpreter_Runtime.H.
Referenced by Aleph::interpreter_values_equal().
| Interpreter_Environment* Aleph::Interpreter_Value::closure_environment = nullptr |
Captured lexical parent for function values.
Definition at line 199 of file Interpreter_Runtime.H.
Referenced by Aleph::Interpreter_Runtime::call_hir_function(), and Aleph::interpreter_values_equal().
| const Compiler_HIR_Function* Aleph::Interpreter_Value::function = nullptr |
Payload for HIR function values.
Definition at line 198 of file Interpreter_Runtime.H.
Referenced by Aleph::Interpreter_Runtime::call_hir_function(), and Aleph::interpreter_values_equal().
| Interpreter_Host_Function Aleph::Interpreter_Value::host_function = nullptr |
Payload for host function values.
Definition at line 201 of file Interpreter_Runtime.H.
Referenced by Aleph::Interpreter_Runtime::call_host_function(), Aleph::Compiler_Bytecode_VM::execute_host_call(), and Aleph::interpreter_values_equal().
| void* Aleph::Interpreter_Value::host_user_data = nullptr |
Embedding-specific payload for host functions.
Definition at line 202 of file Interpreter_Runtime.H.
Referenced by Aleph::Interpreter_Runtime::call_host_function(), Aleph::Compiler_Bytecode_VM::execute_host_call(), and Aleph::interpreter_values_equal().
Payload for Int values.
Definition at line 194 of file Interpreter_Runtime.H.
Referenced by Aleph::interpreter_values_equal(), and TEST().
| Interpreter_Value_Kind Aleph::Interpreter_Value::kind = Interpreter_Value_Kind::Invalid |
Active value kind.
Definition at line 192 of file Interpreter_Runtime.H.
Referenced by Aleph::Interpreter_Runtime::call_value(), Aleph::Compiler_Bytecode_VM::execute_loop(), Aleph::interpreter_values_equal(), is_callable(), is_unit(), make_bool(), make_character(), make_function(), make_host_function(), make_integer(), make_string(), make_tuple(), make_tuple(), make_unit(), operator=(), operator=(), and TEST().
| std::string Aleph::Interpreter_Value::string_value |
Payload for String values.
Definition at line 196 of file Interpreter_Runtime.H.
Referenced by Aleph::interpreter_values_equal().
| std::unique_ptr<Interpreter_Tuple_Storage> Aleph::Interpreter_Value::tuple_storage |
Payload for Tuple values.
Definition at line 197 of file Interpreter_Runtime.H.
Referenced by Interpreter_Value(), and tuple_elements().