pub struct State<'a> {Show 15 fields
pub registers: &'a mut Vec<Data>,
pub fns: &'a mut Vec<Function>,
pub structs: &'a mut Vec<Struct>,
pub enums: &'a mut Vec<EnumType>,
pub pools: &'a mut Pools,
pub instr_src: &'a mut Vec<InstrSrc>,
pub fn_registers: &'a mut Vec<Vec<u16>>,
pub dyn_libs: &'a mut Vec<Dynamiclib>,
pub allocated_arg_count: &'a mut usize,
pub allocated_call_depth: &'a mut usize,
pub const_registers: &'a mut FxHashMap<Data, u16>,
pub free_registers: &'a mut Vec<u16>,
pub sources: &'a mut Vec<Source>,
pub reserved_registers: FxHashSet<u16>,
pub namespace: &'a mut Namespace,
}Fields§
§registers: &'a mut Vec<Data>§fns: &'a mut Vec<Function>§structs: &'a mut Vec<Struct>§enums: &'a mut Vec<EnumType>§pools: &'a mut Pools§instr_src: &'a mut Vec<InstrSrc>§fn_registers: &'a mut Vec<Vec<u16>>§dyn_libs: &'a mut Vec<Dynamiclib>§allocated_arg_count: &'a mut usize§allocated_call_depth: &'a mut usize§const_registers: &'a mut FxHashMap<Data, u16>§free_registers: &'a mut Vec<u16>§sources: &'a mut Vec<Source>§reserved_registers: FxHashSet<u16>§namespace: &'a mut NamespaceImplementations§
Source§impl State<'_>
impl State<'_>
Sourcepub fn free_reg(&mut self, id: u16, v: &[Variable])
pub fn free_reg(&mut self, id: u16, v: &[Variable])
Marks a register as free, allowing it to later be reused by alloc_reg.
The register is marked as free iff:
- the register isn’t tied to any variable
- the register isn’t a constant register
- the register isn’t reserved in
reserved_registers - the register isn’t already marked as free
Sourcepub fn alloc_reg(&mut self) -> u16
pub fn alloc_reg(&mut self) -> u16
Allocates a register. It free_registers isn’t empty, it will reuse the latest one. Else, it will allocate a new one.
Sourcepub fn alloc_reg_tgt(&mut self, tgt_id: Option<u16>) -> u16
pub fn alloc_reg_tgt(&mut self, tgt_id: Option<u16>) -> u16
Allocates a register, reusing tgt_id if it holds some register id.
If tgt_id == None, it calls alloc_reg().
Sourcepub fn free_scope_registers(
&mut self,
regs_before: u16,
scope_instrs: &[Instr],
v: &[Variable],
)
pub fn free_scope_registers( &mut self, regs_before: u16, scope_instrs: &[Instr], v: &[Variable], )
Frees registers that are written by instructions in scope_instrs.
Sourcepub fn free_loop_scope_registers(
&mut self,
regs_before: u16,
scope_instrs: &[Instr],
v: &[Variable],
)
pub fn free_loop_scope_registers( &mut self, regs_before: u16, scope_instrs: &[Instr], v: &[Variable], )
Similar to free_scope_registers, but also frees CloneArray template registers. Only call this after a loop ends.
Sourcepub fn add_to_src(&mut self, ctx: Ctx, output: &[Instr], span: Span)
pub fn add_to_src(&mut self, ctx: Ctx, output: &[Instr], span: Span)
Associates the last instruction in output with span and adds the InstrSrc to instr_src.
This allows runtime errors to be traced back to span in the source code.
Auto Trait Implementations§
impl<'a> Freeze for State<'a>
impl<'a> RefUnwindSafe for State<'a>
impl<'a> !Send for State<'a>
impl<'a> !Sync for State<'a>
impl<'a> Unpin for State<'a>
impl<'a> UnsafeUnpin for State<'a>
impl<'a> !UnwindSafe for State<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);