pub struct CodeTable { /* private fields */ }Expand description
A table of per-character codes with a default function.
Storage is a two-level page table: 256-character pages, allocated on first assignment and filled with the defaults. Lookups are two array indexings, with no hashing, which matters because the scanner consults these tables for every character.
Implementations§
Source§impl CodeTable
impl CodeTable
Sourcepub fn new(default: fn(u32) -> i64) -> Self
pub fn new(default: fn(u32) -> i64) -> Self
A table where every character has value default(c).
Sourcepub fn pages(&self) -> &[Option<Rc<Page>>]
pub fn pages(&self) -> &[Option<Rc<Page>>]
The pages allocated, by number (see crate::fingerprint).
Sourcepub fn define_in_place(&mut self, c: u32, val: i64, cur: u16) -> bool
pub fn define_in_place(&mut self, c: u32, val: i64, cur: u16) -> bool
Assigns val to c at level cur when that needs no save-stack
entry (the value is unchanged, or was defined at level cur, or
cur is level one). Returns false, changing nothing, otherwise.
Sourcepub fn define_identity(&mut self, upto: u32, cur: u16) -> CodeTable
pub fn define_identity(&mut self, upto: u32, cur: u16) -> CodeTable
\lccode c = c (or the like) for every c < upto, at level cur
(above level one, in a group where no character has been assigned
yet): the bulk form of that many local assignments. Returns the
table as it was, from which the save-stack entry restores exactly the
characters whose value changed.
Sourcepub fn restore_identity(&mut self, old: &CodeTable, upto: u32)
pub fn restore_identity(&mut self, old: &CodeTable, upto: u32)
Undoes define_identity at the end of
the group, as the individual save-stack entries would: every
character it changed gets its old value and level back, unless it
has been assigned globally since.
Sourcepub fn default_fn(&self) -> fn(u32) -> i64
pub fn default_fn(&self) -> fn(u32) -> i64
The default function of this table.
Sourcepub fn dump_pages(&self) -> Vec<(usize, [i64; 256])>
pub fn dump_pages(&self) -> Vec<(usize, [i64; 256])>
The values of every allocated page that differs from the defaults, as (page number, values), for format dumping.