Enum erg_compiler::ty::value::ValueObj
source · pub enum ValueObj {
Show 21 variants
Int(i32),
Nat(u64),
Float(Float),
Str(Str),
Bool(bool),
List(ArcArray<ValueObj>),
UnsizedList(Box<ValueObj>),
Set(Set<ValueObj>),
Dict(Dict<ValueObj, ValueObj>),
Tuple(ArcArray<ValueObj>),
Record(Dict<Field, ValueObj>),
DataClass {
name: Str,
fields: Dict<Field, ValueObj>,
},
Code(Box<CodeObj>),
Subr(ConstSubr),
Type(TypeObj),
None,
Ellipsis,
NotImplemented,
NegInf,
Inf,
Failure,
}
Expand description
値オブジェクト コンパイル時評価ができ、シリアライズも可能(Typeなどはシリアライズ不可)
Variants§
Int(i32)
Nat(u64)
Float(Float)
Str(Str)
Bool(bool)
List(ArcArray<ValueObj>)
UnsizedList(Box<ValueObj>)
Set(Set<ValueObj>)
Dict(Dict<ValueObj, ValueObj>)
Tuple(ArcArray<ValueObj>)
Record(Dict<Field, ValueObj>)
DataClass
Code(Box<CodeObj>)
Subr(ConstSubr)
Type(TypeObj)
None
Ellipsis
NotImplemented
NegInf
Inf
different from Float.Inf
Failure
Implementations§
source§impl ValueObj
impl ValueObj
pub const fn builtin_class(t: Type) -> Self
pub const fn builtin_trait(t: Type) -> Self
pub fn builtin_type(t: Type) -> Self
pub const fn gen_t(gen: GenTypeObj) -> Self
pub fn tuple<V: Into<ValueObj>>(elems: Vec<V>) -> Self
pub const fn is_none(&self) -> bool
pub const fn is_num(&self) -> bool
pub const fn is_float(&self) -> bool
pub const fn is_int(&self) -> bool
pub const fn is_nat(&self) -> bool
pub const fn is_bool(&self) -> bool
pub const fn is_true(&self) -> bool
pub const fn is_false(&self) -> bool
pub const fn is_str(&self) -> bool
pub const fn is_type(&self) -> bool
pub const fn is_inited(&self) -> bool
pub fn is_complete(&self) -> bool
pub const fn is_container(&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 as_int(&self) -> Option<i32>
pub fn as_float(&self) -> Option<f64>
pub fn as_str(&self) -> Option<&Str>
pub fn try_binary(self, other: Self, op: OpKind) -> Option<Self>
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_pow(self, other: Self) -> Option<Self>
pub fn try_mod(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, ctx: &Context) -> Option<TypeObj>
pub fn map_t(self, f: &mut impl FnMut(Type) -> Type) -> Self
pub fn try_map_t<E>( self, f: &mut impl FnMut(Type) -> Result<Type, E>, ) -> Result<Self, E>
pub fn map_tp(self, f: &mut impl FnMut(TyParam) -> TyParam) -> Self
pub fn try_map_tp<E>( self, f: &mut impl FnMut(TyParam) -> Result<TyParam, E>, ) -> Result<Self, E>
pub fn replace_t(self, target: &Type, to: &Type) -> Self
pub fn replace_tp(self, target: &TyParam, to: &TyParam) -> Self
pub fn contains(&self, val: &ValueObj) -> bool
pub fn contains_type(&self, target: &Type) -> bool
pub fn contains_tp(&self, target: &TyParam) -> bool
pub fn has_type_satisfies(&self, f: impl Fn(&Type) -> bool + Copy) -> bool
pub fn has_unbound_var(&self) -> bool
pub fn has_undoable_linked_var(&self) -> bool
pub fn has_qvar(&self) -> bool
pub fn contains_tvar(&self, target: &FreeTyVar) -> bool
pub fn qvars(&self) -> Set<(Str, Constraint)>
pub fn typarams(&self) -> Vec<TyParam>
pub fn contained_ts(&self) -> Set<Type>
pub fn dereference(&mut self)
pub fn variables(&self) -> Set<Str>
Trait Implementations§
source§impl HasType for ValueObj
impl HasType for ValueObj
source§impl LimitedDisplay for ValueObj
impl LimitedDisplay for ValueObj
impl Eq for ValueObj
Auto Trait Implementations§
impl Freeze for ValueObj
impl RefUnwindSafe for ValueObj
impl Send for ValueObj
impl Sync for ValueObj
impl Unpin for ValueObj
impl UnwindSafe for ValueObj
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)