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
Handle
s 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 NagaLocalVariable
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 Expression
s 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