pub struct TemplateElaboratedIdent<'a> {
pub ident: IdentExpr<'a>,
pub ident_span: Span,
pub template_list: Vec<Handle<Expression<'a>>>,
pub template_list_span: Span,
}Expand description
An identifier with optional template parameters.
Following the WGSL specification (see the template_list non-terminal),
TemplateElaboratedIdent represents all template parameters as expressions:
even parameters to type generators, like the f32 in vec3<f32>, are Type
Expressions.
§Examples
-
A use of a global variable
colorswould be anExpression::Ident(v), wherevis anTemplateElaboratedIdentwhoseidentisIdentExpr::Unresolved("colors"). Lowering will resolve this to a reference to the global variable. -
The type
f32in a variable declaration is represented as aTemplateElaboratedIdentwhoseidentisIdentExpr::Unresolved("f32"). Lowering will resolve this to WGSL’s predeclaredf32type. -
The type
vec3<f32>can be represented as aTemplateElaboratedIdentwhoseidentisIdentExpr::Unresolved("vec3"), and whosetemplate_listhas one element: anExpressionIdent(v)wherevis a nestedTemplateElaboratedIdentrepresentingf32as described above. -
The type
array<vec3<f32>, 4>has"array"as itsident, and then a two-elementtemplate_list:-
template_list[0]is anExpression::Ident(v)wherevis a nestedTemplateElaboratedIdentrepresentingvec3<f32>as described above. -
template_list[1]is anExpressionrepresenting4.
-
After indexing the module to ensure that declarations appear before uses,
lowering can see which declaration a given TemplateElaboratedIdents
ident refers to. The declaration then determines how to interpret the
template_list.
Fields§
§ident: IdentExpr<'a>§ident_span: Span§template_list: Vec<Handle<Expression<'a>>>If non-empty, the template parameters following the identifier.
template_list_span: Span