pub enum Value {
}Expand description
A value, as the virtual machine holds one.
The variants mirror the reference VM’s value types. Strings and lists
appear twice: as constants (an offset into the image’s constant pool)
and as objects (an ObjId of a string or list object).
Variants§
Nil
nil: false, and the absence of a value.
True
true.
Empty
No value at all. Marks unused slots; programs never see it.
Int(i32)
A 32-bit integer.
Obj(ObjId)
An object reference.
Prop(PropId)
A property ID.
SString(u32)
A constant string, by constant pool offset.
DString(u32)
A constant string that displays itself when evaluated as a property.
List(u32)
A constant list, by constant pool offset.
CodeOfs(u32)
Method code, by code pool offset. Only property values have this type; evaluating the property calls the code.
FuncPtr(u32)
A function pointer, by code pool offset.
Enum(u32)
An enumerator.
BifPtr
A pointer to a function the VM implements.
Fields
ObjX(ObjId)
An object to invoke when the property holding it is evaluated.
BifPtrX
A VM function to call when the property holding it is evaluated.
Fields
NativeCode(NativeDesc)
A method the VM implements, as found by a property lookup that asked not to call it.
Implementations§
Source§impl Value
impl Value
Sourcepub const HOLDER_SIZE: usize = 5
pub const HOLDER_SIZE: usize = 5
Size of a value as images encode it: a type byte and four data bytes.
Sourcepub const fn obj_or_nil(id: ObjId) -> Self
pub const fn obj_or_nil(id: ObjId) -> Self
An object reference, or nil for the invalid ID.
Sourcepub const fn obj_id(self) -> ObjId
pub const fn obj_id(self) -> ObjId
The object ID, or the invalid ID for anything but an object.
Sourcepub const fn is_invocable_prop(self) -> bool
pub const fn is_invocable_prop(self) -> bool
Whether evaluating a property with this value runs code.
Sourcepub fn to_holder(self) -> [u8; 5]
pub fn to_holder(self) -> [u8; 5]
Encode a value in the five-byte form images and saved states use.
Sourcepub fn from_holder(b: &[u8]) -> Self
pub fn from_holder(b: &[u8]) -> Self
Decode a value from the five-byte form images use.
Type codes that cannot appear in an image decode as nil.
Trait Implementations§
impl Copy for Value
impl Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Forget for Value
impl Freeze for Value
impl Move for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.