Skip to main content

Module decompile

Module decompile 

Source
Expand description

The calculator’s text for objects: numbers in the display mode, data objects as the stack shows them, programs, algebraics (infix) and unit expressions rebuilt from their elements.

The rules (number formats, spacing, the operators’ precedence and parentheses) are those the ROM’s own decompiler shows, checked against it by the ROM-gated oracle test (saturnus-kermit e2e, decompiler_matches_the_rom); wiki: protocols/rpl-libraries for how commands are named.

Text is capped at MAX_TEXT characters; longer text ends in TRUNCATED. The texts described adds are capped together at MAX_DESCRIBED_TEXT.

Structs§

Settings
The display settings the text depends on.

Enums§

NumberFormat
How reals are shown (flags -49 and -50, digits in -45 to -48).

Constants§

MAX_DESCRIBED_TEXT
Most characters of text fields one described call (one stack read) adds. Every object inside another carries its own text, so a string nested 64 levels deep is written 64 times: the decode budget bounds the objects, this bounds the copies of their text. 4 M characters, a few MB of JSON; the 49G’s whole RAM (256 KB) holds at most 256 K characters of strings.
MAX_TEXT
Longest text produced for one object, in characters.
TRUNCATED
Appended to text cut at MAX_TEXT.

Functions§

described
obj as JSON (its serde shape) with the calculator’s own text in a text field on the object and on every object inside it (a list’s items, a tagged object’s object, an array’s elements), each as it is written in that place; no text where there is none (has_text). A front end shows and copies these texts and formats nothing itself. An error past MAX_DESCRIBED_TEXT characters of text.
display
obj as the stack shows it as a whole level.
edit_text
Text of obj to edit and compile again (the palette’s editor), in settings made by Settings::for_editing: text, but a tagged object as :tag:object, which compiles. An error for an object with no such text: a part without text (has_text), a string holding " (the calculator has no way to write one), or text cut at MAX_TEXT.
has_text
Whether the calculator’s text of obj is known in full: every program, algebraic and unit inside it was decompiled and every command has a name (or is an XLIB name, shown by its numbers).
text
The calculator’s text of obj as a whole stack level or a variable’s value (display; a name with its quotes, as the stack shows one), or None if a part of it has none (has_text).