cl_interpret::convalue

Enum ConValue

Source
pub enum ConValue {
Show 16 variants Empty, Int(isize), Float(f64), Bool(bool), Char(char), String(Sym), Ref(Rc<ConValue>), Array(Box<[ConValue]>), Tuple(Box<[ConValue]>), RangeExc(isize, isize), RangeInc(isize, isize), Struct(Box<(Sym, HashMap<Sym, ConValue>)>), Module(Box<HashMap<Sym, Option<ConValue>>>), Quote(Box<ExprKind>), Function(Rc<Function>), 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

§

String(Sym)

A string

§

Ref(Rc<ConValue>)

A reference

§

Array(Box<[ConValue]>)

An Array

§

Tuple(Box<[ConValue]>)

A tuple

§

RangeExc(isize, isize)

An exclusive range

§

RangeInc(isize, isize)

An inclusive range

§

Struct(Box<(Sym, HashMap<Sym, ConValue>)>)

A value of a product type

§

Module(Box<HashMap<Sym, Option<ConValue>>>)

An entire namespace

§

Quote(Box<ExprKind>)

A quoted expression

§

Function(Rc<Function>)

A callable thing

§

Builtin(&'static Builtin)

A built-in function

Implementations§

Source§

impl ConValue

Source

pub fn truthy(&self) -> IResult<bool>

Gets whether the current value is true or false

Source

pub fn range_exc(self, other: Self) -> IResult<Self>

Source

pub fn range_inc(self, other: Self) -> IResult<Self>

Source

pub fn index(&self, index: &Self) -> IResult<ConValue>

Source

pub fn lt(&self, other: &Self) -> IResult<Self>

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

Source

pub fn lt_eq(&self, other: &Self) -> IResult<Self>

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

Source

pub fn eq(&self, other: &Self) -> IResult<Self>

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

Source

pub fn neq(&self, other: &Self) -> IResult<Self>

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

Source

pub fn gt_eq(&self, other: &Self) -> IResult<Self>

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

Source

pub fn gt(&self, other: &Self) -> IResult<Self>

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

Source

pub fn add_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn bitand_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn bitor_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn bitxor_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn div_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn mul_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn rem_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn shl_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn shr_assign(&mut self, other: Self) -> IResult<()>

Source

pub fn sub_assign(&mut self, other: Self) -> IResult<()>

Trait Implementations§

Source§

impl Add for ConValue

Source§

fn add(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the + operator.
Source§

impl BitAnd for ConValue

Source§

fn bitand(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the & operator.
Source§

impl BitOr for ConValue

Source§

fn bitor(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the | operator.
Source§

impl BitXor for ConValue

Source§

fn bitxor(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the ^ operator.
Source§

impl Callable for ConValue

Source§

fn name(&self) -> Sym

Returns the common name of this identifier.
Source§

fn call( &self, interpreter: &mut Environment, args: &[ConValue], ) -> IResult<ConValue>

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

impl Clone for ConValue

Source§

fn clone(&self) -> ConValue

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 ConValue

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ConValue

Source§

fn default() -> ConValue

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

impl Display for ConValue

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Div for ConValue

Source§

fn div(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the / operator.
Source§

impl From<&[ConValue]> for ConValue

Source§

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

Converts to this type from the input type.
Source§

impl From<&'static Builtin> for ConValue

Source§

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

Converts to this type from the input type.
Source§

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

Source§

fn from(value: &Sym) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for ConValue

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for ConValue

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl From<ExprKind> for ConValue

Source§

fn from(value: ExprKind) -> Self

Converts to this type from the input type.
Source§

impl From<Function> for ConValue

Source§

fn from(value: Function) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(value: Sym) -> Self

Converts to this type from the input type.
Source§

impl From<Rc<str>> for ConValue

Source§

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

Converts to this type from the input type.
Source§

impl From<String> for ConValue

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<ConValue>> for ConValue

Source§

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

Converts to this type from the input type.
Source§

impl From<bool> for ConValue

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<char> for ConValue

Source§

fn from(value: char) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for ConValue

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for ConValue

Source§

fn from(value: isize) -> Self

Converts to this type from the input type.
Source§

impl Mul for ConValue

Source§

fn mul(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the * operator.
Source§

impl Rem for ConValue

Source§

fn rem(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the % operator.
Source§

impl Shl for ConValue

Source§

fn shl(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the << operator.
Source§

impl Shr for ConValue

Source§

fn shr(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

type Output = Result<ConValue, Error>

The resulting type after applying the >> operator.
Source§

impl Sub for ConValue

Source§

fn sub(self, rhs: Self) -> Self::Output

TODO: Desugar operators into function calls

Source§

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