pub struct Map<S> { /* private fields */ }
Expand description
Map is a map type where the keys are control sequence names and the values are TeX commands.
There are a number of design goals for the map:
-
Make retrieving the function for a command very fast. This is achieved primarily by storing command functions by themselves in an array. The index in the array is the control sequence name, which is an integer when interned. This implementation choice means fast-as-possible lookups. Storing the function by itself means there is good cache locality.
-
Insert built in commands at the start insert_built_in(cs_name, cmd),
-
Insert variable commands that aren’t there at the start, but will be in the future. E.g., \countdef register_built_in(cmd) <- must have a unique ID. Is type ID stable across binary builds? Maybe need to use a string ID instead? But then need to feed that the library using this registered
-
Should we enforce that the previous two steps can only be done at creation time? Probably Maybe initialize the map using Map<cs_name, cmd> and
Vec<cmd>
. Can provide cs_name<->str wrapper at the VM level -
While running, insert macros insert_macro(&str, macro)
-
While running, alias commands by current name or using the special ID inserts alias_control_sequence(cs_name, cs_name) -> undefined control sequence error alias_registered_built_in(cs_name, cmd_id, variable_addr) alias_character(cs_name, token::Token)