pub struct Memory<'a> { /* private fields */ }Expand description
A memory on a virtual machine.
Implementations§
Source§impl<'a> Memory<'a>
impl<'a> Memory<'a>
Sourcepub const fn set_register(&mut self, value: Cons)
pub const fn set_register(&mut self, value: Cons)
Sets a register.
Sourcepub fn pop_numbers<const M: usize>(&mut self) -> [Number; M]
pub fn pop_numbers<const M: usize>(&mut self) -> [Number; M]
Pops numbers from a stack.
Sourcepub fn cons(&mut self, car: Value, cdr: Cons) -> Result<Cons, Error>
pub fn cons(&mut self, car: Value, cdr: Cons) -> Result<Cons, Error>
Allocates a cons with a default tag of Type::Pair.
Sourcepub const fn allocation_index(&self) -> usize
pub const fn allocation_index(&self) -> usize
Returns the current allocation index relative an allocation start index.
Sourcepub const fn allocation_start(&self) -> usize
pub const fn allocation_start(&self) -> usize
Returns an allocation start index.
Sourcepub const fn allocation_end(&self) -> usize
pub const fn allocation_end(&self) -> usize
Returns an allocation end index.
Sourcepub const fn car_value(&self, cons: Value) -> Value
pub const fn car_value(&self, cons: Value) -> Value
Returns a value of a car field in a value assumed as a cons.
Sourcepub const fn cdr_value(&self, cons: Value) -> Value
pub const fn cdr_value(&self, cons: Value) -> Value
Returns a value of a cdr field in a value assumed as a cons.
Sourcepub fn set_raw_car(&mut self, cons: Cons, value: Value)
pub fn set_raw_car(&mut self, cons: Cons, value: Value)
Sets a raw value to a car field in a cons overwriting its tag.
Sourcepub fn set_raw_cdr(&mut self, cons: Cons, value: Value)
pub fn set_raw_cdr(&mut self, cons: Cons, value: Value)
Sets a raw value to a cdr field in a cons overwriting its tag.
Sourcepub fn set_car_value(&mut self, cons: Value, value: Value)
pub fn set_car_value(&mut self, cons: Value, value: Value)
Sets a value to a car field in a value assumed as a cons.
Sourcepub fn set_cdr_value(&mut self, cons: Value, value: Value)
pub fn set_cdr_value(&mut self, cons: Value, value: Value)
Sets a value to a cdr field in a value assumed as a cons.
Sourcepub fn operate_top(
&mut self,
operate: impl Fn(&Self, Value) -> Value,
) -> Result<(), Error>
pub fn operate_top( &mut self, operate: impl Fn(&Self, Value) -> Value, ) -> Result<(), Error>
Executes an operation against a value at the top of a stack.
Sourcepub fn list_length(&self, list: Cons) -> usize
pub fn list_length(&self, list: Cons) -> usize
Calculates a length of a list.
Sourcepub fn operate_unary(
&mut self,
operate: fn(Number) -> Number,
) -> Result<(), Error>
pub fn operate_unary( &mut self, operate: fn(Number) -> Number, ) -> Result<(), Error>
Executes an unary number operation.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Memory<'a>
impl<'a> RefUnwindSafe for Memory<'a>
impl<'a> Send for Memory<'a>
impl<'a> Sync for Memory<'a>
impl<'a> Unpin for Memory<'a>
impl<'a> !UnwindSafe for Memory<'a>
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