Skip to main content

Value

Struct Value 

Source
pub struct Value(/* private fields */);
Expand description

A VM value (fat 16-byte representation).

Implementations§

Source§

impl Value

Source

pub fn int(n: i64) -> Self

Source

pub fn float(f: f64) -> Self

Source

pub fn bool(b: bool) -> Self

Source

pub fn nothing() -> Self

Source

pub fn from_runtime(rv: RuntimeValue) -> Self

Source

pub fn into_runtime(self) -> RuntimeValue

Source

pub fn as_runtime(&self) -> RuntimeRef<'_>

Borrow as a RuntimeValue. Zero cost: the Value IS a RuntimeValue.

Source

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.

Source

pub fn as_runtime_mut(&mut self) -> &mut RuntimeValue

Mutably borrow as a RuntimeValue.

Source

pub fn as_int(&self) -> Option<i64>

Source

pub fn as_bool(&self) -> Option<bool>

Source

pub fn as_float(&self) -> Option<f64>

Source

pub fn is_int(&self) -> bool

Source

pub fn add(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn sub(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn mul(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn lt(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn gt(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn lte(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn gte(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn eq_op(&self, rhs: &Value) -> Value

Source

pub fn neq_op(&self, rhs: &Value) -> Value

Source§

impl Value

Source

pub fn text(s: String) -> Self

Source

pub fn is_truthy(&self) -> bool

Source

pub fn to_display_string(&self) -> String

Source

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.

Source

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).

Source

pub fn list(items: Vec<Value>) -> Self

Source

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).

Source

pub fn empty_list() -> Self

Source

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.

Source

pub fn empty_set() -> Self

Source

pub fn empty_map() -> Self

Source

pub fn int_range(lo: i64, hi: i64) -> Self

Source

pub fn list_push(&self, value: Value) -> Result<(), String>

Source

pub fn len(&self) -> Result<i64, String>

Source

pub fn index_get(&self, idx: &Value) -> Result<Value, String>

Source

pub fn set_add(&self, value: Value) -> Result<(), String>

Source

pub fn remove_from(&self, value: &Value) -> Result<(), String>

Source

pub fn index_set(&self, idx: &Value, value: Value) -> Result<(), String>

Source

pub fn contains(&self, value: &Value) -> Result<bool, String>

Source

pub fn div(&self, rhs: &Value) -> Result<Value, String>

Source

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.

Source

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.

Source

pub fn modulo(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn concat(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn seq_concat(&self, rhs: &Value) -> Result<Value, String>

a followed by b — merge two sequences into one (reuses the tree-walker semantics).

Source

pub fn pow(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn bitxor(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn bitand(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn bitor(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn shl(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn shr(&self, rhs: &Value) -> Result<Value, String>

Source

pub fn not_op(&self) -> Result<Value, String>

not x — logical for Bool, bitwise for Int, error otherwise.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,