Re-allow dynamic indexing of 'let' arrays and matrices

Spec change: https://github.com/gpuweb/gpuweb/pull/2427
Reverses: tint:867

This reverts and fixes commits:
 b6fdcc54df
 10442eff7d

Added a bunch of end-to-end tests.

Fixed: tint:1352
Change-Id: I34968243bbec1cab838c8ba50a6f027146bbfd06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/75401
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-01-06 18:11:01 +00:00
committed by Tint LUCI CQ
parent 294ce9394f
commit 3cbb136b8a
164 changed files with 2495 additions and 122 deletions

View File

@@ -126,6 +126,13 @@ class Constant {
return func(~0);
}
/// @param index the index of the scalar value
/// @return the value of the scalar `static_cast` to type T.
template <typename T>
T ElementAs(size_t index) const {
return WithScalarAt(index, [](auto val) { return static_cast<T>(val); });
}
private:
const sem::Type* type_ = nullptr;
const sem::Type* elem_type_ = nullptr;