pub struct Memory {
pub addresses: Vec<Option<Primitive>>,
pub stack: Stack<Vec<Primitive>>,
pub sketch_groups: Vec<SketchGroup>,
}Expand description
KCEP’s program memory. A flat, linear list of values.
Fields§
§addresses: Vec<Option<Primitive>>Each address of memory.
stack: Stack<Vec<Primitive>>A stack where temporary values can be pushed or popped.
sketch_groups: Vec<SketchGroup>Special storage for SketchGroups.
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn set(&mut self, address: Address, value: Primitive)
pub fn set(&mut self, address: Address, value: Primitive)
Store a value in KCEP’s program memory.
Sourcepub fn set_composite<T: Value>(
&mut self,
start: Address,
composite_value: T,
) -> usize
pub fn set_composite<T: Value>( &mut self, start: Address, composite_value: T, ) -> usize
Store a value value (i.e. a value which takes up multiple addresses in memory).
Store its parts in consecutive memory addresses starting at start.
Returns how many memory addresses the data took up.
Sourcepub fn iter(&self) -> impl Iterator<Item = (usize, &Option<Primitive>)>
pub fn iter(&self) -> impl Iterator<Item = (usize, &Option<Primitive>)>
Iterate over each memory address and its value.
Sourcepub fn get_primitive<T>(&self, addr: &Address) -> Result<T, ExecutionError>
pub fn get_primitive<T>(&self, addr: &Address) -> Result<T, ExecutionError>
Get a primitive from addr. If it’s of type T, extract that T. Otherwise error.
Sourcepub fn get_size(&self, addr: &Address) -> Result<usize, ExecutionError>
pub fn get_size(&self, addr: &Address) -> Result<usize, ExecutionError>
Look for either a usize or an object/list header at the given address.
Return that usize, or the size field of the header.
Sourcepub fn get_slice(
&self,
start: Address,
len: usize,
) -> Result<Vec<Primitive>, ExecutionError>
pub fn get_slice( &self, start: Address, len: usize, ) -> Result<Vec<Primitive>, ExecutionError>
Get a range of addresses, starting at start and continuing for len more.
Sourcepub fn get_in_memory<T: Value>(
&mut self,
source: InMemory,
field_name: &'static str,
events: &mut EventWriter,
) -> Result<(T, usize), MemoryError>
pub fn get_in_memory<T: Value>( &mut self, source: InMemory, field_name: &'static str, events: &mut EventWriter, ) -> Result<(T, usize), MemoryError>
Read a T value out of memory (either addressable or stack).
Sourcepub fn debug_table_stack(&self) -> String
pub fn debug_table_stack(&self) -> String
Return a nicely-formatted table of stack.
Sourcepub fn debug_table(&self, up_to: Option<usize>) -> String
pub fn debug_table(&self, up_to: Option<usize>) -> String
Return a nicely-formatted table of memory.
Sourcepub fn last_nonempty_address(&self) -> Option<usize>
pub fn last_nonempty_address(&self) -> Option<usize>
Get the address of the last non-empty address. If none, then all addresses are empty.
Sourcepub fn next_empty_cell(&self) -> Option<usize>
pub fn next_empty_cell(&self) -> Option<usize>
Get the address of the last empty cell. If none, then all cells are occupied.
Trait Implementations§
Source§impl ReadMemory for Memory
impl ReadMemory for Memory
Source§fn get(&self, address: &Address) -> Option<&Primitive>
fn get(&self, address: &Address) -> Option<&Primitive>
Get a value from KCEP’s program memory.
Source§fn get_composite<T: Value>(
&self,
start: Address,
) -> Result<(T, usize), MemoryError>
fn get_composite<T: Value>( &self, start: Address, ) -> Result<(T, usize), MemoryError>
Get a value value (i.e. a value which takes up multiple addresses in memory).
Its parts are stored in consecutive memory addresses starting at start.
Source§fn stack_pop(&mut self) -> Result<Vec<Primitive>, MemoryError>
fn stack_pop(&mut self) -> Result<Vec<Primitive>, MemoryError>
Source§fn stack_peek(&self) -> Result<Vec<Primitive>, MemoryError>
fn stack_peek(&self) -> Result<Vec<Primitive>, MemoryError>
Auto Trait Implementations§
impl Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnwindSafe for Memory
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<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more