pub struct Value(/* private fields */);Expand description
A VM value (fat 16-byte representation).
Implementations§
Source§impl Value
impl Value
pub fn int(n: i64) -> Self
pub fn float(f: f64) -> Self
pub fn bool(b: bool) -> Self
pub fn nothing() -> Self
pub fn from_runtime(rv: RuntimeValue) -> Self
pub fn into_runtime(self) -> RuntimeValue
Sourcepub fn as_runtime(&self) -> RuntimeRef<'_>
pub fn as_runtime(&self) -> RuntimeRef<'_>
Borrow as a RuntimeValue. Zero cost: the Value IS a
RuntimeValue.
Sourcepub fn as_runtime_ref(&self) -> Option<&RuntimeValue>
pub fn as_runtime_ref(&self) -> Option<&RuntimeValue>
Borrow the RuntimeValue DIRECTLY (lifetime tied to &self, no
RuntimeRef temporary) when one already exists in place. Default:
always Some. The seam for the machine.rs sites that destructure a
heap arm and hold a borrow (an Rc/RefMut) across statements — see
the narrow impl, where an inline scalar returns None.
Sourcepub fn as_runtime_mut(&mut self) -> &mut RuntimeValue
pub fn as_runtime_mut(&mut self) -> &mut RuntimeValue
Mutably borrow as a RuntimeValue.
pub fn as_int(&self) -> Option<i64>
pub fn as_bool(&self) -> Option<bool>
pub fn as_float(&self) -> Option<f64>
pub fn is_int(&self) -> bool
pub fn add(&self, rhs: &Value) -> Result<Value, String>
pub fn sub(&self, rhs: &Value) -> Result<Value, String>
pub fn mul(&self, rhs: &Value) -> Result<Value, String>
pub fn lt(&self, rhs: &Value) -> Result<Value, String>
pub fn gt(&self, rhs: &Value) -> Result<Value, String>
pub fn lte(&self, rhs: &Value) -> Result<Value, String>
pub fn gte(&self, rhs: &Value) -> Result<Value, String>
pub fn eq_op(&self, rhs: &Value) -> Value
pub fn neq_op(&self, rhs: &Value) -> Value
Source§impl Value
impl Value
pub fn text(s: String) -> Self
pub fn is_truthy(&self) -> bool
pub fn to_display_string(&self) -> String
Sourcepub fn type_name(&self) -> &str
pub fn type_name(&self) -> &str
The value’s type name. Borrows &self (Struct/Inductive names live in the
value; the scalar names are 'static literals) — never a temporary, so it
is valid under the narrow representation where as_runtime() would
materialise an inline scalar into a short-lived RuntimeValue.
Sourcepub fn values_equal(&self, other: &Value) -> bool
pub fn values_equal(&self, other: &Value) -> bool
Value equality for the equals/== operator and for set/list
membership (epsilon floats, structural inductives — the kernel’s rules).
pub fn list(items: Vec<Value>) -> Self
Sourcepub fn int_list(items: Vec<i64>) -> Self
pub fn int_list(items: Vec<i64>) -> Self
Wrap a raw Int vector as a list value (the native tier’s fresh allocations re-box through here).
pub fn empty_list() -> Self
Sourcepub fn empty_list_i32() -> Self
pub fn empty_list_i32() -> Self
A fresh empty half-width Int sequence (ListRepr::IntsI32), backing a
narrowing-proven new Seq of Int under LOGOS_NARROW_VM.
pub fn empty_set() -> Self
pub fn empty_map() -> Self
pub fn int_range(lo: i64, hi: i64) -> Self
pub fn list_push(&self, value: Value) -> Result<(), String>
pub fn len(&self) -> Result<i64, String>
pub fn index_get(&self, idx: &Value) -> Result<Value, String>
pub fn set_add(&self, value: Value) -> Result<(), String>
pub fn remove_from(&self, value: &Value) -> Result<(), String>
pub fn index_set(&self, idx: &Value, value: Value) -> Result<(), String>
pub fn contains(&self, value: &Value) -> Result<bool, String>
pub fn div(&self, rhs: &Value) -> Result<Value, String>
Sourcepub fn exact_div(&self, rhs: &Value) -> Result<Value, String>
pub fn exact_div(&self, rhs: &Value) -> Result<Value, String>
EXACT division (Op::ExactDiv) — the type-directed sibling of Value::div:
7 / 2 → 7/2 (a Rational), never the floored 3. Routes through the shared
kernel exactly like div, so the VM stays bit-identical to the tree-walker.
Sourcepub fn floor_div(&self, rhs: &Value) -> Result<Value, String>
pub fn floor_div(&self, rhs: &Value) -> Result<Value, String>
FLOOR division (Op::FloorDiv, a // b) — the quotient rounded toward negative
infinity (-7 // 2 → -4), distinct from the truncating Value::div. Routes
through the shared kernel, so the VM stays bit-identical to the tree-walker.
pub fn modulo(&self, rhs: &Value) -> Result<Value, String>
pub fn concat(&self, rhs: &Value) -> Result<Value, String>
Sourcepub fn seq_concat(&self, rhs: &Value) -> Result<Value, String>
pub fn seq_concat(&self, rhs: &Value) -> Result<Value, String>
a followed by b — merge two sequences into one (reuses the tree-walker semantics).
pub fn pow(&self, rhs: &Value) -> Result<Value, String>
pub fn bitxor(&self, rhs: &Value) -> Result<Value, String>
pub fn bitand(&self, rhs: &Value) -> Result<Value, String>
pub fn bitor(&self, rhs: &Value) -> Result<Value, String>
pub fn shl(&self, rhs: &Value) -> Result<Value, String>
pub fn shr(&self, rhs: &Value) -> Result<Value, String>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Value
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl !UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.