Skip to main content

Module runtime_core

Module runtime_core 

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

BoundMethodData
BufferSink
Test/simulator sink collecting raw stdout bytes.
ClassData
ClosureData
InstanceData
RuntimeFailure

Enums§

CallDispatch
Dispatch result: builtins resolve immediately, code invocations bounce back through the execution adapter (real function pointer natively, a simulated PC in wasm).
HashKey
HeapObject
Heap object layout is fully opaque to generated assembly (design §5.2), which is what lets it be plain Rust data.
ReturnPolicy
How the execution adapter finishes an Invoke (design §8.1): constructors always yield their instance.
RuntimeErrorKind
Stable error categories, frozen ABI between .s and 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 the i64 range is boxed.
TRUE_VALUE

Traits§

OutputSink
Where puts/print bytes 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
!v is strictly the logical inverse of truthiness (design §10.1).
bool_value
builtin_canonical_name
Canonical name used by the observer protocol (print normalizes to puts).
builtin_from_ordinal
builtin_id_for_symbol_index
Builtin id for a SymbolScope::Builtin symbol index (the index into object::builtins::BuiltIns, where print aliases puts).
builtin_ordinal
Frozen builtin numbering used by the immediate encoding (ordinal << 3) | 0b101. print shares BuiltinId::Puts and therefore the same ordinal (see object/builtins.rs).
builtin_value
call_builtin
Builtins run inside the runtime (no separate FFI symbols); arity/type problems are terminating errors, never Error values (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
new dispatch (design §7.2): callee must be a class; the constructor — when present — runs with the fresh instance as this and the instance is always the result.
display
Shared language display (design §10.2): what puts prints.
div
Division separates DivisionByZero first, then truncates toward zero via checked i64 division (i64::MIN / -1IntegerOverflow).
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
pairs is k0,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 are TypeError; unhashable hash keys are InvalidHashKey (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 false and null are falsy (design §10.1).

Type Aliases§

RuntimeResult
Value
64-bit tagged value (design §5.2).