slvm::value

Enum Value

Source
pub enum Value {
Show 28 variants Byte(u8), Int([u8; 7]), Float(F56), CodePoint(char), CharCluster(u8, [u8; 6]), CharClusterLong(Handle), Symbol(Interned), Keyword(Interned), StringConst(Interned), Special(Interned), Builtin(u32), True, False, Nil, Undefined, String(Handle), Vector(Handle), Map(Handle), Bytes(Handle), Pair(Handle), List(Handle, u16), Lambda(Handle), Closure(Handle), Continuation(Handle), CallFrame(Handle), Value(Handle), Error(Handle), Io(Handle),
}

Variants§

§

Byte(u8)

§

Int([u8; 7])

§

Float(F56)

§

CodePoint(char)

§

CharCluster(u8, [u8; 6])

§

CharClusterLong(Handle)

§

Symbol(Interned)

§

Keyword(Interned)

§

StringConst(Interned)

§

Special(Interned)

§

Builtin(u32)

§

True

§

False

§

Nil

§

Undefined

§

String(Handle)

§

Vector(Handle)

§

Map(Handle)

§

Bytes(Handle)

§

Pair(Handle)

§

List(Handle, u16)

§

Lambda(Handle)

§

Closure(Handle)

§

Continuation(Handle)

§

CallFrame(Handle)

§

Value(Handle)

§

Error(Handle)

§

Io(Handle)

Implementations§

Source§

impl Value

Source

pub fn new() -> Self

Source

pub fn unref<ENV>(self, vm: &GVm<ENV>) -> Value

Source

pub fn get_symbol(&self) -> Option<Interned>

Source

pub fn is_symbol(&self, sym: Interned) -> bool

Source

pub fn is_indirect(&self) -> bool

Source

pub fn is_nil(&self) -> bool

Source

pub fn is_undef(&self) -> bool

Source

pub fn is_true(&self) -> bool

Source

pub fn is_truthy(&self) -> bool

Source

pub fn is_false(&self) -> bool

Source

pub fn is_falsey(&self) -> bool

Source

pub fn is_int(&self) -> bool

Source

pub fn is_number(&self) -> bool

Source

pub fn is_float(&self) -> bool

Source

pub fn not(&self) -> Value

Source

pub fn get_int<ENV>(&self, vm: &GVm<ENV>) -> VMResult<i64>

Source

pub fn get_float<ENV>(&self, _vm: &GVm<ENV>) -> VMResult<f64>

Source

pub fn get_string<'vm, ENV>(&self, vm: &'vm GVm<ENV>) -> VMResult<&'vm str>

Source

pub fn get_handle(&self) -> Option<Handle>

Source

pub fn get_pair<ENV>(&self, vm: &GVm<ENV>) -> Option<(Value, Value)>

Source

pub fn iter<'vm, ENV>( &self, vm: &'vm GVm<ENV>, ) -> Box<dyn Iterator<Item = Value> + 'vm>

Returns an iterator over all values in the list, vector, pair. If the item is not one of the above it returns an empty iterator.

Source

pub fn iter_all<'vm, ENV>( &self, vm: &'vm GVm<ENV>, ) -> Box<dyn Iterator<Item = Value> + 'vm>

Returns an iterator over all values in the list, vector, pair. Returns an empty iterator if the value is nil. If the item is not one of the above it returns a once iter of the value.

Particularly useful if iterating over a Vec<Value> that contains a heterogeneous mix of List(s), Vector(s), Pair(s), and potentially other values, rather than returning an empty list for any non-iterable thing, return a once iter so the item is not missed.

Source

pub fn display_value<ENV>(&self, vm: &GVm<ENV>) -> String

Source

pub fn pretty_value<ENV>(&self, vm: &GVm<ENV>) -> String

Source

pub fn value_type<ENV>(&self, vm: &GVm<ENV>) -> ValueType

Map a Value to a ValueType which can be written to a debug string that refers to the Slosh types and does not require passing in a GVm to do so.

Source

pub fn display_type<ENV>(&self, vm: &GVm<ENV>) -> &'static str

Source

pub fn is_proper_list<ENV>(&self, vm: &GVm<ENV>) -> bool

Source

pub fn get_hash<ENV>(&self, vm: &GVm<ENV>) -> u64

Get the hash of a value making sure that strings (whether const or allocated) hash to the same value. Note: This use the FxHasher which means it is fast and stable but is not randomized to be hardened against external key attacks.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · 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
Source§

impl Default for Value

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<f32> for Value

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for Value

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl BridgedType for &Value

Source§

impl BridgedType for &mut Value

Source§

impl BridgedType for Value

Source§

impl Copy for Value

Source§

impl Eq for Value

Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> 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.