Expand description
Calx VM is a toy VM for learning WebAssembly. It is a stack machine for a strict typed Calcit subset, with an explicit legacy profile for the original dynamic embedding API.
Structs§
- Body
Builder - Builds a flat
CalxSyntaxbody while owning structural target calculation. - Calx
Build Error - Structured failure returned by
ProgramBuilder,FunctionBuilder, orBodyBuilder. - Calx
Error - Runtime or host error with an optional, out-of-line VM snapshot.
- Calx
Error Snapshot - VM state captured only when an execution error originates inside a VM.
- Calx
Frame - Calx
Func - Calx
Global Decl - Calx
Host Binding - Calx
Import Decl - Calx
Local Decl - Calx
Program - Calx
Program Error - Declaration or strict-profile conversion failure.
- CalxVM
- Virtual Machine for Calx code is evaluated in a several steps:
- Diagnostic
View - Common borrowed view over parse, validation, runtime, and host failures.
- Function
Builder - Builds a typed function signature, local declarations, and source body.
- Function
Validation Trace - Ordered validation steps for one function.
- Global
Id - Opaque index of a declared module global.
- Import
Id - Opaque reference to a declared typed host import.
- LocalId
- Opaque index of a parameter or declared local in one function.
- Parse
Error - Parse failure with a stable code and optional source location.
- Parsed
Program - Source-aware result of parsing a complete Calx file.
- Program
Builder - Builds module declarations and functions without generating Cirru text.
- Source
Position - One source position. Lines and columns are one-based; offsets are byte-based.
- Source
Span - Half-open source range associated with a parsed Calx expression.
- Validated
Program - A strict program whose declarations, typed instruction effects, and lowering have all succeeded.
- Validation
Control State - Observable state of one validation control frame.
- Validation
Error - Validation
Step - Validation state immediately before and after one expanded syntax instruction.
- VmEvent
- An owned, deterministic snapshot of one real VM transition.
- VmSlot
Change - One local or global slot changed by a traced instruction.
Enums§
- Calx
- Simplied from Calcit, but trying to be basic and mutable
- Calx
Boundary Type - A boundary contract retained by parsed and legacy metadata.
- Calx
Build Error Kind - Stable category for errors raised while assembling an unvalidated program.
- Calx
Host Callback - Calx
Instr - learning from WASM but for dynamic data
- Calx
Mutability - Calx
RunResult - Typed execution distinguishes void from the explicit
Calx::Nilvalue. - Calx
Slot - Storage state for locals and globals.
- Calx
Syntax - learning from WASM but for dynamic data
- Calx
Trace Error - Explicit reason why a traced execution stopped.
- Calx
Type - syntax like
(i64 -> i64)can be used to types of functions and blocks - Diagnostic
Code - Stable identifier for a class of Calx diagnostic.
- Diagnostic
Phase - Pipeline phase that produced a diagnostic.
- Diagnostic
Stack - Borrowed stack data exposed by a diagnostic without allocation.
- Validation
Control Kind - Kind of a control frame exposed by a validation trace.
- Validation
Type - VmEvent
Kind - The execution transition represented by one
VmEvent.
Constants§
- CALX_
INSTR_ EDITION - TODO not sure whether bincode remains compatible after new instruction added use string for some semantics
- DEFAULT_
TRACE_ STEP_ LIMIT - Default maximum number of executed VM steps emitted by the trace API and CLI.
Traits§
- VmObserver
- Receives owned snapshots from an explicitly traced VM execution.
Functions§
- extract_
nested - rather stupid function to extract nested calls before current call TODO better have some tests
- log_
calx_ value - parse_
function - parses
- parse_
program - Parses a complete source file and attaches deterministic source spans to all expanded syntax instructions.
- trace_
typed_ validation - Record strict typed validation transitions using module declarations.
- trace_
validation - Validates a program and records typed operand/control-stack transitions.
- validate_
program - validate_
typed_ program - Validate a strict program using its declared local/global/import context.