Skip to main content

UserMemory

Struct UserMemory 

Source
pub struct UserMemory<'a> { /* private fields */ }
Expand description

User memory of a paused machine, read through layout.

Implementations§

Source§

impl<'a> UserMemory<'a>

Source

pub fn new(mem: &'a dyn Memory, layout: Layout) -> Self

mem with the system pointers at layout.

Source

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.

Source

pub fn of(machine: &'a Machine) -> Result<Self>

The user memory of machine (48SX, 48GX, 49G).

Source

pub fn layout(&self) -> Layout

The layout in use.

Source

pub fn tree(&self) -> Result<Vec<Variable>>

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).

Source

pub fn current_path(&self) -> Result<Vec<String>>

The current directory as a path from HOME, e.g. ["HOME", "A"].

Source

pub fn stack_addresses(&self) -> Result<Vec<u32>>

The addresses of the objects on the data stack, level 1 first.

Source

pub fn stack(&self) -> Result<Vec<Object>>

The data stack as typed objects, level 1 first; binary integers carry the display base of flags -11 and -12.

Source

pub fn object_at(&self, addr: u32) -> Result<Object>

The object at addr (a variable’s address from UserMemory::tree), binary integers in the display base, text in the display mode.

Source

pub fn stack_described(&self) -> Result<Vec<Value>>

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.

Source

pub fn stack_top(&self) -> Result<(usize, Option<Value>)>

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.

Source

pub fn object_described(&self, addr: u32) -> Result<Value>

UserMemory::object_at as JSON with the calculator’s text on every object (crate::decompile::described).

Source

pub fn edit_text_at(&self, addr: u32) -> Result<String>

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).

Source

pub fn identity_at(&self, addr: u32) -> Result<(usize, u16)>

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).

Source

pub fn menu_pointer(&self) -> Result<u32>

Where the current menu’s pointer points (see Layout::menu_ptr; crate::menus::Menus::number turns it into a menu number).

Source

pub fn flags(&self) -> Result<Flags>

The system and user flags.

Source

pub fn change_counter(&self) -> Result<u64>

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.

Trait Implementations§

Source§

impl<'a> Clone for UserMemory<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for UserMemory<'a>

Source§

impl Debug for UserMemory<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for UserMemory<'a>

§

impl<'a> !Send for UserMemory<'a>

§

impl<'a> !Sync for UserMemory<'a>

§

impl<'a> !UnwindSafe for UserMemory<'a>

§

impl<'a> Freeze for UserMemory<'a>

§

impl<'a> Unpin for UserMemory<'a>

§

impl<'a> UnsafeUnpin for UserMemory<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.