Expand description
Storage/execution agnostic runtime semantics (design §5.2, §8, §10.1).
Everything here is shared between the native runtime (runtime.rs) and
the wasm simulator: tagged value encoding, the frozen semantics matrix
(checked i64 arithmetic, equality, truthiness, indexing, builtins),
the canonical observer encoding, and call/construct dispatch. Failures
never exit the process at this layer; they are returned as stable
RuntimeErrorKind categories.
Structs§
- Bound
Method Data - Buffer
Sink - Test/simulator sink collecting raw stdout bytes.
- Class
Data - Closure
Data - Instance
Data - Runtime
Failure
Enums§
- Call
Dispatch - Dispatch result: builtins resolve immediately, code invocations bounce back through the execution adapter (real function pointer natively, a simulated PC in wasm).
- HashKey
- Heap
Object - Heap object layout is fully opaque to generated assembly (design §5.2), which is what lets it be plain Rust data.
- Return
Policy - How the execution adapter finishes an
Invoke(design §8.1): constructors always yield their instance. - Runtime
Error Kind - Stable error categories, frozen ABI between
.sand the runtime (design §8). Tests compare kinds, never messages.
Constants§
- BUILTIN_
TAG - FALSE_
VALUE - HEAP_
TAG - MAX_
INVOKE_ ARGS - Hard cap shared with the calling convention: a closure body receives its
arguments in
x1..x7(design §2.2, §7). - NULL_
VALUE - PTR_
TAG_ MASK - SMI_MAX
- SMI_MIN
- SMIs cover
[-2^62, 2^62 - 1]; the rest of thei64range is boxed. - TRUE_
VALUE
Traits§
- Output
Sink - Where
puts/printbytes go: stdout natively, a buffer in the simulator and in tests (design §8.1).
Functions§
- add
- Checked addition; also string concatenation (design §8).
- array_
from_ values - bang
!vis strictly the logical inverse of truthiness (design §10.1).- bool_
value - builtin_
canonical_ name - Canonical name used by the observer protocol (
printnormalizes toputs). - builtin_
from_ ordinal - builtin_
id_ for_ symbol_ index - Builtin id for a
SymbolScope::Builtinsymbol index (the index intoobject::builtins::BuiltIns, whereprintaliasesputs). - builtin_
ordinal - Frozen builtin numbering used by the immediate encoding
(ordinal << 3) | 0b101.printsharesBuiltinId::Putsand therefore the same ordinal (seeobject/builtins.rs). - builtin_
value - call_
builtin - Builtins run inside the runtime (no separate FFI symbols); arity/type
problems are terminating errors, never
Errorvalues (design §8). - canonical_
value - Canonical tagged JSON encoding for the observer protocol (design §10.2).
- class_
add_ method - class_
new - closure_
new - dispatch_
call - Plain-call dispatch (design §7.2): closures, builtins and bound methods
are callable; classes must use
new. - dispatch_
construct newdispatch (design §7.2): callee must be a class; the constructor — when present — runs with the fresh instance asthisand the instance is always the result.- display
- Shared language display (design §10.2): what
putsprints. - div
- Division separates
DivisionByZerofirst, then truncates toward zero via checkedi64division (i64::MIN / -1→IntegerOverflow). - eq_
values - Frozen equality matrix (design §10.1): integers by raw value, scalars by value, builtins by id, aggregates recursively, identity types by object identity, differing types compare unequal.
- get_
free - v1’s only free-variable access path (design §7).
- get_
property - Field first, then a freshly bound method; missing →
MissingProperty(design §8, matching the VMs’ error surface). - gt
>accepts integers only (design §10.1).- hash_
from_ pairs pairsisk0,v0,k1,v1,…; later duplicates win, like the VMs.- hash_
key - i64_
fits_ smi - index
- Array out-of-bounds and hash missing key are
null; wrong container or index types areTypeError; unhashable hash keys areInvalidHashKey(design §10.1). - int_
value - Raw integer behind either representation (SMI or boxed).
- is_
builtin - is_heap
- is_smi
- make_
int - SMI when it fits, boxed integer otherwise; results shrink back to SMI whenever possible.
- minus
- mul
- set_
property - smi_
from_ i64 - smi_
to_ i64 - string_
from_ utf8 - sub
- truthy
- Frozen truthiness: only
falseandnullare falsy (design §10.1).
Type Aliases§
- Runtime
Result - Value
- 64-bit tagged value (design §5.2).