Enum erg_compiler::ty::value::ValueObj
source · pub enum ValueObj {
Show 21 variants
Int(i32),
Nat(u64),
Float(f64),
Str(Str),
Bool(bool),
Array(Rc<[ValueObj]>),
Set(Set<ValueObj>),
Dict(Dict<ValueObj, ValueObj>),
Tuple(Rc<[ValueObj]>),
Record(Dict<Field, ValueObj>),
DataClass {
name: Str,
fields: Dict<Field, ValueObj>,
},
Code(Box<CodeObj>),
Subr(ConstSubr),
Type(TypeObj),
None,
Ellipsis,
NotImplemented,
NegInf,
Inf,
Mut(Shared<ValueObj>),
Illegal,
}
Expand description
値オブジェクト コンパイル時評価ができ、シリアライズも可能
Variants§
Int(i32)
Nat(u64)
Float(f64)
Str(Str)
Bool(bool)
Array(Rc<[ValueObj]>)
Set(Set<ValueObj>)
Dict(Dict<ValueObj, ValueObj>)
Tuple(Rc<[ValueObj]>)
Record(Dict<Field, ValueObj>)
DataClass
Code(Box<CodeObj>)
Subr(ConstSubr)
Type(TypeObj)
None
Ellipsis
NotImplemented
NegInf
Inf
Mut(Shared<ValueObj>)
Illegal
Implementations§
source§impl ValueObj
impl ValueObj
pub fn builtin_class(t: Type) -> Self
pub fn builtin_trait(t: Type) -> Self
pub fn builtin_type(t: Type) -> Self
pub fn gen_t(gen: GenTypeObj) -> Self
pub fn is_num(&self) -> bool
pub fn is_float(&self) -> bool
pub fn is_int(&self) -> bool
pub fn is_nat(&self) -> bool
pub fn is_bool(&self) -> bool
pub const fn is_str(&self) -> bool
pub const fn is_type(&self) -> bool
pub const fn is_mut(&self) -> bool
pub fn from_str(t: Type, content: Str) -> Option<Self>
pub fn into_bytes(self, python_ver: PythonVersion) -> Vec<u8>
pub fn from_const_expr(expr: ConstExpr) -> Self
pub fn tuple_from_const_args(args: ConstArgs) -> Self
pub fn vec_from_const_args(args: ConstArgs) -> Vec<Self>
pub fn class(&self) -> Type
pub fn try_cmp(&self, other: &Self) -> Option<Ordering>
pub fn try_add(self, other: Self) -> Option<Self>
pub fn try_sub(self, other: Self) -> Option<Self>
pub fn try_mul(self, other: Self) -> Option<Self>
pub fn try_div(self, other: Self) -> Option<Self>
pub fn try_floordiv(self, other: Self) -> Option<Self>
pub fn try_gt(self, other: Self) -> Option<Self>
pub fn try_ge(self, other: Self) -> Option<Self>
pub fn try_lt(self, other: Self) -> Option<Self>
pub fn try_le(self, other: Self) -> Option<Self>
pub fn try_eq(self, other: Self) -> Option<Self>
pub fn try_ne(self, other: Self) -> Option<Self>
pub fn try_or(self, other: Self) -> Option<Self>
pub fn try_get_attr(&self, attr: &Field) -> Option<Self>
pub fn as_type(&self) -> Option<TypeObj>
Trait Implementations§
source§impl HasType for ValueObj
impl HasType for ValueObj
fn ref_t(&self) -> &Type
source§fn ref_mut_t(&mut self) -> &mut Type
fn ref_mut_t(&mut self) -> &mut Type
x.ref_mut_t()
may panic, in which case x
is Call
and x.ref_t() == Type::Failure
.