Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Compiler_Bytecode_Value Struct Reference

One value stored in bytecode registers, locals, or globals. More...

#include <Bytecode_Interpreter.H>

Collaboration diagram for Aleph::Compiler_Bytecode_Value:
[legend]

Public Member Functions

bool is_invalid () const noexcept
 Returns whether this value is invalid.
 
bool is_runtime_value () const noexcept
 Returns whether this value wraps an Interpreter_Value.
 
bool is_function_ref () const noexcept
 Returns whether this value is a bytecode function reference.
 

Static Public Member Functions

static Compiler_Bytecode_Value make_invalid ()
 Builds an invalid placeholder value.
 
static Compiler_Bytecode_Value make_value (const Interpreter_Value &value)
 Wraps one regular runtime value.
 
static Compiler_Bytecode_Value make_value (Interpreter_Value &&value)
 Wraps one regular runtime value by move.
 
static Compiler_Bytecode_Value make_unit ()
 Builds the Unit singleton.
 
static Compiler_Bytecode_Value make_bool (const bool value)
 Builds a boolean runtime value.
 
static Compiler_Bytecode_Value make_integer (const long long value)
 Builds an integer runtime value.
 
static Compiler_Bytecode_Value make_string (std::string text)
 Builds a string runtime value.
 
static Compiler_Bytecode_Value make_character (const char ch)
 Builds a character runtime value.
 
static Compiler_Bytecode_Value make_host_function (std::string name, const Interpreter_Host_Function callback, void *user_data=nullptr)
 Builds a callable value backed by host code.
 
static Compiler_Bytecode_Value make_function_ref (const Compiler_Bytecode_Function_Id id)
 Builds a reference to one bytecode function in the current module.
 

Public Attributes

Compiler_Bytecode_Value_Kind kind = Compiler_Bytecode_Value_Kind::Invalid
 Active payload category.
 
Interpreter_Value runtime_value = Interpreter_Value::make_invalid()
 Wrapped scalar/tuple/host-function value.
 
Compiler_Bytecode_Function_Id function_id = compiler_bytecode_invalid_id()
 Referenced bytecode function when kind == Function_Ref.
 

Detailed Description

One value stored in bytecode registers, locals, or globals.

The VM reuses Interpreter_Value for ordinary runtime data such as integers, booleans, strings, tuples, or host functions. Bytecode function references remain separate so the VM never confuses bytecode callables with HIR function values.

Definition at line 129 of file Bytecode_Interpreter.H.

Member Function Documentation

◆ is_function_ref()

bool Aleph::Compiler_Bytecode_Value::is_function_ref ( ) const
inlinenoexcept

Returns whether this value is a bytecode function reference.

Definition at line 238 of file Bytecode_Interpreter.H.

References Aleph::Function_Ref, and kind.

Referenced by Aleph::Compiler_Bytecode_VM::execute_loop().

◆ is_invalid()

bool Aleph::Compiler_Bytecode_Value::is_invalid ( ) const
inlinenoexcept

Returns whether this value is invalid.

Definition at line 224 of file Bytecode_Interpreter.H.

References Aleph::Invalid, and kind.

◆ is_runtime_value()

bool Aleph::Compiler_Bytecode_Value::is_runtime_value ( ) const
inlinenoexcept

Returns whether this value wraps an Interpreter_Value.

Definition at line 231 of file Bytecode_Interpreter.H.

References kind, and Aleph::Value.

Referenced by Aleph::Compiler_Bytecode_VM::execute_loop().

◆ make_bool()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_bool ( const bool  value)
inlinestatic

◆ make_character()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_character ( const char  ch)
inlinestatic

◆ make_function_ref()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_function_ref ( const Compiler_Bytecode_Function_Id  id)
inlinestatic

Builds a reference to one bytecode function in the current module.

Definition at line 214 of file Bytecode_Interpreter.H.

References function_id, Aleph::Function_Ref, and kind.

Referenced by Aleph::Compiler_Bytecode_VM::execute_loop().

◆ make_host_function()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_host_function ( std::string  name,
const Interpreter_Host_Function  callback,
void *  user_data = nullptr 
)
inlinestatic

Builds a callable value backed by host code.

This is useful for embeddings that want to expose helper functions to bytecode by preloading globals before execution.

Definition at line 203 of file Bytecode_Interpreter.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::Interpreter_Value::make_host_function(), and make_value().

◆ make_integer()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_integer ( const long long  value)
inlinestatic

◆ make_invalid()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_invalid ( )
inlinestatic

Builds an invalid placeholder value.

Definition at line 137 of file Bytecode_Interpreter.H.

Referenced by Aleph::Compiler_Bytecode_Execution_Result::runtime_error().

◆ make_string()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_string ( std::string  text)
inlinestatic

Builds a string runtime value.

Definition at line 185 of file Bytecode_Interpreter.H.

References Aleph::Interpreter_Value::make_string(), and make_value().

Referenced by Aleph::Compiler_Bytecode_Interpreter_Detail::constant_to_value().

◆ make_unit()

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_unit ( )
inlinestatic

◆ make_value() [1/2]

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_value ( const Interpreter_Value &  value)
inlinestatic

◆ make_value() [2/2]

static Compiler_Bytecode_Value Aleph::Compiler_Bytecode_Value::make_value ( Interpreter_Value &&  value)
inlinestatic

Wraps one regular runtime value by move.

Definition at line 154 of file Bytecode_Interpreter.H.

References kind, runtime_value, Aleph::Value, and value.

Member Data Documentation

◆ function_id

Compiler_Bytecode_Function_Id Aleph::Compiler_Bytecode_Value::function_id = compiler_bytecode_invalid_id()

Referenced bytecode function when kind == Function_Ref.

Definition at line 133 of file Bytecode_Interpreter.H.

Referenced by Aleph::compiler_bytecode_values_equal(), Aleph::Compiler_Bytecode_VM::execute_loop(), and make_function_ref().

◆ kind

◆ runtime_value

Interpreter_Value Aleph::Compiler_Bytecode_Value::runtime_value = Interpreter_Value::make_invalid()

The documentation for this struct was generated from the following file: