pub enum ConValue {
Show 17 variants
Empty,
Int(isize),
Float(f64),
Bool(bool),
Char(char),
String(Sym),
Ref(Place),
Slice(Place, usize),
Array(Box<[ConValue]>),
Tuple(Box<[ConValue]>),
Struct(Box<(Sym, HashMap<Sym, ConValue>)>),
TupleStruct(Box<(&'static str, Box<[ConValue]>)>),
Module(Box<HashMap<Sym, Option<ConValue>>>),
Quote(Box<Expr>),
Function(Rc<Function>),
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
String(Sym)
A string
Ref(Place)
A reference
Slice(Place, usize)
A reference to an array
Array(Box<[ConValue]>)
An Array
Tuple(Box<[ConValue]>)
A tuple
Struct(Box<(Sym, HashMap<Sym, ConValue>)>)
A value of a product type
TupleStruct(Box<(&'static str, Box<[ConValue]>)>)
A value of a product type with anonymous members
Module(Box<HashMap<Sym, Option<ConValue>>>)
An entire namespace
Quote(Box<Expr>)
A quoted expression
Function(Rc<Function>)
A callable thing
Closure(Rc<Closure>)
A closure, capturing by reference
Builtin(&'static Builtin)
A built-in function
Implementations§
Source§impl ConValue
impl ConValue
pub fn TupleStruct(name: Sym, values: Box<[ConValue]>) -> Self
pub fn Struct(name: Sym, values: HashMap<Sym, ConValue>) -> Self
pub fn index(&self, index: &Self, env: &Environment) -> IResult<ConValue>
Sourcepub fn lt(&self, other: &Self) -> IResult<Self>
pub fn lt(&self, other: &Self) -> IResult<Self>
TODO: Remove when functions are implemented: Desugar into function calls
Sourcepub fn lt_eq(&self, other: &Self) -> IResult<Self>
pub fn lt_eq(&self, other: &Self) -> IResult<Self>
TODO: Remove when functions are implemented: Desugar into function calls
Sourcepub fn eq(&self, other: &Self) -> IResult<Self>
pub fn eq(&self, other: &Self) -> IResult<Self>
TODO: Remove when functions are implemented: Desugar into function calls
Sourcepub fn neq(&self, other: &Self) -> IResult<Self>
pub fn neq(&self, other: &Self) -> IResult<Self>
TODO: Remove when functions are implemented: Desugar into function calls
Sourcepub fn gt_eq(&self, other: &Self) -> IResult<Self>
pub fn gt_eq(&self, other: &Self) -> IResult<Self>
TODO: Remove when functions are implemented: Desugar into function calls
Sourcepub fn gt(&self, other: &Self) -> IResult<Self>
pub fn gt(&self, other: &Self) -> IResult<Self>
TODO: Remove when functions are implemented: Desugar into function calls
pub fn add_assign(&mut self, other: Self) -> IResult<()>
pub fn bitand_assign(&mut self, other: Self) -> IResult<()>
pub fn bitor_assign(&mut self, other: Self) -> IResult<()>
pub fn bitxor_assign(&mut self, other: Self) -> IResult<()>
pub fn div_assign(&mut self, other: Self) -> IResult<()>
pub fn mul_assign(&mut self, other: Self) -> IResult<()>
pub fn rem_assign(&mut self, other: Self) -> IResult<()>
pub fn shl_assign(&mut self, other: Self) -> IResult<()>
pub fn shr_assign(&mut self, other: Self) -> IResult<()>
pub fn sub_assign(&mut self, other: Self) -> IResult<()>
Trait Implementations§
Source§impl Callable for ConValue
impl Callable for ConValue
Source§fn call(
&self,
interpreter: &mut Environment,
args: &[ConValue],
) -> IResult<ConValue>
fn call( &self, interpreter: &mut Environment, args: &[ConValue], ) -> IResult<ConValue>
The Callable is responsible for checking the argument count and validating types