Termisu::Terminfo::Tparm::Operations
Operations reference tables for tparm processor.
This module documents the operation set of the tparm stack machine. The terminfo parametrized string format uses a stack-based language where operations pop operands from the stack, compute results, and push them back.
NOTE: These tables are kept as documentation/reference; actual dispatch lives in Processor's inlined case/when methods (dispatch_binary_op, dispatch_non_binary_op and friends), which avoid per-call hash lookups and Proc indirection.
Operation Categories
- Binary: Two-operand operations (arithmetic, bitwise, comparison, logical)
- Output: Format and output the top of stack (%d, %s, %c, %%)
- Variable: Parameter access (%p), variable storage (%P), retrieval (%g)
- Constant: Push literal values (%{n}, %'c')
- Special: Control flow (%?), increment (%i), unary ops (%!, %~, %l)
Performance
Optimized for high-frequency operations like cursor positioning (cup) and color setting (setaf/setab) which are called thousands of times per frame.
Constants
All non-binary operation characters for fast membership testing. Used to quickly determine if a character is a known operation.
Binary operations - arithmetic, bitwise, comparison, logical.
All binary ops pop two values (right first, then left), compute, and push result. Division and modulo return 0 on divide-by-zero to prevent crashes.
Constant operations - push literal integer or character values.
Output format operations - pop and write to output buffer.
Special operations - control flow, unary operations, and special commands.
Variable operations - parameter push and variable get/set.