Skip to main content

PrintFormatter

Struct PrintFormatter 

Source
pub struct PrintFormatter<'a> {
    pub env: &'a Environment,
    pub seen_identifiers: HashSet<IdentifierId>,
    pub seen_scopes: HashSet<ScopeId>,
    pub output: Vec<String>,
    pub indent_level: usize,
}
Expand description

Shared formatter state used by both HIR and reactive printers.

Both DebugPrinter structs delegate to this for formatting shared constructs like Places, Identifiers, Scopes, Types, InstructionValues, etc.

Fields§

§env: &'a Environment§seen_identifiers: HashSet<IdentifierId>§seen_scopes: HashSet<ScopeId>§output: Vec<String>§indent_level: usize

Implementations§

Source§

impl<'a> PrintFormatter<'a>

Source

pub fn new(env: &'a Environment) -> Self

Source

pub fn line(&mut self, text: &str)

Source

pub fn line_raw(&mut self, text: &str)

Write a line without adding indentation (used when copying pre-formatted output)

Source

pub fn indent(&mut self)

Source

pub fn dedent(&mut self)

Source

pub fn to_string_output(&self) -> String

Source

pub fn format_effect(&self, effect: &AliasingEffect) -> String

Source

pub fn format_place_field(&mut self, field_name: &str, place: &Place)

Source

pub fn format_identifier(&mut self, id: IdentifierId)

Source

pub fn format_scope_field(&mut self, field_name: &str, scope_id: ScopeId)

Source

pub fn format_type(&self, type_id: TypeId) -> String

Source

pub fn format_type_value(&self, ty: &Type) -> String

Source

pub fn format_lvalue(&mut self, field_name: &str, lv: &LValue)

Source

pub fn format_pattern(&mut self, pattern: &Pattern)

Source

pub fn format_argument(&mut self, arg: &PlaceOrSpread, index: usize)

Source

pub fn format_instruction_value( &mut self, value: &InstructionValue, inner_func_formatter: Option<&dyn Fn(&mut PrintFormatter<'_>, &HirFunction)>, )

Format an InstructionValue. The inner_func_formatter callback is invoked for FunctionExpression/ObjectMethod to format the inner HirFunction. If None, a placeholder is printed instead.

Source

pub fn format_errors(&mut self, error: &CompilerError)

Auto Trait Implementations§

§

impl<'a> Freeze for PrintFormatter<'a>

§

impl<'a> RefUnwindSafe for PrintFormatter<'a>

§

impl<'a> Send for PrintFormatter<'a>

§

impl<'a> Sync for PrintFormatter<'a>

§

impl<'a> Unpin for PrintFormatter<'a>

§

impl<'a> UnsafeUnpin for PrintFormatter<'a>

§

impl<'a> UnwindSafe for PrintFormatter<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.