usecrate::diagnostic_filter::DiagnosticFilterNode; usecrate::front::wgsl::parse::directive::enable_extension::EnableExtensions; usecrate::front::wgsl::parse::number::Number; usecrate::front::wgsl::Scalar; usecrate::{Arena, FastIndexSet, Handle, Span}; use std::hash::Hash;
#[derive(Debug, Default)] pubstruct TranslationUnit<'a> { pub enable_extensions: EnableExtensions, pub decls: Arena<GlobalDecl<'a>>, /// The common expressions arena for the entire translation unit. /// /// All functions, global initializers, array lengths, etc. store their /// expressions here. We apportion these out to individual Naga /// [`Function`]s' expression arenas at lowering time. Keeping them all in a /// single arena simplifies handling of things like array lengths (which are /// effectively global and thus don't clearly belong to any function) and /// initializers (which can appear in both function-local and module-scope /// contexts). /// /// [`Function`]: crate::Function pub expressions: Arena<Expression<'a>>,
/// Non-user-defined types, like `vec4<f32>` or `array<i32, 10>`. /// /// These are referred to by `Handle<ast::Type<'a>>` values. /// User-defined types are referred to by name until lowering. pub types: Arena<Type<'a>>,
/// Arena for all diagnostic filter rules parsed in this module, including those in functions. /// /// See [`DiagnosticFilterNode`] for details on how the tree is represented and used in /// validation. pub diagnostic_filters: Arena<DiagnosticFilterNode>, /// The leaf of all `diagnostic(…)` directives in this module. /// /// See [`DiagnosticFilterNode`] for details on how the tree is represented and used in /// validation. pub diagnostic_filter_leaf: Option<Handle<DiagnosticFilterNode>>,
}
/// A reference to a module-scope definition or predeclared object. /// /// Each [`GlobalDecl`] holds a set of these values, to be resolved to /// specific definitions later. To support de-duplication, `Eq` and /// `Hash` on a `Dependency` value consider only the name, not the /// source location at which the reference occurs. #[derive(Debug)] pubstruct Dependency<'a> { /// The name referred to. pub ident: &'a str,
/// The location at which the reference to that name occurs. pub usage: Span,
}
/// The size of an [`Array`] or [`BindingArray`]. /// /// [`Array`]: Type::Array /// [`BindingArray`]: Type::BindingArray #[derive(Debug, Copy, Clone)] pubenum ArraySize<'a> { /// The length as a constant expression.
Constant(Handle<Expression<'a>>),
Dynamic,
}
/// A type at the head of a [`Construct`] expression. /// /// WGSL has two types of [`type constructor expressions`]: /// /// - Those that fully specify the type being constructed, like /// `vec3<f32>(x,y,z)`, which obviously constructs a `vec3<f32>`. /// /// - Those that leave the component type of the composite being constructed /// implicit, to be inferred from the argument types, like `vec3(x,y,z)`, /// which constructs a `vec3<T>` where `T` is the type of `x`, `y`, and `z`. /// /// This enum represents the head type of both cases. The `PartialFoo` variants /// represent the second case, where the component type is implicit. /// /// This does not cover structs or types referred to by type aliases. See the /// documentation for [`Construct`] and [`Call`] expressions for details. /// /// [`Construct`]: Expression::Construct /// [`type constructor expressions`]: https://gpuweb.github.io/gpuweb/wgsl/#type-constructor-expr /// [`Call`]: Expression::Call #[derive(Debug)] pubenum ConstructorType<'a> { /// A scalar type or conversion: `f32(1)`.
Scalar(Scalar),
/// A vector construction whose component type is inferred from the /// argument: `vec3(1.0)`.
PartialVector { size: crate::VectorSize },
/// A vector construction whose component type is written out: /// `vec3<f32>(1.0)`.
Vector {
size: crate::VectorSize,
ty: Handle<Type<'a>>,
ty_span: Span,
},
/// A matrix construction whose component type is inferred from the /// argument: `mat2x2(1,2,3,4)`.
PartialMatrix {
columns: crate::VectorSize,
rows: crate::VectorSize,
},
/// A matrix construction whose component type is written out: /// `mat2x2<f32>(1,2,3,4)`.
Matrix {
columns: crate::VectorSize,
rows: crate::VectorSize,
ty: Handle<Type<'a>>,
ty_span: Span,
},
/// An array whose component type and size are inferred from the arguments: /// `array(3,4,5)`.
PartialArray,
/// An array whose component type and size are written out: /// `array<u32, 4>(3,4,5)`.
Array {
base: Handle<Type<'a>>,
size: ArraySize<'a>,
},
/// Constructing a value of a known Naga IR type. /// /// This variant is produced only during lowering, when we have Naga types /// available, never during parsing. Type(Handle<crate::Type>),
}
/// A type constructor expression. /// /// This is only used for expressions like `KEYWORD(EXPR...)` and /// `KEYWORD<PARAM>(EXPR...)`, where `KEYWORD` is a [type-defining keyword] like /// `vec3`. These keywords cannot be shadowed by user definitions, so we can /// tell that such an expression is a construction immediately. /// /// For ordinary identifiers, we can't tell whether an expression like /// `IDENTIFIER(EXPR, ...)` is a construction expression or a function call /// until we know `IDENTIFIER`'s definition, so we represent those as /// [`Call`] expressions. /// /// [type-defining keyword]: https://gpuweb.github.io/gpuweb/wgsl/#type-defining-keywords /// [`Call`]: Expression::Call
Construct {
ty: ConstructorType<'a>,
ty_span: Span,
components: Vec<Handle<Expression<'a>>>,
},
Unary {
op: crate::UnaryOperator,
expr: Handle<Expression<'a>>,
},
AddrOf(Handle<Expression<'a>>),
Deref(Handle<Expression<'a>>),
Binary {
op: crate::BinaryOperator,
left: Handle<Expression<'a>>,
right: Handle<Expression<'a>>,
},
/// A function call or type constructor expression. /// /// We can't tell whether an expression like `IDENTIFIER(EXPR, ...)` is a /// construction expression or a function call until we know `IDENTIFIER`'s /// definition, so we represent everything of that form as one of these /// expressions until lowering. At that point, [`Lowerer::call`] has /// everything's definition in hand, and can decide whether to emit a Naga /// [`Constant`], [`As`], [`Splat`], or [`Compose`] expression. /// /// [`Lowerer::call`]: Lowerer::call /// [`Constant`]: crate::Expression::Constant /// [`As`]: crate::Expression::As /// [`Splat`]: crate::Expression::Splat /// [`Compose`]: crate::Expression::Compose
Call {
function: Ident<'a>,
arguments: Vec<Handle<Expression<'a>>>,
},
Index {
base: Handle<Expression<'a>>,
index: Handle<Expression<'a>>,
},
Member {
base: Handle<Expression<'a>>,
field: Ident<'a>,
},
Bitcast {
expr: Handle<Expression<'a>>,
to: Handle<Type<'a>>,
ty_span: Span,
},
}
#[derive(Debug)] /// A placeholder for a local variable declaration. /// /// See [`super::ExpressionContext::locals`] for more information. pubstruct Local;
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet am 2026-06-23)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.