pub enum ConValue {
Show 19 variants
Empty,
Int(isize),
Float(f64),
Bool(bool),
Char(char),
Str(Sym),
String(String),
Ref(usize),
Slice(usize, usize),
Array(Box<[ConValue]>),
Tuple(Box<[ConValue]>),
Struct(Sym, Box<HashMap<Sym, ConValue>>),
TupleStruct(Sym, Box<Box<[ConValue]>>),
Module(Box<HashMap<Sym, 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(Sym)
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(Sym, Box<HashMap<Sym, ConValue>>)
A value of a product type
TupleStruct(Sym, Box<Box<[ConValue]>>)
A value of a product type with anonymous members
Module(Box<HashMap<Sym, 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§
Source§impl ConValue
impl ConValue
pub fn typename(&self) -> &'static str
pub fn TupleStruct(id: Sym, values: Box<[ConValue]>) -> Self
pub fn Struct(id: 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, env: &mut Environment, args: &[ConValue]) -> IResult<ConValue>
fn call(&self, env: &mut Environment, args: &[ConValue]) -> IResult<ConValue>
The Callable is responsible for checking the argument count and validating types