mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 22:41:07 +01:00
[naga wgsl-in] Doc fixes.
This commit is contained in:
1 parent
71f186a032
commit
85bd8b45bd
2 files changed
+36
-1
No files matched your search
@@ -2627,7 +2627,9 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
let ident = match *ident {
|
||||
ast::IdentExpr::Unresolved(ident) => ident,
|
||||
ast::IdentExpr::Local(_) => {
|
||||
return Err(Box::new(Error::UnexpectedExprForTypeExpression(ident_span)))
|
||||
// Since WGSL only supports module-scope type definitions and
|
||||
// aliases, a local identifier can't possibly refer to a type.
|
||||
return Err(Box::new(Error::UnexpectedExprForTypeExpression(ident_span)));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2638,10 +2640,15 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
return Err(Box::new(Error::UnexpectedExprForTypeExpression(ident_span)));
|
||||
};
|
||||
|
||||
// Type generators can only be predeclared, so since `ident` refers
|
||||
// to a module-scope declaration, the template parameter list should
|
||||
// be empty.
|
||||
tl.finish(ctx)?;
|
||||
return Ok(handle);
|
||||
}
|
||||
|
||||
// If `ident` doesn't resolve to a module-scope declaration, then it
|
||||
// must resolve to a predeclared type or type generator.
|
||||
let ty = conv::map_predeclared_type(&ctx.enable_extensions, ident_span, ident)?
|
||||
.ok_or_else(|| Box::new(Error::UnknownIdent(ident_span, ident)))?;
|
||||
let ty = self.finalize_type(ctx, ty, &mut tl, alias_name)?;
|
||||
@@ -2651,6 +2658,23 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
Ok(ty)
|
||||
}
|
||||
|
||||
/// Construct an [`ir::Type`] from a [`conv::PredeclaredType`] and a list of
|
||||
/// template parameters.
|
||||
///
|
||||
/// If we're processing a type alias, then `alias_name` is the name we
|
||||
/// should use in the new `ir::Type`.
|
||||
///
|
||||
/// For example, when parsing `vec3<f32>`, the caller would pass:
|
||||
///
|
||||
/// - for `ty`, [`TypeGenerator::Vector`], and
|
||||
///
|
||||
/// - for `tl`, an iterator producing a single [`Expression::Ident`] representing `f32`.
|
||||
///
|
||||
/// From those arguments this function will return a handle for the
|
||||
/// [`ir::Type`] representing `vec3<f32>`.
|
||||
///
|
||||
/// [`TypeGenerator::Vector`]: conv::TypeGenerator::Vector
|
||||
/// [`Expression::Ident`]: crate::front::wgsl::parse::ast::Expression::Ident
|
||||
fn finalize_type(
|
||||
&mut self,
|
||||
ctx: &mut ExpressionContext<'source, '_, '_>,
|
||||
|
||||
@@ -137,6 +137,17 @@ impl<'iter, 'source> TemplateListIter<'iter, 'source> {
|
||||
let (enumerant, span) = ctx.enumerant(expr)?;
|
||||
conv::map_access_mode(enumerant, span)
|
||||
}
|
||||
|
||||
/// Update `space` with an access mode from `self`, if appropriate.
|
||||
///
|
||||
/// If `space` is [`Storage`], and there is another template parameter in
|
||||
/// `self`, parse it as a storage mode and mutate `space` accordingly. If
|
||||
/// there are no more template parameters, treat that like `read`.
|
||||
///
|
||||
/// If `space` is some other address space, don't consume any template
|
||||
/// parameters.
|
||||
///
|
||||
/// [`Storage`]: ir::AddressSpace::Storage
|
||||
pub fn maybe_access_mode(
|
||||
&mut self,
|
||||
space: &mut ir::AddressSpace,
|
||||
|
||||
Reference in new issue
Block a user