Struct spirt::print::Printer

source ·
pub struct Printer<'a> {
    cx: &'a Context,
    use_styles: IndexMap<Use, UseStyle, BuildHasherDefault<FxHasher>>,
    attrs_with_spv_name_in_use: FxHashMap<AttrSet, &'a Inst>,
}

Fields§

§cx: &'a Context§use_styles: IndexMap<Use, UseStyle, BuildHasherDefault<FxHasher>>§attrs_with_spv_name_in_use: FxHashMap<AttrSet, &'a Inst>

Subset of the Plan’s original attrs_to_unique_spv_name map, only containing those entries which are actively used for UseStyle::Named values in use_styles, and therefore need to be hidden from attributes.

Implementations§

source§

impl<'a> Printer<'a>

source

fn new(plan: &Plan<'a>) -> Self

source

pub fn cx(&self) -> &'a Context

source§

impl Printer<'_>

source

fn error_style(&self) -> Styles

source

fn comment_style(&self) -> Styles

source

fn named_argument_label_style(&self) -> Styles

source

fn numeric_literal_style(&self) -> Styles

source

fn string_literal_style(&self) -> Styles

source

fn string_literal_escape_style(&self) -> Styles

source

fn declarative_keyword_style(&self) -> Styles

source

fn imperative_keyword_style(&self) -> Styles

source

fn spv_base_style(&self) -> Styles

source

fn spv_op_style(&self) -> Styles

source

fn spv_enumerand_name_style(&self) -> Styles

source

fn attr_style(&self) -> Styles

source

fn demote_style_for_namespace_prefix(&self, style: Styles) -> Styles

Compute a suitable style for an unintrusive foo. “namespace prefix”, from a more typical style (by shrinking and/or reducing visibility).

source§

impl<'a> Printer<'a>

source

fn pretty_string_literal(&self, s: &str) -> Fragment

Pretty-print a string literal with escaping and styling.

source

fn pretty_named_argument_prefix<'b>( &self, name: impl Into<Cow<'b, str>> ) -> Fragment

Pretty-print a name: style “named argument” prefix.

source

fn pretty_type_ascription_suffix(&self, ty: Type) -> Fragment

Pretty-print a : T style “type ascription” suffix.

This should be used everywhere some type ascription notation is needed, to ensure consistency across all such situations.

source

fn pretty_spv_opcode( &self, opcode_name_style: Styles, opcode: Opcode ) -> Fragment

Pretty-print a SPIR-V opcode’s name, prefixed by "spv.".

source

fn sanitize_spv_operand_name<'b>(&self, name: &'b str) -> Option<Cow<'b, str>>

Clean up a spv::print::TokensForOperand string (common helper used below).

source

fn pretty_spv_print_tokens_for_operand( &self, operand: TokensForOperand<Option<Fragment>> ) -> Fragment

Pretty-print a spv::print::TokensForOperand (common helper used below).

source

fn pretty_spv_operand_from_imms( &self, imms: impl IntoIterator<Item = Imm> ) -> Fragment

Pretty-print a single SPIR-V operand from only immediates, potentially composed of an enumerand with parameters (which consumes more immediates).

source

fn pretty_spv_imm(&self, kind: OperandKind, word: u32) -> Fragment

Pretty-print a single SPIR-V (short) immediate (e.g. an enumerand).

source

fn pretty_spv_inst<OPF: Into<Option<Fragment>>>( &self, spv_inst_name_style: Styles, opcode: Opcode, imms: &[Imm], printed_ids: impl IntoIterator<Item = OPF> ) -> Fragment

Pretty-print an arbitrary SPIR-V opcode with its SPIR-V operands being given by imms (non-IDs) and printed_ids (IDs, printed by the caller).

printed_ids elements can be None to indicate an ID operand is implicit in SPIR-T, and should not be printed (e.g. decorations’ target IDs). But if printed_ids doesn’t need to have None elements, it can skip the Option entirely (i.e. have pretty::Fragment elements directly).

Immediate and ID operands are interleaved (in the order mandated by the SPIR-V standard) and together wrapped in parentheses, e.g.: spv.OpFoo(spv.FooEnum.Bar, v1, 123, v2, "baz").

This should be used everywhere a SPIR-V instruction needs to be printed, to ensure consistency across all such situations.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Printer<'a>

§

impl<'a> !Send for Printer<'a>

§

impl<'a> !Sync for Printer<'a>

§

impl<'a> Unpin for Printer<'a>

§

impl<'a> !UnwindSafe for Printer<'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>,

§

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>,

§

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.