pub enum WordVal {
W8(Word8),
W16(Word16),
W32(Word32),
W64(Word64),
}Expand description
A fixed-width wrapping integer of any supported width — the single runtime carrier for
Word8/Word16/Word32/Word64 across the interpreter, VM, and wire, so the rest of the system
matches on one Word value rather than a type per width. Each width is its own ring: a Word16
wraps at 2¹⁶ exactly as the compiled tier’s Word16 newtype does. Binary ops require matching
widths; a width mismatch is a type error the caller reports (the ops return None).
Variants§
W8(Word8)
An 8-bit wrapping value.
W16(Word16)
A 16-bit wrapping value.
W32(Word32)
A 32-bit wrapping value.
W64(Word64)
A 64-bit wrapping value.
Implementations§
Source§impl WordVal
impl WordVal
Sourcepub const fn to_u64(self) -> u64
pub const fn to_u64(self) -> u64
The value zero-extended to u64 — the canonical scalar form for display, hashing into
other contexts, and the wire.
Sourcepub const fn from_u64(width: u32, bits: u64) -> Option<Self>
pub const fn from_u64(width: u32, bits: u64) -> Option<Self>
Build a word of the given width from the low bits of bits (the value is reduced into the
width’s ring); None for a width that is not 8, 16, 32, or 64.
Sourcepub const fn type_name(self) -> &'static str
pub const fn type_name(self) -> &'static str
The type name (Word8 … Word64) — what errors and type_name report.
Sourcepub fn div(self, o: Self) -> Option<Self>
pub fn div(self, o: Self) -> Option<Self>
Truncating unsigned division; None on a width mismatch. The caller must ensure a
non-zero divisor — the concrete / panics on zero, exactly as the AOT Word newtype
(and the native unsigned integers) do.
Sourcepub fn rem(self, o: Self) -> Option<Self>
pub fn rem(self, o: Self) -> Option<Self>
Unsigned remainder; None on a width mismatch. The caller must ensure a non-zero divisor.
Sourcepub const fn shl(self, n: u32) -> Self
pub const fn shl(self, n: u32) -> Self
Logical left shift by n (width-preserving; the count is taken modulo the width).
Sourcepub const fn shr(self, n: u32) -> Self
pub const fn shr(self, n: u32) -> Self
Logical right shift by n (width-preserving; the count is taken modulo the width).