Value

Enum Value 

pub enum Value {
Show 19 variants Empty, Int(isize), Float(f64), Bool(bool), Char(char), Str(Interned<'static, str>), String(String), Ref(usize), Slice(usize, usize), Array(Box<[ConValue]>), Tuple(Box<[ConValue]>), Struct(Interned<'static, str>, Box<HashMap<Interned<'static, str>, ConValue>>), TupleStruct(Interned<'static, str>, Box<Box<[ConValue]>>), Module(Box<HashMap<Interned<'static, str>, ConValue>>), Quote(Rc<Expr>), Function(Rc<Function>), TupleConstructor(Constructor), Closure(Rc<Closure>), Builtin(&'static Builtin),
}
Expand description

A Conlang value stores data in the interpreter

Variants§

§

Empty

The empty/unit () type

§

Int(isize)

An integer

§

Float(f64)

A floating point number

§

Bool(bool)

A boolean

§

Char(char)

A unicode character

§

Str(Interned<'static, str>)

A string literal

§

String(String)

A dynamic string

§

Ref(usize)

A reference

§

Slice(usize, usize)

A reference to an array

§

Array(Box<[ConValue]>)

An Array

§

Tuple(Box<[ConValue]>)

A tuple

§

Struct(Interned<'static, str>, Box<HashMap<Interned<'static, str>, ConValue>>)

A value of a product type

§

TupleStruct(Interned<'static, str>, Box<Box<[ConValue]>>)

A value of a product type with anonymous members

§

Module(Box<HashMap<Interned<'static, str>, ConValue>>)

An entire namespace

§

Quote(Rc<Expr>)

A quoted expression

§

Function(Rc<Function>)

A callable thing

§

TupleConstructor(Constructor)

A tuple constructor

§

Closure(Rc<Closure>)

A closure, capturing by reference

§

Builtin(&'static Builtin)

A built-in function

Implementations§

§

impl ConValue

pub fn truthy(&self) -> Result<bool, Error>

Gets whether the current value is true or false

pub fn typename(&self) -> &'static str

pub fn TupleStruct( id: Interned<'static, str>, values: Box<[ConValue]>, ) -> ConValue

pub fn Struct( id: Interned<'static, str>, values: HashMap<Interned<'static, str>, ConValue>, ) -> ConValue

pub fn index( &self, index: &ConValue, _env: &Environment, ) -> Result<ConValue, Error>

pub fn lt(&self, other: &ConValue) -> Result<ConValue, Error>

TODO: Remove when functions are implemented: Desugar into function calls

pub fn lt_eq(&self, other: &ConValue) -> Result<ConValue, Error>

TODO: Remove when functions are implemented: Desugar into function calls

pub fn eq(&self, other: &ConValue) -> Result<ConValue, Error>

TODO: Remove when functions are implemented: Desugar into function calls

pub fn neq(&self, other: &ConValue) -> Result<ConValue, Error>

TODO: Remove when functions are implemented: Desugar into function calls

pub fn gt_eq(&self, other: &ConValue) -> Result<ConValue, Error>

TODO: Remove when functions are implemented: Desugar into function calls

pub fn gt(&self, other: &ConValue) -> Result<ConValue, Error>

TODO: Remove when functions are implemented: Desugar into function calls

pub fn add_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn bitand_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn bitor_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn bitxor_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn div_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn mul_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn rem_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn shl_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn shr_assign(&mut self, other: ConValue) -> Result<(), Error>

pub fn sub_assign(&mut self, other: ConValue) -> Result<(), Error>

Trait Implementations§

§

impl Add for ConValue

§

fn add(self, rhs: ConValue) -> <ConValue as Add>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the + operator.
§

impl BitAnd for ConValue

§

fn bitand(self, rhs: ConValue) -> <ConValue as BitAnd>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the & operator.
§

impl BitOr for ConValue

§

fn bitor(self, rhs: ConValue) -> <ConValue as BitOr>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the | operator.
§

impl BitXor for ConValue

§

fn bitxor(self, rhs: ConValue) -> <ConValue as BitXor>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the ^ operator.
§

impl Callable for ConValue

§

fn name(&self) -> Interned<'static, str>

Returns the common name of this identifier.
§

fn call( &self, env: &mut Environment, args: &[ConValue], ) -> Result<ConValue, Error>

Calls this [Callable] in the provided Environment, with ConValue args
The Callable is responsible for checking the argument count and validating types
§

impl Clone for ConValue

§

fn clone(&self) -> ConValue

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for ConValue

§

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

Formats the value using the given formatter. Read more
§

impl Default for ConValue

§

fn default() -> ConValue

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

impl Display for ConValue

§

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

Formats the value using the given formatter. Read more
§

impl Div for ConValue

§

fn div(self, rhs: ConValue) -> <ConValue as Div>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the / operator.
§

impl From<&[ConValue]> for ConValue

§

fn from(value: &[ConValue]) -> ConValue

Converts to this type from the input type.
§

impl From<&'static Builtin> for ConValue

§

fn from(value: &'static Builtin) -> ConValue

Converts to this type from the input type.
§

impl From<&Interned<'static, str>> for ConValue

§

fn from(value: &Interned<'static, str>) -> ConValue

Converts to this type from the input type.
§

impl From<&str> for ConValue

§

fn from(value: &str) -> ConValue

Converts to this type from the input type.
§

impl From<()> for ConValue

§

fn from(_: ()) -> ConValue

Converts to this type from the input type.
§

impl From<Expr> for ConValue

§

fn from(value: Expr) -> ConValue

Converts to this type from the input type.
§

impl From<Function> for ConValue

§

fn from(value: Function) -> ConValue

Converts to this type from the input type.
§

impl From<Interned<'static, str>> for ConValue

§

fn from(value: Interned<'static, str>) -> ConValue

Converts to this type from the input type.
§

impl From<Rc<str>> for ConValue

§

fn from(value: Rc<str>) -> ConValue

Converts to this type from the input type.
§

impl From<String> for ConValue

§

fn from(value: String) -> ConValue

Converts to this type from the input type.
§

impl From<Vec<ConValue>> for ConValue

§

fn from(value: Vec<ConValue>) -> ConValue

Converts to this type from the input type.
§

impl From<bool> for ConValue

§

fn from(value: bool) -> ConValue

Converts to this type from the input type.
§

impl From<char> for ConValue

§

fn from(value: char) -> ConValue

Converts to this type from the input type.
§

impl From<f64> for ConValue

§

fn from(value: f64) -> ConValue

Converts to this type from the input type.
§

impl From<isize> for ConValue

§

fn from(value: isize) -> ConValue

Converts to this type from the input type.
§

impl Mul for ConValue

§

fn mul(self, rhs: ConValue) -> <ConValue as Mul>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the * operator.
§

impl Rem for ConValue

§

fn rem(self, rhs: ConValue) -> <ConValue as Rem>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the % operator.
§

impl Shl for ConValue

§

fn shl(self, rhs: ConValue) -> <ConValue as Shl>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the << operator.
§

impl Shr for ConValue

§

fn shr(self, rhs: ConValue) -> <ConValue as Shr>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the >> operator.
§

impl Sub for ConValue

§

fn sub(self, rhs: ConValue) -> <ConValue as Sub>::Output

TODO: Desugar operators into function calls

§

type Output = Result<ConValue, Error>

The resulting type after applying the - operator.

Auto Trait Implementations§

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
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.