tint/resolver: Add `DataType<T>::ElementType` typedef
To point to the element type of T. Helpful for tests.
Change-Id: I41b5ad0923375e11509acf67959a849da3d1ebcf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91421
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h
index cdc29ea..a0d71e5 100644
--- a/src/tint/resolver/resolver_test_helper.h
+++ b/src/tint/resolver/resolver_test_helper.h
@@ -189,6 +189,9 @@
/// Helper for building bool types and expressions
template <>
struct DataType<bool> {
+ /// The element type
+ using ElementType = bool;
+
/// false as bool is not a composite type
static constexpr bool is_composite = false;
@@ -211,6 +214,9 @@
/// Helper for building i32 types and expressions
template <>
struct DataType<i32> {
+ /// The element type
+ using ElementType = i32;
+
/// false as i32 is not a composite type
static constexpr bool is_composite = false;
@@ -233,6 +239,9 @@
/// Helper for building u32 types and expressions
template <>
struct DataType<u32> {
+ /// The element type
+ using ElementType = u32;
+
/// false as u32 is not a composite type
static constexpr bool is_composite = false;
@@ -255,6 +264,9 @@
/// Helper for building f32 types and expressions
template <>
struct DataType<f32> {
+ /// The element type
+ using ElementType = f32;
+
/// false as f32 is not a composite type
static constexpr bool is_composite = false;
@@ -277,6 +289,9 @@
/// Helper for building f16 types and expressions
template <>
struct DataType<f16> {
+ /// The element type
+ using ElementType = f16;
+
/// false as f16 is not a composite type
static constexpr bool is_composite = false;
@@ -299,6 +314,9 @@
/// Helper for building abstract float types and expressions
template <>
struct DataType<AFloat> {
+ /// The element type
+ using ElementType = AFloat;
+
/// false as AFloat is not a composite type
static constexpr bool is_composite = false;
@@ -320,6 +338,9 @@
/// Helper for building abstract integer types and expressions
template <>
struct DataType<AInt> {
+ /// The element type
+ using ElementType = AInt;
+
/// false as AFloat is not a composite type
static constexpr bool is_composite = false;
@@ -341,6 +362,9 @@
/// Helper for building vector types and expressions
template <uint32_t N, typename T>
struct DataType<vec<N, T>> {
+ /// The element type
+ using ElementType = T;
+
/// true as vectors are a composite type
static constexpr bool is_composite = true;
@@ -381,6 +405,9 @@
/// Helper for building matrix types and expressions
template <uint32_t N, uint32_t M, typename T>
struct DataType<mat<N, M, T>> {
+ /// The element type
+ using ElementType = T;
+
/// true as matrices are a composite type
static constexpr bool is_composite = true;
@@ -423,6 +450,9 @@
/// Helper for building alias types and expressions
template <typename T, int ID>
struct DataType<alias<T, ID>> {
+ /// The element type
+ using ElementType = T;
+
/// true if the aliased type is a composite type
static constexpr bool is_composite = DataType<T>::is_composite;
@@ -466,6 +496,9 @@
/// Helper for building pointer types and expressions
template <typename T>
struct DataType<ptr<T>> {
+ /// The element type
+ using ElementType = T;
+
/// true if the pointer type is a composite type
static constexpr bool is_composite = false;
@@ -496,6 +529,9 @@
/// Helper for building array types and expressions
template <uint32_t N, typename T>
struct DataType<array<N, T>> {
+ /// The element type
+ using ElementType = T;
+
/// true as arrays are a composite type
static constexpr bool is_composite = true;