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 Printer<'_>
impl Printer<'_>
fn error_style(&self) -> Styles
fn comment_style(&self) -> Styles
fn named_argument_label_style(&self) -> Styles
fn numeric_literal_style(&self) -> Styles
fn string_literal_style(&self) -> Styles
fn string_literal_escape_style(&self) -> Styles
fn declarative_keyword_style(&self) -> Styles
fn imperative_keyword_style(&self) -> Styles
fn spv_base_style(&self) -> Styles
fn spv_op_style(&self) -> Styles
fn spv_enumerand_name_style(&self) -> Styles
fn attr_style(&self) -> Styles
Sourcefn demote_style_for_namespace_prefix(&self, style: Styles) -> Styles
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 Printer<'_>
impl Printer<'_>
Sourcefn pretty_string_literal(&self, s: &str) -> Fragment
fn pretty_string_literal(&self, s: &str) -> Fragment
Pretty-print a string literal with escaping and styling.
Sourcefn pretty_named_argument_prefix<'b>(
&self,
name: impl Into<Cow<'b, str>>,
) -> Fragment
fn pretty_named_argument_prefix<'b>( &self, name: impl Into<Cow<'b, str>>, ) -> Fragment
Pretty-print a name: style “named argument” prefix.
Sourcefn pretty_type_ascription_suffix(&self, ty: Type) -> Fragment
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.
Sourcefn pretty_spv_opcode(
&self,
opcode_name_style: Styles,
opcode: Opcode,
) -> Fragment
fn pretty_spv_opcode( &self, opcode_name_style: Styles, opcode: Opcode, ) -> Fragment
Pretty-print a SPIR-V opcode’s name, prefixed by "spv.".
Sourcefn sanitize_spv_operand_name<'b>(&self, name: &'b str) -> Option<Cow<'b, str>>
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).
Sourcefn pretty_spv_print_tokens_for_operand(
&self,
operand: TokensForOperand<Option<Fragment>>,
) -> Fragment
fn pretty_spv_print_tokens_for_operand( &self, operand: TokensForOperand<Option<Fragment>>, ) -> Fragment
Pretty-print a spv::print::TokensForOperand (common helper used below).
Sourcefn pretty_spv_operand_from_imms(
&self,
imms: impl IntoIterator<Item = Imm>,
) -> Fragment
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).
Sourcefn pretty_spv_imm(&self, kind: OperandKind, word: u32) -> Fragment
fn pretty_spv_imm(&self, kind: OperandKind, word: u32) -> Fragment
Pretty-print a single SPIR-V (short) immediate (e.g. an enumerand).
Sourcefn pretty_spv_inst<OPF: Into<Option<Fragment>>>(
&self,
spv_inst_name_style: Styles,
opcode: Opcode,
imms: &[Imm],
printed_ids: impl IntoIterator<Item = OPF>,
) -> Fragment
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> Freeze for Printer<'a>
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> 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more