pub struct UserMemory<'a> { /* private fields */ }Expand description
User memory of a paused machine, read through layout.
Implementations§
Source§impl<'a> UserMemory<'a>
impl<'a> UserMemory<'a>
Sourcepub fn new(mem: &'a dyn Memory, layout: Layout) -> Self
pub fn new(mem: &'a dyn Memory, layout: Layout) -> Self
mem with the system pointers at layout.
Sourcepub fn with_names(self, names: &'a NameTable) -> Self
pub fn with_names(self, names: &'a NameTable) -> Self
The same view, naming commands from names (the table of the ROM
this memory runs) and writing programs, algebraics and units as
text in the display mode of the flags.
Sourcepub fn of(machine: &'a Machine) -> Result<Self, Error>
pub fn of(machine: &'a Machine) -> Result<Self, Error>
The user memory of machine (48SX, 48GX, 49G); for another model
Error::NoUserMemory.
Sourcepub fn tree(&self) -> Result<Vec<Variable>, Error>
pub fn tree(&self) -> Result<Vec<Variable>, Error>
HOME’s variables, newest first (as VARS), with every
sub-directory’s variables. Needs no decode budget: the walk sizes
objects without following ROM pointers, so its work is linear in
HOME’s nibbles (at most the address space).
Sourcepub fn current_path(&self) -> Result<Vec<String>, Error>
pub fn current_path(&self) -> Result<Vec<String>, Error>
The current directory as a path from HOME, e.g. ["HOME", "A"].
Sourcepub fn stack_addresses(&self) -> Result<Vec<u32>, Error>
pub fn stack_addresses(&self) -> Result<Vec<u32>, Error>
The addresses of the objects on the data stack, level 1 first.
Sourcepub fn stack(&self) -> Result<Vec<Object>, Error>
pub fn stack(&self) -> Result<Vec<Object>, Error>
The data stack as typed objects, level 1 first; binary integers carry the display base of flags -11 and -12.
Sourcepub fn object_at(&self, addr: u32) -> Result<Object, Error>
pub fn object_at(&self, addr: u32) -> Result<Object, Error>
The object at addr (a variable’s address from UserMemory::tree),
binary integers in the display base, text in the display mode.
Sourcepub fn stack_described(&self) -> Result<Vec<Value>, Error>
pub fn stack_described(&self) -> Result<Vec<Value>, Error>
UserMemory::stack as JSON with the calculator’s text on every
object (crate::decompile::described), in the display mode the
flags select; the texts of all levels together are capped at
crate::decompile::MAX_DESCRIBED_TEXT.
Sourcepub fn stack_top(&self) -> Result<(usize, Option<Value>), Error>
pub fn stack_top(&self) -> Result<(usize, Option<Value>), Error>
The stack’s depth and level 1 as JSON with its text
(crate::decompile::described), or None on an empty stack:
what an Edit button needs, without decoding the other levels.
Sourcepub fn object_described(&self, addr: u32) -> Result<Value, Error>
pub fn object_described(&self, addr: u32) -> Result<Value, Error>
UserMemory::object_at as JSON with the calculator’s text on
every object (crate::decompile::described).
Sourcepub fn edit_text_at(&self, addr: u32) -> Result<String, Error>
pub fn edit_text_at(&self, addr: u32) -> Result<String, Error>
The text to edit of the object at addr (a variable’s address or a
stack level’s, UserMemory::stack_addresses): decoded and written
in the display mode made fit for compiling again
(crate::decompile::edit_text).
Sourcepub fn identity_at(&self, addr: u32) -> Result<(usize, u16), Error>
pub fn identity_at(&self, addr: u32) -> Result<(usize, u16), Error>
What identifies the object at addr whatever the display mode:
its size in nibbles and BYTES’s checksum of them (storeText’s
check that the object a save replaces is the one that was opened).
Where the current menu’s pointer points (see Layout::menu_ptr;
crate::menus::Menus::number turns it into a menu number).
The index of the first key the current menu’s page shows, from 0
(0 on the first page, 6 after NXT; see Layout::menu_page).
Sourcepub fn current_variables(&self) -> Result<Vec<Variable>, Error>
pub fn current_variables(&self) -> Result<Vec<Variable>, Error>
The variables of the current directory, newest first (the VAR menu’s order): names, types and sizes only, no checksums, the sub-directories not expanded. Walks HOME down to the current directory only (its records, not their objects’ contents).
Sourcepub fn change_counter(&self) -> Result<u64, Error>
pub fn change_counter(&self) -> Result<u64, Error>
A number that changes whenever HOME (any variable anywhere in the tree), the current directory, the stack or the flags change: an FNV-1a hash of HOME’s nibbles, the system pointers, the stack’s entries and the flag words. A host polls it and re-reads only when it moves. Reads HOME once (up to the whole RAM). It hashes the stack’s pointers, not the objects they point to: an object rewritten in place at the same address would not move it.