pub enum ConValue {
Show 18 variants
Empty,
Int(i128),
Float(f64),
Bool(bool),
Char(char),
Str(Symbol),
String(String),
Ref(Place),
Slice(Place, usize),
Array(Box<[ConValue]>),
Tuple(Box<[ConValue]>),
Struct(Type, Box<HashMap<Symbol, ConValue>>),
TupleStruct(Type, Box<[ConValue]>),
Module(Box<HashMap<Symbol, ConValue>>),
Quote(Rc<Expr>),
Function(Rc<Function>),
Builtin(&'static Builtin),
TypeInfo(Type),
}Expand description
A Conlang value stores data in the interpreter
Variants§
Empty
The empty/unit () type
Int(i128)
An integer
Float(f64)
A floating point number
Bool(bool)
A boolean
Char(char)
A unicode character
Str(Symbol)
A string literal
String(String)
A dynamic string
Ref(Place)
A reference
Slice(Place, usize)
A reference to an array
Array(Box<[ConValue]>)
An Array
Tuple(Box<[ConValue]>)
A tuple
Struct(Type, Box<HashMap<Symbol, ConValue>>)
A value of a product type
TupleStruct(Type, Box<[ConValue]>)
A value of a product type with anonymous members
Module(Box<HashMap<Symbol, ConValue>>)
An entire namespace
Quote(Rc<Expr>)
A quoted expression
Function(Rc<Function>)
A callable thing
Builtin(&'static Builtin)
A built-in function
TypeInfo(Type)
The definition of a type, by index
Implementations§
Source§impl ConValue
impl ConValue
pub fn take(&mut self) -> Self
pub fn is_cheap_to_copy(&self) -> bool
pub fn typename(&self) -> &'static str
pub fn cast(self, ty: &TypeInfo) -> Self
pub fn dereference_in<'e>(&'e self, env: &'e Environment) -> IResult<&'e Self>
pub fn tuple_struct(id: Type, values: impl Into<Box<[ConValue]>>) -> Self
pub fn Struct(id: Type, values: HashMap<Symbol, 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