Struct yksom::vm::val::Val [−][src]
pub struct Val { pub val: usize, }
The core struct representing values in the language runtime: boxed and unboxed values are hidden behind this, such that they can be treated in exactly the same way.
Fields
val: usize
Implementations
impl Val
[src]
pub fn from_obj<T: Obj + 'static>(obj: T) -> Val
[src]
Create a new Val
from an object that should be allocated on the heap.
pub unsafe fn new_from_layout<T: Obj + 'static, F>(
layout: Layout,
init: F
) -> Val where
F: FnOnce(*mut T),
[src]
layout: Layout,
init: F
) -> Val where
F: FnOnce(*mut T),
Allocate memory on the heap into which an object (and, optionally, additional memory) can be stored.
Safety
layout
must be at least big enough for an object of type T
(but may optionally be
bigger) and must have at least the same alignment that T requires (but may optionally have a bigger alignment).
initwill be called with a pointer to uninitialised memory into which a fully initialised object of type
T*must* be written. After
initcompletes, the object will be considered fully initialised: failure to fully initialise it leads to undefined behaviour. Note that if additional memory was requested beyond that needed to store
Tthen that extra memory does not have to be initialised after
init` completes.
pub fn recover<T: Obj + 'static>(obj: Gc<T>) -> Self
[src]
Convert obj
into a Val
. Obj
must previously have been created via Val::from_obj
and
then turned into an actual object with tobj
: failure to follow these steps will result in
undefined behaviour.
pub fn illegal() -> Val
[src]
Create a value upon which all operations are invalid. This can be used as a sentinel or while initialising part of the system.
pub fn valkind(&self) -> ValKind
[src]
What is this Val
’s ValKind
.
pub fn downcast<T: Obj + StaticObjType + NotUnboxable>(
&self,
vm: &VM
) -> Result<Gc<T>, Box<VMError>>
[src]
&self,
vm: &VM
) -> Result<Gc<T>, Box<VMError>>
Cast a Val
into an instance of type T
(where T
must statically be a type that cannot
be boxed) or return a VMError
if the cast is invalid.
pub fn try_downcast<T: Obj + StaticObjType + NotUnboxable>(
&self,
_: &VM
) -> Option<Gc<T>>
[src]
&self,
_: &VM
) -> Option<Gc<T>>
Cast a Val
into an instance of type T
(where T
must statically be a type that cannot
be boxed) or return None
if the cast is not valid.
pub fn tobj(&self, vm: &mut VM) -> Result<Gc<ThinObj>, Box<VMError>>
[src]
Return this Val
’s box. If the Val
refers to an unboxed value, this will box it.
pub fn from_isize(vm: &mut VM, i: isize) -> Val
[src]
Create a (possibly boxed) Val
representing the isize
integer i
.
pub fn from_usize(vm: &mut VM, i: usize) -> Val
[src]
Create a (possibly boxed) Val
representing the usize
integer i
.
pub fn from_u64(vm: &mut VM, i: u64) -> Val
[src]
pub fn from_bool(vm: &VM, v: bool) -> Val
[src]
If v == true
, return a Val
representing vm.true_
, otherwise return a Val
representing vm.false_
.
pub fn as_isize(&self, vm: &mut VM) -> Result<isize, Box<VMError>>
[src]
If this Val
represents a non-bigint integer, return its value as an isize
.
pub fn as_usize(&self, vm: &mut VM) -> Result<usize, Box<VMError>>
[src]
If this Val
represents a non-bigint integer, return its value as an usize
.
pub fn as_f64(&self, vm: &mut VM) -> Result<f64, Box<VMError>>
[src]
pub fn bit_eq(&self, other: &Val) -> bool
[src]
Is this Val
bit equal to other
? This is a very strong property, generally used as a
fast proxy for “if both Val
s are GCBox
s then do they point to the same thing?” since,
in such cases, at least one of the sides has been pre-guaranteed to be a GCBox
.
impl Val
[src]
pub fn dyn_objtype(&self, vm: &mut VM) -> ObjType
[src]
What ObjType
does this Val
represent?
pub fn get_class(&self, vm: &mut VM) -> Val
[src]
What class is this Val
an instance of?
pub fn to_strval(&self, vm: &mut VM) -> Result<Val, Box<VMError>>
[src]
pub fn hashcode(&self, vm: &mut VM) -> Val
[src]
Produce a new Val
which adds other
to this.
pub fn add(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which adds other
to this.
pub fn and(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which performs a bitwise and operation with other
and this.
pub fn div(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which divides other
from this.
pub fn double_div(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which perfoms a Double divide on other
with this.
pub fn modulus(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which performs a mod operation on this with other
.
pub fn mul(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which multiplies other
to this.
pub fn remainder(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which performs a mod operation on this with other
.
pub fn shl(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which shifts self
other
bits to the left.
pub fn shr(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which shifts self
other
bits to the right, treating self
as if it
did not have a sign bit.
pub fn sqrt(&self, vm: &mut VM) -> Result<Val, Box<VMError>>
[src]
Produces a new Val
which is the square root of this.
pub fn sub(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which subtracts other
from this.
pub fn xor(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Produce a new Val
which performs a bitwise xor operation with other
and this.
pub fn ref_equals(&self, vm: &mut VM, other: Val) -> Result<Val, Box<VMError>>
[src]
Is this Val
reference equal to other
? Notice that for integers (but not Doubles)
“reference equal” is equivalent to “equals”.
impl Val
[src]
impl Val
[src]
impl Val
[src]
impl Val
[src]
impl Val
[src]
impl Val
[src]
Trait Implementations
impl Clone for Val
[src]
impl Copy for Val
[src]
impl Debug for Val
[src]
impl !NoTrace for Val
[src]
impl PartialEq<Val> for Val
[src]
impl StructuralPartialEq for Val
[src]
Auto Trait Implementations
impl RefUnwindSafe for Val
impl Send for Val
impl Sync for Val
impl Unpin for Val
impl UnwindSafe for Val
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,