pub struct GlobalCtx<'a> {
pub types: &'a UniqueArena<Type>,
pub constants: &'a Arena<Constant>,
pub overrides: &'a Arena<Override>,
pub global_expressions: &'a Arena<Expression>,
}
Fields§
§types: &'a UniqueArena<Type>
§constants: &'a Arena<Constant>
§overrides: &'a Arena<Override>
§global_expressions: &'a Arena<Expression>
Implementations§
Source§impl GlobalCtx<'_>
impl GlobalCtx<'_>
Sourcepub(crate) fn eval_expr_to_u32(
&self,
handle: Handle<Expression>,
) -> Result<u32, U32EvalError>
pub(crate) fn eval_expr_to_u32( &self, handle: Handle<Expression>, ) -> Result<u32, U32EvalError>
Try to evaluate the expression in self.global_expressions
using its handle
and return it as a u32
.
Sourcepub(crate) fn eval_expr_to_u32_from(
&self,
handle: Handle<Expression>,
arena: &Arena<Expression>,
) -> Result<u32, U32EvalError>
pub(crate) fn eval_expr_to_u32_from( &self, handle: Handle<Expression>, arena: &Arena<Expression>, ) -> Result<u32, U32EvalError>
Try to evaluate the expression in the arena
using its handle
and return it as a u32
.
Sourcepub(crate) fn eval_expr_to_bool_from(
&self,
handle: Handle<Expression>,
arena: &Arena<Expression>,
) -> Option<bool>
pub(crate) fn eval_expr_to_bool_from( &self, handle: Handle<Expression>, arena: &Arena<Expression>, ) -> Option<bool>
Try to evaluate the expression in the arena
using its handle
and return it as a bool
.
pub(crate) fn eval_expr_to_literal( &self, handle: Handle<Expression>, ) -> Option<Literal>
pub(crate) fn eval_expr_to_literal_from( &self, handle: Handle<Expression>, arena: &Arena<Expression>, ) -> Option<Literal>
Trait Implementations§
Source§impl TypeContext for GlobalCtx<'_>
impl TypeContext for GlobalCtx<'_>
Format types as WGSL based on a GlobalCtx
.
This is probably good enough for diagnostic output, but it has some limitations:
-
It does not apply
Namer
renamings, to avoid collisions. -
It generates invalid WGSL for anonymous struct types.
-
It doesn’t write the lengths of override-expression-sized arrays correctly, unless the expression is just the override identifier.
Source§fn type_name(&self, handle: Handle<Type>) -> &str
fn type_name(&self, handle: Handle<Type>) -> &str
Return the name to be used for the type referred to by
handle
.Source§fn write_override<W: Write>(
&self,
handle: Handle<Override>,
out: &mut W,
) -> Result
fn write_override<W: Write>( &self, handle: Handle<Override>, out: &mut W, ) -> Result
Write the WGSL form of
override
to out
.Source§fn write_type<W: Write>(&self, handle: Handle<Type>, out: &mut W) -> Result
fn write_type<W: Write>(&self, handle: Handle<Type>, out: &mut W) -> Result
Write the type
ty
as it would appear in a value’s declaration. Read moreSource§fn write_scalar<W: Write>(&self, scalar: Scalar, out: &mut W) -> Result
fn write_scalar<W: Write>(&self, scalar: Scalar, out: &mut W) -> Result
Write the
Scalar
scalar
as a WGSL type.Source§fn write_type_resolution<W: Write>(
&self,
resolution: &TypeResolution,
out: &mut W,
) -> Result
fn write_type_resolution<W: Write>( &self, resolution: &TypeResolution, out: &mut W, ) -> Result
Write the
TypeResolution
resolution
as a WGSL type.fn write_type_conclusion<W: Write>( &self, conclusion: &Conclusion, out: &mut W, ) -> Result
fn write_type_rule<W: Write>( &self, name: &str, rule: &Rule, out: &mut W, ) -> Result
fn type_to_string(&self, handle: Handle<Type>) -> String
fn type_inner_to_string(&self, inner: &TypeInner) -> String
fn type_resolution_to_string(&self, resolution: &TypeResolution) -> String
fn type_rule_to_string(&self, name: &str, rule: &Rule) -> String
impl<'a> Copy for GlobalCtx<'a>
Auto Trait Implementations§
impl<'a> Freeze for GlobalCtx<'a>
impl<'a> RefUnwindSafe for GlobalCtx<'a>
impl<'a> Send for GlobalCtx<'a>
impl<'a> Sync for GlobalCtx<'a>
impl<'a> Unpin for GlobalCtx<'a>
impl<'a> UnwindSafe for GlobalCtx<'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
Mutably borrows from an owned value. Read more