Expand description
A global, singleton, mutable state - hosts almost all TeX-facing runtime information for the conversion
Re-exports§
pub use crate::common::store::Stored;pub use crate::common::local_assignments::*;
Structs§
- State
- The state efficiently bookkeeps the bindings in a TeX-like fashion.
- State
Options - state fields allowed for customization during construction
- Undo
Frame - For each of several tables (being “value”, “meaning”, “catcode” or other space of names), each table maintains the bound values, and “undo” defines the stack frames
Enums§
- Catcodes
- High-level catcode profiles
- Scope
- installation scope in the state_tables
- Table
Name - the kinds of tables bookkept in the State
Statics§
- UNITS
- Used in conversion to scaled points.
Functions§
- activate_
scope - Activates all stashed definitions for the named scope. No-op if the scope is already active.
- add_
binding_ names - Append one crate’s
(name, ext)slice. Companion toset_bindings_dispatch/set_extra_bindings_dispatch— call alongside dispatcher registration sofind_filecan resolve compile-time bindings. Duplicates are deduplicated by pointer so repeated calls from the same crate don’t inflate the fallback pool. - add_
search_ path - Global append (Perl
PushValue(SEARCHPATHS)) — a persistent search dir. - after_
assignment - run the accumulated directives from
\afterassignment - assign_
alignment - assign_
catcode - assigns a Catcode for a given character
- assign_
delcode - like
assign_catcodebut targets Delcode and its table - assign_
font - a convenience method to globally asign a
Fontto the “font” key - assign_
internal - assigns a
Storedvalue at the given key and scope Direct mirror of Perl’s free-function formLaTeXML::Core::State::assign_internal($STATE, $table, $key, $value, $scope)(Core/State.pm L140). Bypasses every dialect / lock / let-chase / admission layer Rust has accreted on top of the table mutation; used by the dump loader (Core/Dumper.pmV/Cc/Mc/Sc/Lc/Uc/Dc/Im/I/Lt) so the dump replay matches Perl exactly: one record == oneassign_internalcall. - assign_
lccode - like
assign_catcodebut targets Lccode and its table - assign_
mapping - Bind
keytovalueinside the named mapping — Perl’sAssignMapping. - assign_
mathcode - like
assign_catcodebut targets Mathcode and its table - assign_
meaning - $meaning should be a definition (for defining active control sequences) or another token, for \let
- assign_
register - assign_
register_ token assign_registervariant taking a pre-built Token — lets hot callers skip theT_CS!(&str)pin when they already have the CS cached (e.g. viaT_CS!("\\c@…")literal which routes throughpin!).- assign_
sfcode - like
assign_catcodebut targets Sfcode and its table - assign_
uccode - like
assign_catcodebut targets Uccode and its table - assign_
value - Bind
keytovaluein the value table — Perl’sAssignValue. - assign_
value_ inplace - assigns a
Storedvalue ‘inplace’: replaces the front value in whatever frame it was originally assigned in, without recording an undo entry. This matches Perl’sassignValue(key, value, 'inplace'). Used for MODE changes in enter_horizontal (switches mode without creating a new binding). - assign_
value_ inplace_ sym - Sym-keyed variant of
assign_value_inplace— skip the per-callarena::pin(key)for hot callers with a pre-pinned SymStr. - assign_
value_ sym - assigns a
Storedvalue at the given (arena ticket!) key and scope - begin_
semiverbatim - begins a semiverbatim frame, neutralizing the usual + requested characters
- binding_
exists truewhen a binding is registered for the exact(name, ext)pair. Convenience wrapper over the per-crate slices inbinding_names. Mirrorsdispatch()’s lookup but without the side effect of loading.- checkin_
value - Returns a value into its
Stored::Noneplaceholder (seecheckout_valuefor taking it) - checkout_
value - Replaces the value in question with
Stored::None(seecheckin_valuefor returning it) - clear_
prefixes - clears the global prefixes
- compute_
indirect_ model - The indirect model includes all elements allowed as direct children, and all descendents of a node that can be inserted after autoOpen’ing intermediate elements.
- convert_
unit - convert a unit name into a
f64scaling factor oversp - convert_
unit_ ratio - Convert a unit name into the exact TeX
(num, den)fraction such that a dimension ofvalueunits isfloor(round(value·65536)·num/den)scaled points (seenumeric_ops::fixpoint_unit). - current_
frame_ locked truewhen the CURRENT (front) stack frame is the locked bottom frame — i.e. there is no openable group/mode frame to pop. Popping it would FATAL.- current_
verbosity - deactivate_
scope - Removes any definitions that were associated with the named
scope. Normally not needed, since a scopes definitions are locally bound anyway. - diff_
snapshot - Compute diff from snapshot and return changed serializable entries.
- dump_
top_ frame_ keys - Starts a new level of grouping.
Note that this is lower level than C<\bgroup>;
Diagnostic helper: dump the keys in undo
0’s value table. For temporary instrumentation only — no production callers should rely on this. - end_
semiverbatim - end by just calling
pop_frame - ensure_
tag_ property - generate_
error_ stub - Generate a stub definition for an undefined control-sequence, along with appropriate error messge.
- generate_
ligature_ id - simple id generator for a ligature
- get_
active_ scopes - return the currently activated named scopes
- get_
binding_ names - Snapshot of all registered (name, ext) binding pairs across all
dispatchers. Used by
find_file(notex=true)to detect compiled-binding existence regardless of extension (cls/sty/def/pool/code.tex/…). - get_
bindings_ dispatch - get_
class_ binding_ names - Filtered view of
get_binding_names()returning ONLY class names (without.clssuffix). Used byload_classfor Perl’s prefix-match fallback (Package.pm L2702-2706). Returns a flatVec<&str>rather than per-crate slices — callers that need to preserve crate boundaries should iterateget_binding_names()directly. - get_
extra_ bindings_ dispatch - get_
frame_ depth - Determine depth of group nesting.
- get_
graphics_ paths - Mirror Perl’s
LookupValue('GRAPHICSPATHS')— a list value that all\graphicspath,\svgpath, initial source-directory prepends, andimage_candidatesconsult. Always return asVec<String>even if the value was stored asStrings(initial assignValue) orVecDequeStored(after any push/unshift). - get_
indirect_ model_ relationship - get_
input_ encoding - get_
known_ scopes - return all known named scopes
- get_
label_ mapping_ hook - get_
nomathparse_ flag - get_
prefix - gets the current value of a named prefix
- get_
prefix_ sym get_prefixwith a pre-pinned SymStr key (seecrate::pin!) — for the per-\defprefix probes inExpandable::newand friends.- get_
search_ paths - Read SEARCHPATHS from the group-scoped value table (Perl
LookupValue('SEARCHPATHS')). Mirrorsget_graphics_paths: the list is a group-scoped value, not a plain field, so an\import/\subimportgroup reverts its change at}and a package’s global add persists. - get_
staged_ snapshot - Retrieve a previously staged snapshot, if present.
- get_
tag_ property - graphics_
paths_ contains - Zero-alloc membership test for GRAPHICSPATHS. Mirrors the Perl idiom
grep { $_ eq $dir } @{ $state->lookupValue('GRAPHICSPATHS') }but without allocating an ownedVec<String>for a single boolean — the interned-symbolwith/with2family resolves each path in place. - graphics_
paths_ push_ front - Mirror Perl’s
$state->unshiftValue(GRAPHICSPATHS => $dir). Used by Core.pm-style source-directory prepends. - has_
indirect_ model - has_
meaning - has_
search_ paths - has_
value - Check if the Value table contains a given key
- hoist_
top_ frame_ meaning_ delta - Hoist every Meaning binding installed at the topmost frame since
pre_snapshotwas taken to GLOBAL scope. Idempotent: keys already inpre_snapshotare skipped. Operates on the Meaning table only — callers that need to promote Value/Catcode/etc. should add parallel helpers (none required so far). - install_
definition - A shorthand for installing definitions
- install_
undefined_ error_ constructor - Install a
Constructorfortokenwhose sole effect at digestion time is to emit<ltx:ERROR class='undefined'>content</ltx:ERROR>(the Rust equivalent of PerlDocument::makeError). It logs NOTHING — the caller is responsible for theError!/note_status. Mirrors the make_error constructor thatgenerate_error_stubinstalls for undefined commands, so undefined environments (\begin{undefinedenv}) leave the same visible<ltx:ERROR>marker as Perl instead of silently vanishing from the output. - is_
binding_ extension truewhen at least one registered binding declaresextas its extension. Used by\input’s heuristic to decide whether\input{name.<ext>}should consult the binding registry — e.g..sty,.cls,.def,.pool,code.texare all valid binding extensions, while.eps,.png,.bibare not. Matches by extension only (thenameis checked separately bydispatch()’s exact lookup).- is_
dont_ expandable - Whether token is affected by \noexpand
- is_
scope_ active - Is the named scope currently active? See
scope_active_infor why this is a front-value test and not a presence test, andsubfile_scope_at_depthfor the region marker it supports. - is_
serializable - Check whether a Stored value can be serialized for the kernel dump. Values containing closures (Primitive, Constructor, Conditional, etc.) cannot be serialized — they come from Rust engine code, not the dump. This matches Perl’s DumpFile which only serializes Expandable macros.
- is_
value_ bound - Was
namebound? Ifframeis given, check only whether it is bound in that frame (0 is the topmost). - let_i
Letmacro setter- lookup_
alignment - lookup_
bool - A bit of Perl “existence as truth” semantics mixed in with proper boolean lookup
- lookup_
bool_ sym lookup_boolvariant for hot call sites with a pre-pinned SymStr (seecrate::pin!). Skips the per-callarena::pin(key)hash lookup — significant on every-expansion hot paths.SymStris au32wrapper (Copy), so it passes by value — no borrow overhead.- lookup_
catcode - Lookup & assign a character’s Catcode
- lookup_
conditional - lookup_
definition - used for expansion & various queries Since we’re not doing digestion here, we don’t need to handle mathactive, nor cs let to executable tokens This returns a definition object, or undef
- lookup_
definition_ stored - Returns a definition as
Storedso that one can call.read_arguments - lookup_
delcode - like
lookup_catcodebut targets Delcode and its table - lookup_
digestable_ definition - Recognizes mathactive tokens in math mode and also looks for cs that have been let to other `executable’ tokens. Returns a definition object, or a “self inserting” token. Used for digestion.
- lookup_
dimension - a variant of
lookup_valuethat casts the value intoDimension - lookup_
dimension_ cs - Faithful port of Perl
LookupDimension(Package.pmL1371-1393, as widened by upstream PR #2829): try to turn the argument into a Dimension, recognizing strings, registers, …. - lookup_
expandable - lookup_
float - a variant of
lookup_valuethat casts the value intoFloat - lookup_
font - convenience method to lookup the current value at the “font” key
- lookup_
glue - a variant of
lookup_valuethat only recognizes aStored::Glue - lookup_
int - like
lookup_valuebut only recognizes Int, Bool and Number variants of Stored (default: 0) - lookup_
int_ sym lookup_intvariant for hot call sites with a pre-pinned SymStr (seecrate::pin!). Skips the per-callarena::pin(key)hash lookup — the sibling oflookup_bool_sym, added for the per-conditionalif_count/if_limitprobes (Conditional::invokefires on every\if/\ifx/\ifnum/…).- lookup_
lccode - like
lookup_catcodebut targets Lccode and its table - lookup_
mapping - lookup_
mapping_ sym - Sym-keyed variant — skip the per-call
arena::pin(map)for hot callers with a pre-pinned map key (e.g. viapin!("siunitx_macros")). - lookup_
mathcode - like
lookup_catcodebut targets Mathcode and its table - lookup_
mathcode_ sym - lookup_
mathfont - convenience method to lookup the current value at the “mathfont” key
- lookup_
meaning - Get the “Meaning” of a token.
- lookup_
muglue - a variant of
lookup_valuethat only recognizes aStored::Glue - lookup_
number - a variant of
lookup_valuethat casts the value intoNumber - lookup_
register - lookup_
register_ definition - A specialized version of
lookup_definitionfor registers, since we can’t adequately perform multi-dispatch when we have a “Self: Sized” for the Definition trait object. - lookup_
register_ quiet - Quiet sibling of
lookup_registerfor call sites that mirror Perl’s explicitlookupDefinition(cs) && $defn->isRegister ? $defn->valueOf : <default>guard — e.g. TeX_Tables\lx@text@intercol/\lx@math@intercol(TeX_Tables.pool.ltxmlL639/L646), where a document may legitimately\renewcommanda length register (\tabcolsep/\arraycolsep) into a plain macro. In that case the register-ness is genuinely gone in Perl too, and Perl silently falls back to its default (Dimension(0)) with no warning. ReturnsNone(no warning) when the CS is undefined or is not a register, so the caller can apply its own faithful default. - lookup_
register_ token - Token-keyed variant of
lookup_register— saves the per-callT_CS!(&str)pin for hot callers with a cached CS token. - lookup_
sfcode - like
lookup_catcodebut targets Sfcode and its table - lookup_
string - like
lookup_value, but casts the entry into a String (empty if None) - lookup_
string_ from_ sym lookup_stringvariant using a pre-pinned SymStr key.- lookup_
string_ sym - like
lookup_value, but casts the entry into a SymStr from the string interner (pin!("")if None) - lookup_
token - a variant of
lookup_valuethat only recognizes aStored::Token - lookup_
token_ sym - a variant of
lookup_tokentaking an already-pinned SymStr key — avoids the per-callarena::pin(key)hash lookup. - lookup_
tokens - a variant of
lookup_valuethat casts the response intoTokens - lookup_
uccode - like
lookup_catcodebut targets Uccode and its table - lookup_
value - The value bound to
key, orNonewhen nothing is bound — Perl’sLookupValue. - lookup_
vecdeque - like
lookup_valuebut only recognizesStored::VecDequeStored - meaning_
key - The key under which a token’s meaning is stored. All
\special_relax-family tokens (\noexpand’d forms — the bare\special_relaxand every\special_relax\x01<shadowed>) resolve under the bare\special_relaxname: they share its\relaxmeaning, faithful to TeX where a\noexpand’d token has relax meaning regardless of which token it shadows. The shadowed identity is recovered separately viaToken::noexpand_shadowed(delimited matching only). Use this anywhere a token’s name keys a meaning lookup or a “same control sequence?” comparison. Cheap on the common path: non-CS tokens short-circuit before any string access. - opened_
sources_ snapshot - Snapshot of the opened-sources read-log (see
record_opened_source). - pop_
daemon_ frame - pop_
frame - Ends the current level of grouping.
Note that this is lower level than
\egroup; - pop_
value - pops the last value in a named
Stored::VecDequeStoredqueue, if any - push_
daemon_ frame - push_
frame - push_
pending_ resource - push_
tokens - Pushes Tokens into a
Stored::Tokensvalue when defined, or assigns when new. - push_
value - manage a (global) list of values
- record_
opened_ source - Record a named source in the opened-sources read-log. Called from
Mouth::createfor file and cached-content mouths — a cold path (one call per file open, not per token). - remove_
meaning_ global - Remove a token’s meaning entirely — the token becomes undefined, as if it
had never been defined, so a later use takes the normal undefined-CS error
path naming the token itself. Bypasses the group-undo journal: intended
ONLY for format-bootstrap time (no user groups open), where a format layer
retracts a definition inherited from a lower layer that the emulated
format must not expose (e.g. plain.tex’s
\+in a LaTeX session — real LaTeX is INITEX-based and never defines it). - remove_
value - inline lookup_value after which globally assign an empty Tokens() to undo
- remove_
value_ sym remove_valuevariant for hot call sites with a pre-pinned SymStr (seecrate::pin!) — added forafter_assignment, which fires on every\def/\let/register assignment.- remove_
vecdeque - reset_
pending_ resources - reset_
thread_ state - Free every definition/register/box this thread accumulated, returning
all three
Statesingletons (STATE,STD_STATE,STY_STATE) to a fresh, empty baseline and the rotation toMain. - search_
paths_ push_ front - Global prepend (Perl
UnshiftValue(SEARCHPATHS)) — a persistent search dir. - set_
bindings_ dispatch - set_
extra_ bindings_ dispatch - set_
indirect_ model - set_
input_ encoding - set_
label_ mapping_ hook - set_
nomathparse_ flag - set_
prefix - Set one of the definition prefixes global, etc (only global matters!)
- set_
search_ paths - Replace SEARCHPATHS GLOBALLY (Perl
AssignValue(SEARCHPATHS => [...], 'global')). For the local-by-default\importscoping, useset_search_paths_local. - set_
search_ paths_ local - Replace SEARCHPATHS in the CURRENT group only (Perl
AssignValue(SEARCHPATHS => [...])default-local): reverted when the enclosing\import/\subimportgroup closes. This is what makesimport.styfaithful without an explicit save/restore stack. - set_
source_ map_ flag - set_
state - shift_
value - snapshot_
top_ frame_ meaning_ keys - Snapshot of the keys currently bound at the topmost (calling) undo frame
for the Meaning table. Used by Perl-style autoload triggers that need to
promote everything a package’s load just installed at this scope to
GLOBAL — without that promotion, sibling autoload triggers fired AFTER
a group pop would re-fire on a now-undefined sibling CS (the canonical
case is
\begin{subequations}triggering amsmath autoload at depth=N, then a later\begin{align}at depth=0 finding\alignundefined because amsmath’s depth=N install was popped on\end{subequations}). - source_
map_ enabled - Whether source-locator (
--source-map) tracking + emission is on. Read by the source-provenance machinery (mouth token-start capture,Document::absorbdata-sourceposstamping) to stay zero-cost when off. Seedocs/performance/SOURCE_PROVENANCE.md. - source_
table_ snapshot - Snapshot of the
sourcestable (index = tag) for emitting the document-level tag→file header. - source_
tag - Find-or-append a source file in the document-level
sourcestable, returning its integertag(index). The per-elementdata-sourceposattribute carries this compact integer rather than a path — the Source-Map-v3sourcesconvention (compact + anonymisable). Only called on the source-map path. Seedocs/performance/SOURCE_PROVENANCE.md§0.1. - stage_
snapshot - Take a snapshot now and store it under a named key for later retrieval.
Intended for phased engine init (e.g.
stage_snapshot("bootstrap")called right afterlatex_bootstraphas loaded). - stage_
snapshot_ value - Stage an already-taken snapshot under a named key. Used by callers
(like
ini_tex) that want to snapshot at a specific point without waiting for a pool hook. - subfile_
scope_ at_ depth - Named scope bracketing a subfile LaTeXML included itself — a
standalonechild’s preamble, an\imported file. Real LaTeX has no group at either spot (standalone gobbles the child preamble; import restores its paths by plain\defafter the\input), so a package loaded inside one is an artifact of LaTeXML executing what the real packages skip. Bindings that open such a bracket activate this scope;require_packagereads it to decide whether a load must outlive the bracket. See OXIDIZED_DESIGN #65. - subfile_
scope_ here - The subfile scope for the CURRENT frame depth — what a bracket activates on
opening, and what
require_packagetests before hoisting. - take_
pending_ resources - take_
snapshot - Take a snapshot of the current State (for dump diff).
- try_
lookup_ int lookup_intvariant that never panics on a live mutable borrow.- undo_
depth - Undo-stack depth (open TeX groups) — pass-1 streaming telemetry.
- unshift_
value - use_
main_ state - use_
std_ state - use_
sty_ state - with_
font_ info - with_
mapping - manage a (global) hash of values
- with_
mapping_ keys - with_
mapping_ sym - with_
meaning - Closure-based variant of
lookup_meaning— avoids the per-callStored::clone()when the caller only needs to inspect the meaning (e.g. extract a CS Token from an Expandable/Primitive definition). Stored::clone is ~1% of total instructions on siunitx-heavy fixtures (5M+ calls per run, each cloning a full Stored enum). This helper borrows the stored value instead. - with_
search_ paths - with_
stacked_ values - with_
stacked_ values_ sym - Sym-keyed variant of
with_stacked_values. - with_
tag_ property - with_
tag_ property_ mut - with_
value - with_
value_ mut - with_
value_ sym - Sym-keyed variant of
with_value— avoids the per-callarena::pin(key). - with_
vecdeque - x_
equals XEqualscheck for two token arguments
Type Aliases§
- Assignment
Count - Ledger for stacked assignments
- Stash
Table - The
(table_name, key, value)contents of a stored table of assignments - Table
- The type of values that are storable by the different namespaced “tables” in State.