[][src]Struct dark_vm::values::value::Value

pub struct Value {
    pub pos: usize,
    pub kind: ValueKind,
}

The Value struct maintains both the position where this value is used and its kind. Maintaining the position is useful because it can be used to produce good error messages.

Fields

pos: usizekind: ValueKind

Implementations

impl Value[src]

pub fn new(pos: usize, kind: ValueKind) -> Value[src]

Constructs a new Value struct with the specified position and kind.

Arguments

pos - The position where this value is created or called. kind - The value of this value.

impl Value[src]

pub fn add(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and adds them together. Note that this function does not take ownership of either value. Instead, it creates a new value.

Arguments

other - The other value to add. pos - The position where this operation was called.

pub fn sub(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and subtracts them. Note that this function does not take ownership of either value. Instead, it creates a new value.

Arguments

other - The other value to subtract. pos - The position where this operation was called.

pub fn mul(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and mutliplies them. Note that this function does not take ownership of either value. Instead, it creates a new value.

Arguments

other - The other value to multiply. pos - The position where this operation was called.

pub fn div(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and divides them. Note that this function does not take ownership of either value. Instead, it creates a new value.

Arguments

other - The other value to divide. pos - The position where this operation was called.

pub fn lt(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and returns if the current value is less than the second one. Note that this function does not consume either value.

Arguments

other - The other value to compare. pos - The position where this operation was called.

pub fn lte(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and returns if the current value is less than or equal to the second one. Note that this function does not consume either value.

Arguments

other - The other value to compare. pos - The position where this operation was called.

pub fn gt(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and returns if the current value is greater than the second one. Note that this function does not consume either value.

Arguments

other - The other value to compare. pos - The position where this operation was called.

pub fn gte(&self, other: &Value, pos: usize) -> Result<Value, Error>[src]

This function takes the current value and a reference to another value and returns if the current value is greater than or equal to the second one. Note that this function does not consume either value.

Arguments

other - The other value to compare. pos - The position where this operation was called.

pub fn equal(&self, other: &Value, pos: usize) -> Value[src]

This function takes the current value and a reference to another value and returns if the current value is equal to the second one. Note that this function does not consume either value.

Arguments

other - The other value to compare. pos - The position where this operation was called.

pub fn not_equal(&self, other: &Value, pos: usize) -> Value[src]

This function takes the current value and a reference to another value and returns if the current value is not equal to the second one. Note that this function does not consume either value.

Arguments

other - The other value to compare. pos - The position where this operation was called.

pub fn is_truthy(&self) -> bool[src]

This function takes the current value and returns if it is "truthy". This can mean different things for differet values. For ints, it is whether it is not 0. For floats, it is whether it is not NAN, infinite, and not 0. For strings, it is whether it is not empty. Every other value is considered to be false.

Trait Implementations

impl Debug for Value[src]

impl From<Token> for Value[src]

Converts a token into a value. This is used by the Code struct when generating the vector of values.

impl PartialEq<Value> for Value[src]

impl StructuralPartialEq for Value[src]

Auto Trait Implementations

impl RefUnwindSafe for Value

impl Send for Value

impl Sync for Value

impl Unpin for Value

impl UnwindSafe for Value

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.