Struct naga::front::wgsl::lower::StatementContext

source ·
pub struct StatementContext<'source, 'temp, 'out> {
    ast_expressions: &'temp Arena<Expression<'source>>,
    types: &'temp Arena<Type<'source>>,
    globals: &'temp mut FastHashMap<&'source str, LoweredGlobalDecl>,
    local_table: &'temp mut FastHashMap<Handle<Local>, Declared<Typed<Handle<Expression>>>>,
    const_typifier: &'temp mut Typifier,
    typifier: &'temp mut Typifier,
    function: &'out mut Function,
    named_expressions: &'out mut FastIndexMap<Handle<Expression>, (String, Span)>,
    module: &'out mut Module,
    local_expression_kind_tracker: &'temp mut ExpressionKindTracker,
    global_expression_kind_tracker: &'temp mut ExpressionKindTracker,
}
Expand description

State for lowering a statement within a function.

Fields§

§ast_expressions: &'temp Arena<Expression<'source>>

A reference to TranslationUnit::expressions for the translation unit we’re lowering.

§types: &'temp Arena<Type<'source>>

A reference to TranslationUnit::types for the translation unit we’re lowering.

§globals: &'temp mut FastHashMap<&'source str, LoweredGlobalDecl>

The map from the names of module-scope declarations to the Naga IR Handles we have built for them, owned by Lowerer::lower.

§local_table: &'temp mut FastHashMap<Handle<Local>, Declared<Typed<Handle<Expression>>>>

A map from each ast::Local handle to the Naga expression we’ve built for it:

  • WGSL function arguments become Naga FunctionArgument expressions.

  • WGSL var declarations become Naga LocalVariable expressions.

  • WGSL let declararations become arbitrary Naga expressions.

This always borrows the local_table local variable in Lowerer::function.

§const_typifier: &'temp mut Typifier§typifier: &'temp mut Typifier§function: &'out mut Function§named_expressions: &'out mut FastIndexMap<Handle<Expression>, (String, Span)>

Stores the names of expressions that are assigned in let statement Also stores the spans of the names, for use in errors.

§module: &'out mut Module§local_expression_kind_tracker: &'temp mut ExpressionKindTracker

Which Expressions in self.naga_expressions are const expressions, in the WGSL sense.

According to the WGSL spec, a const expression must not refer to any let declarations, even if those declarations’ initializers are themselves const expressions. So this tracker is not simply concerned with the form of the expressions; it is also tracking whether WGSL says we should consider them to be const. See the use of force_non_const in the code for lowering let bindings.

§global_expression_kind_tracker: &'temp mut ExpressionKindTracker

Implementations§

source§

impl<'a, 'temp> StatementContext<'a, 'temp, '_>

source

fn as_const<'t>( &'t mut self, block: &'t mut Block, emitter: &'t mut Emitter, ) -> ExpressionContext<'a, 't, 't>
where 'temp: 't,

source

fn as_expression<'t>( &'t mut self, block: &'t mut Block, emitter: &'t mut Emitter, ) -> ExpressionContext<'a, 't, 't>
where 'temp: 't,

source

fn as_global(&mut self) -> GlobalContext<'a, '_, '_>

source

fn invalid_assignment_type( &self, expr: Handle<Expression>, ) -> InvalidAssignmentType

Auto Trait Implementations§

§

impl<'source, 'temp, 'out> Freeze for StatementContext<'source, 'temp, 'out>

§

impl<'source, 'temp, 'out> RefUnwindSafe for StatementContext<'source, 'temp, 'out>

§

impl<'source, 'temp, 'out> Send for StatementContext<'source, 'temp, 'out>

§

impl<'source, 'temp, 'out> Sync for StatementContext<'source, 'temp, 'out>

§

impl<'source, 'temp, 'out> Unpin for StatementContext<'source, 'temp, 'out>

§

impl<'source, 'temp, 'out> !UnwindSafe for StatementContext<'source, 'temp, 'out>

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.