mirror of
https://github.com/storytold/wgpu.git
synced 2026-12-01 10:34:57 +01:00
Document some parts of ConstantEvaluator. (#2489)
This commit is contained in:
1 parent
ca69a6b372
commit
44ca6ac5b3
1 file changed
+11
@@ -117,9 +117,13 @@ impl ConstantEvaluator<'_> {
|
||||
| Expression::Compose { .. }
|
||||
| Expression::Splat { .. } => Ok(expr),
|
||||
Expression::Constant(c) => {
|
||||
// Are we working in a function's expression arena, or the
|
||||
// module's constant expression arena?
|
||||
if let Some(const_expressions) = self.const_expressions {
|
||||
// Deep-copy the constant's value into our arena.
|
||||
self.copy_from(self.constants[c].init, const_expressions)
|
||||
} else {
|
||||
// "See through" the constant and use its initializer.
|
||||
Ok(self.constants[c].init)
|
||||
}
|
||||
}
|
||||
@@ -783,6 +787,13 @@ impl ConstantEvaluator<'_> {
|
||||
Ok(self.register_evaluated_expr(expr, span))
|
||||
}
|
||||
|
||||
/// Deep copy `expr` from `expressions` into `self.expressions`.
|
||||
///
|
||||
/// Return the root of the new copy.
|
||||
///
|
||||
/// This is used when we're evaluating expressions in a function's
|
||||
/// expression arena that refer to a constant: we need to copy the
|
||||
/// constant's value into the function's arena so we can operate on it.
|
||||
fn copy_from(
|
||||
&mut self,
|
||||
handle: Handle<Expression>,
|
||||
|
||||
Reference in new issue
Block a user