Skip to main content

Crate calx_vm

Crate calx_vm 

Source
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§

BodyBuilder
Builds a flat CalxSyntax body while owning structural target calculation.
CalxBuildError
Structured failure returned by ProgramBuilder, FunctionBuilder, or BodyBuilder.
CalxError
Runtime or host error with an optional, out-of-line VM snapshot.
CalxErrorSnapshot
VM state captured only when an execution error originates inside a VM.
CalxFrame
CalxFunc
CalxGlobalDecl
CalxHostBinding
CalxImportDecl
CalxLocalDecl
CalxProgram
CalxProgramError
Declaration or strict-profile conversion failure.
CalxVM
Virtual Machine for Calx code is evaluated in a several steps:
DiagnosticView
Common borrowed view over parse, validation, runtime, and host failures.
FunctionBuilder
Builds a typed function signature, local declarations, and source body.
FunctionValidationTrace
Ordered validation steps for one function.
GlobalId
Opaque index of a declared module global.
ImportId
Opaque reference to a declared typed host import.
LocalId
Opaque index of a parameter or declared local in one function.
ParseError
Parse failure with a stable code and optional source location.
ParsedProgram
Source-aware result of parsing a complete Calx file.
ProgramBuilder
Builds module declarations and functions without generating Cirru text.
SourcePosition
One source position. Lines and columns are one-based; offsets are byte-based.
SourceSpan
Half-open source range associated with a parsed Calx expression.
ValidatedProgram
A strict program whose declarations, typed instruction effects, and lowering have all succeeded.
ValidationControlState
Observable state of one validation control frame.
ValidationError
ValidationStep
Validation state immediately before and after one expanded syntax instruction.
VmEvent
An owned, deterministic snapshot of one real VM transition.
VmSlotChange
One local or global slot changed by a traced instruction.

Enums§

Calx
Simplied from Calcit, but trying to be basic and mutable
CalxBoundaryType
A boundary contract retained by parsed and legacy metadata.
CalxBuildErrorKind
Stable category for errors raised while assembling an unvalidated program.
CalxHostCallback
CalxInstr
learning from WASM but for dynamic data
CalxMutability
CalxRunResult
Typed execution distinguishes void from the explicit Calx::Nil value.
CalxSlot
Storage state for locals and globals.
CalxSyntax
learning from WASM but for dynamic data
CalxTraceError
Explicit reason why a traced execution stopped.
CalxType
syntax like (i64 -> i64) can be used to types of functions and blocks
DiagnosticCode
Stable identifier for a class of Calx diagnostic.
DiagnosticPhase
Pipeline phase that produced a diagnostic.
DiagnosticStack
Borrowed stack data exposed by a diagnostic without allocation.
ValidationControlKind
Kind of a control frame exposed by a validation trace.
ValidationType
VmEventKind
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.

Type Aliases§

CalxHostBindings
CalxImportsDict