Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Bytecode_Interpreter.H File Reference

Simple portable VM for executing the register bytecode in Bytecode.H. More...

#include <sstream>
#include <string>
#include <utility>
#include <Bytecode.H>
#include <Interpreter_Runtime.H>
Include dependency graph for Bytecode_Interpreter.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::Compiler_Bytecode_Value
 One value stored in bytecode registers, locals, or globals. More...
 
struct  Aleph::Compiler_Bytecode_Runtime_Error
 Structured runtime error produced by the bytecode VM. More...
 
struct  Aleph::Compiler_Bytecode_Execution_Result
 Result of one bytecode execution request. More...
 
class  Aleph::Compiler_Bytecode_VM
 Small portable VM for executing one Compiler_Bytecode_Module. More...
 
struct  Aleph::Compiler_Bytecode_VM::Frame
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::Compiler_Bytecode_Interpreter_Detail
 

Enumerations

enum class  Aleph::Compiler_Bytecode_Value_Kind { Aleph::Invalid , Aleph::Value , Aleph::Function_Ref }
 Runtime categories that can live inside bytecode registers/slots. More...
 
enum class  Aleph::Compiler_Bytecode_Completion_Kind { Aleph::Returned , Aleph::Halted , Aleph::Runtime_Error }
 Final status produced by one VM execution request. More...
 

Functions

const char * Aleph::compiler_bytecode_value_kind_name (const Compiler_Bytecode_Value_Kind kind) noexcept
 Stable debug name for one bytecode runtime value kind.
 
const char * Aleph::compiler_bytecode_completion_kind_name (const Compiler_Bytecode_Completion_Kind kind) noexcept
 Stable debug name for one execution completion kind.
 
bool Aleph::compiler_bytecode_values_equal (const Compiler_Bytecode_Value &lhs, const Compiler_Bytecode_Value &rhs)
 Returns whether two bytecode values compare equal.
 
std::string Aleph::compiler_bytecode_value_to_string (const Compiler_Bytecode_Value &value, const Compiler_Bytecode_Module *module=nullptr)
 Renders one bytecode value deterministically.
 
std::string Aleph::compiler_dump_bytecode_globals (const Compiler_Bytecode_Module *module, const DynArray< Compiler_Bytecode_Value > &globals)
 Dumps the current global state associated with one bytecode module.
 
void Aleph::Compiler_Bytecode_Interpreter_Detail::reset_values (DynArray< Compiler_Bytecode_Value > &values, const size_t count, const Compiler_Bytecode_Value &fill=Compiler_Bytecode_Value::make_invalid())
 
size_t Aleph::Compiler_Bytecode_Interpreter_Detail::count_parameters (const Compiler_Bytecode_Function &function) noexcept
 
bool Aleph::Compiler_Bytecode_Interpreter_Detail::constant_to_value (const Compiler_Bytecode_Constant &constant, Compiler_Bytecode_Value &value, std::string &error)
 

Detailed Description

Simple portable VM for executing the register bytecode in Bytecode.H.

This header closes the first end-to-end execution loop over the compiler platform:

HIR -> IR -> Bytecode -> Bytecode_Interpreter

The VM is intentionally conservative and explicit:

  • registers are addressed by the ids already emitted by Bytecode.H
  • locals and globals remain explicit slot arrays instead of hidden stack memory
  • runtime failures are reported as structured values instead of exceptions
  • host callbacks from Interpreter_Runtime.H can be injected into globals
  • bytecode function references are kept distinct from HIR function values

The execution model is deliberately small. It is meant to be easy to read, validate, and extend before any future optimized backend or threaded VM.

Definition in file Bytecode_Interpreter.H.