Remove type:: prefix in type/ folder.

Remove type:: namespaces added during the file moves.

Bug: tint:1718
Change-Id: I9862296cf93aad92e6c2b2e54d06d1c53d3a9b09
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113428
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
dan sinclair 2022-12-08 22:21:24 +00:00 committed by Dan Sinclair
parent 946858ad56
commit 98705d417e
63 changed files with 479 additions and 533 deletions

View File

@ -29,7 +29,7 @@ size_t AbstractFloat::Hash() const {
return utils::Hash(TypeInfo::Of<AbstractFloat>().full_hashcode);
}
bool AbstractFloat::Equals(const type::Type& other) const {
bool AbstractFloat::Equals(const Type& other) const {
return other.Is<AbstractFloat>();
}

View File

@ -29,7 +29,7 @@ size_t AbstractInt::Hash() const {
return utils::Hash(TypeInfo::Of<AbstractInt>().full_hashcode);
}
bool AbstractInt::Equals(const type::Type& other) const {
bool AbstractInt::Equals(const Type& other) const {
return other.Is<AbstractInt>();
}

View File

@ -19,7 +19,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::AbstractNumeric);
namespace tint::type {
AbstractNumeric::AbstractNumeric()
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -23,7 +23,7 @@ namespace tint::type {
/// The base class for abstract-int and abstract-float types.
/// @see https://www.w3.org/TR/WGSL/#types-for-creation-time-constants
class AbstractNumeric : public Castable<AbstractNumeric, type::Type> {
class AbstractNumeric : public Castable<AbstractNumeric, Type> {
public:
/// Constructor
AbstractNumeric();

View File

@ -27,20 +27,20 @@ namespace tint::type {
namespace {
type::TypeFlags FlagsFrom(const type::Type* element, const type::ArrayCount* count) {
type::TypeFlags flags;
TypeFlags FlagsFrom(const Type* element, const ArrayCount* count) {
TypeFlags flags;
// Only constant-expression sized arrays are constructible
if (count->Is<type::ConstantArrayCount>()) {
if (count->Is<ConstantArrayCount>()) {
if (element->IsConstructible()) {
flags.Add(type::TypeFlag::kConstructable);
flags.Add(TypeFlag::kConstructable);
}
if (element->HasCreationFixedFootprint()) {
flags.Add(type::TypeFlag::kCreationFixedFootprint);
flags.Add(TypeFlag::kCreationFixedFootprint);
}
}
if (!count->Is<type::RuntimeArrayCount>()) {
if (!count->Is<RuntimeArrayCount>()) {
if (element->HasFixedFootprint()) {
flags.Add(type::TypeFlag::kFixedFootprint);
flags.Add(TypeFlag::kFixedFootprint);
}
}
return flags;
@ -52,8 +52,8 @@ const char* const Array::kErrExpectedConstantCount =
"array size is an override-expression, when expected a constant-expression.\n"
"Was the SubstituteOverride transform run?";
Array::Array(const type::Type* element,
const type::ArrayCount* count,
Array::Array(const Type* element,
const ArrayCount* count,
uint32_t align,
uint32_t size,
uint32_t stride,
@ -72,7 +72,7 @@ size_t Array::Hash() const {
return utils::Hash(TypeInfo::Of<Array>().full_hashcode, count_, align_, size_, stride_);
}
bool Array::Equals(const type::Type& other) const {
bool Array::Equals(const Type& other) const {
if (auto* o = other.As<Array>()) {
// Note: implicit_stride is not part of the type_name string as this is
// derived from the element type

View File

@ -28,7 +28,7 @@
namespace tint::type {
/// Array holds the type information for Array nodes.
class Array final : public Castable<Array, type::Type> {
class Array final : public Castable<Array, Type> {
public:
/// An error message string stating that the array count was expected to be a constant
/// expression. Used by multiple writers and transforms.
@ -45,8 +45,8 @@ class Array final : public Castable<Array, type::Type> {
/// @param implicit_stride the number of bytes from the start of one element
/// of the array to the start of the next element, if there was no `@stride`
/// attribute applied.
Array(type::Type const* element,
const type::ArrayCount* count,
Array(Type const* element,
const ArrayCount* count,
uint32_t align,
uint32_t size,
uint32_t stride,
@ -57,17 +57,17 @@ class Array final : public Castable<Array, type::Type> {
/// @param other the other type to compare against
/// @returns true if the this type is equal to the given type
bool Equals(const type::Type& other) const override;
bool Equals(const Type& other) const override;
/// @return the array element type
type::Type const* ElemType() const { return element_; }
Type const* ElemType() const { return element_; }
/// @returns the number of elements in the array.
const type::ArrayCount* Count() const { return count_; }
const ArrayCount* Count() const { return count_; }
/// @returns the array count if the count is a const-expression, otherwise returns nullopt.
inline std::optional<uint32_t> ConstantCount() const {
if (auto* count = count_->As<type::ConstantArrayCount>()) {
if (auto* count = count_->As<ConstantArrayCount>()) {
return count->value;
}
return std::nullopt;
@ -102,8 +102,8 @@ class Array final : public Castable<Array, type::Type> {
std::string FriendlyName(const SymbolTable& symbols) const override;
private:
type::Type const* const element_;
const type::ArrayCount* count_;
Type const* const element_;
const ArrayCount* count_;
const uint32_t align_;
const uint32_t size_;
const uint32_t stride_;

View File

@ -22,29 +22,22 @@ namespace {
using ArrayTest = TestHelper;
TEST_F(ArrayTest, CreateSizedArray) {
auto* a =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* b =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* c =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
auto* d =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
auto* e =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
auto* f =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
auto* g =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
auto* a = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* b = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* c = create<Array>(create<U32>(), create<ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
auto* d = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
auto* e = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
auto* f = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
auto* g = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
EXPECT_EQ(a->ElemType(), create<type::U32>());
EXPECT_EQ(a->Count(), create<type::ConstantArrayCount>(2u));
EXPECT_EQ(a->ElemType(), create<U32>());
EXPECT_EQ(a->Count(), create<ConstantArrayCount>(2u));
EXPECT_EQ(a->Align(), 4u);
EXPECT_EQ(a->Size(), 8u);
EXPECT_EQ(a->Stride(), 32u);
EXPECT_EQ(a->ImplicitStride(), 16u);
EXPECT_FALSE(a->IsStrideImplicit());
EXPECT_FALSE(a->Count()->Is<type::RuntimeArrayCount>());
EXPECT_FALSE(a->Count()->Is<RuntimeArrayCount>());
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
@ -55,27 +48,21 @@ TEST_F(ArrayTest, CreateSizedArray) {
}
TEST_F(ArrayTest, CreateRuntimeArray) {
auto* a =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
auto* b =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
auto* c =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 5u, 8u, 32u, 32u);
auto* d =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 9u, 32u, 32u);
auto* e =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 33u, 32u);
auto* f =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 33u, 17u);
auto* a = create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
auto* b = create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 8u, 32u, 32u);
auto* c = create<Array>(create<U32>(), create<RuntimeArrayCount>(), 5u, 8u, 32u, 32u);
auto* d = create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 9u, 32u, 32u);
auto* e = create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 8u, 33u, 32u);
auto* f = create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 8u, 33u, 17u);
EXPECT_EQ(a->ElemType(), create<type::U32>());
EXPECT_EQ(a->Count(), create<type::RuntimeArrayCount>());
EXPECT_EQ(a->ElemType(), create<U32>());
EXPECT_EQ(a->Count(), create<RuntimeArrayCount>());
EXPECT_EQ(a->Align(), 4u);
EXPECT_EQ(a->Size(), 8u);
EXPECT_EQ(a->Stride(), 32u);
EXPECT_EQ(a->ImplicitStride(), 32u);
EXPECT_TRUE(a->IsStrideImplicit());
EXPECT_TRUE(a->Count()->Is<type::RuntimeArrayCount>());
EXPECT_TRUE(a->Count()->Is<RuntimeArrayCount>());
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
@ -85,20 +72,13 @@ TEST_F(ArrayTest, CreateRuntimeArray) {
}
TEST_F(ArrayTest, Hash) {
auto* a =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* b =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* c =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
auto* d =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
auto* e =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
auto* f =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
auto* g =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
auto* a = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* b = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* c = create<Array>(create<U32>(), create<ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
auto* d = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
auto* e = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
auto* f = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
auto* g = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
@ -109,20 +89,13 @@ TEST_F(ArrayTest, Hash) {
}
TEST_F(ArrayTest, Equals) {
auto* a =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* b =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* c =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
auto* d =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
auto* e =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
auto* f =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
auto* g =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
auto* a = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* b = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* c = create<Array>(create<U32>(), create<ConstantArrayCount>(3u), 4u, 8u, 32u, 16u);
auto* d = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 5u, 8u, 32u, 16u);
auto* e = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 9u, 32u, 16u);
auto* f = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 33u, 16u);
auto* g = create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 33u, 17u);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
@ -130,42 +103,38 @@ TEST_F(ArrayTest, Equals) {
EXPECT_FALSE(a->Equals(*e));
EXPECT_FALSE(a->Equals(*f));
EXPECT_FALSE(a->Equals(*g));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(ArrayTest, FriendlyNameRuntimeSized) {
auto* arr =
create<Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 0u, 4u, 4u, 4u);
auto* arr = create<Array>(create<I32>(), create<RuntimeArrayCount>(), 0u, 4u, 4u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32>");
}
TEST_F(ArrayTest, FriendlyNameStaticSized) {
auto* arr =
create<Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u, 20u, 4u, 4u);
auto* arr = create<Array>(create<I32>(), create<ConstantArrayCount>(5u), 4u, 20u, 4u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "array<i32, 5>");
}
TEST_F(ArrayTest, FriendlyNameRuntimeSizedNonImplicitStride) {
auto* arr =
create<Array>(create<type::I32>(), create<type::RuntimeArrayCount>(), 0u, 4u, 8u, 4u);
auto* arr = create<Array>(create<I32>(), create<RuntimeArrayCount>(), 0u, 4u, 8u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32>");
}
TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) {
auto* arr =
create<Array>(create<type::I32>(), create<type::ConstantArrayCount>(5u), 4u, 20u, 8u, 4u);
auto* arr = create<Array>(create<I32>(), create<ConstantArrayCount>(5u), 4u, 20u, 8u, 4u);
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array<i32, 5>");
}
TEST_F(ArrayTest, IsConstructable) {
auto* fixed_sized =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* named_override_sized = create<Array>(
create<type::U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
create<U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
auto* unnamed_override_sized = create<Array>(
create<type::U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
create<U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
auto* runtime_sized =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
EXPECT_TRUE(fixed_sized->IsConstructible());
EXPECT_FALSE(named_override_sized->IsConstructible());
@ -175,13 +144,13 @@ TEST_F(ArrayTest, IsConstructable) {
TEST_F(ArrayTest, HasCreationFixedFootprint) {
auto* fixed_sized =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* named_override_sized = create<Array>(
create<type::U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
create<U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
auto* unnamed_override_sized = create<Array>(
create<type::U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
create<U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
auto* runtime_sized =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
EXPECT_TRUE(fixed_sized->HasCreationFixedFootprint());
EXPECT_FALSE(named_override_sized->HasCreationFixedFootprint());
@ -191,13 +160,13 @@ TEST_F(ArrayTest, HasCreationFixedFootprint) {
TEST_F(ArrayTest, HasFixedFootprint) {
auto* fixed_sized =
create<Array>(create<type::U32>(), create<type::ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
create<Array>(create<U32>(), create<ConstantArrayCount>(2u), 4u, 8u, 32u, 16u);
auto* named_override_sized = create<Array>(
create<type::U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
create<U32>(), create<sem::NamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
auto* unnamed_override_sized = create<Array>(
create<type::U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
create<U32>(), create<sem::UnnamedOverrideArrayCount>(nullptr), 4u, 8u, 32u, 16u);
auto* runtime_sized =
create<Array>(create<type::U32>(), create<type::RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
create<Array>(create<U32>(), create<RuntimeArrayCount>(), 4u, 8u, 32u, 16u);
EXPECT_TRUE(fixed_sized->HasFixedFootprint());
EXPECT_TRUE(named_override_sized->HasFixedFootprint());

View File

@ -23,12 +23,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Atomic);
namespace tint::type {
Atomic::Atomic(const type::Type* subtype)
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,
}),
subtype_(subtype) {
TINT_ASSERT(AST, !subtype->Is<type::Reference>());
TINT_ASSERT(AST, !subtype->Is<Reference>());
}
size_t Atomic::Hash() const {

View File

@ -22,7 +22,7 @@
namespace tint::type {
/// A atomic type.
class Atomic final : public Castable<Atomic, type::Type> {
class Atomic final : public Castable<Atomic, Type> {
public:
/// Constructor
/// @param subtype the atomic type
@ -37,7 +37,7 @@ class Atomic final : public Castable<Atomic, type::Type> {
/// @param other the other type to compare against
/// @returns true if the this type is equal to the given type
bool Equals(const Type& other) const override;
bool Equals(const type::Type& other) const override;
/// @returns the atomic type
const type::Type* Type() const { return subtype_; }

View File

@ -22,33 +22,33 @@ namespace {
using AtomicTest = TestHelper;
TEST_F(AtomicTest, Creation) {
auto* a = create<Atomic>(create<type::I32>());
auto* b = create<Atomic>(create<type::I32>());
auto* c = create<Atomic>(create<type::U32>());
EXPECT_TRUE(a->Type()->Is<type::I32>());
auto* a = create<Atomic>(create<I32>());
auto* b = create<Atomic>(create<I32>());
auto* c = create<Atomic>(create<U32>());
EXPECT_TRUE(a->Type()->Is<I32>());
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
}
TEST_F(AtomicTest, Hash) {
auto* a = create<Atomic>(create<type::I32>());
auto* b = create<Atomic>(create<type::I32>());
auto* c = create<Atomic>(create<type::U32>());
auto* a = create<Atomic>(create<I32>());
auto* b = create<Atomic>(create<I32>());
auto* c = create<Atomic>(create<U32>());
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
}
TEST_F(AtomicTest, Equals) {
auto* a = create<Atomic>(create<type::I32>());
auto* b = create<Atomic>(create<type::I32>());
auto* c = create<Atomic>(create<type::U32>());
auto* a = create<Atomic>(create<I32>());
auto* b = create<Atomic>(create<I32>());
auto* c = create<Atomic>(create<U32>());
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(AtomicTest, FriendlyName) {
auto* a = create<Atomic>(create<type::I32>());
auto* a = create<Atomic>(create<I32>());
EXPECT_EQ(a->FriendlyName(Symbols()), "atomic<i32>");
}

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Bool);
namespace tint::type {
Bool::Bool()
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -28,7 +28,7 @@
namespace tint::type {
/// A boolean type
class Bool final : public Castable<Bool, type::Type> {
class Bool final : public Castable<Bool, Type> {
public:
/// Constructor
Bool();

View File

@ -40,7 +40,7 @@ size_t DepthMultisampledTexture::Hash() const {
return utils::Hash(TypeInfo::Of<DepthMultisampledTexture>().full_hashcode, dim());
}
bool DepthMultisampledTexture::Equals(const type::Type& other) const {
bool DepthMultisampledTexture::Equals(const Type& other) const {
if (auto* o = other.As<DepthMultisampledTexture>()) {
return o->dim() == dim();
}

View File

@ -44,7 +44,7 @@ TEST_F(DepthMultisampledTextureTest, Equals) {
EXPECT_TRUE(a->Equals(*a));
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(DepthMultisampledTextureTest, Dim) {

View File

@ -41,7 +41,7 @@ size_t DepthTexture::Hash() const {
return utils::Hash(TypeInfo::Of<DepthTexture>().full_hashcode, dim());
}
bool DepthTexture::Equals(const type::Type& other) const {
bool DepthTexture::Equals(const Type& other) const {
if (auto* o = other.As<DepthTexture>()) {
return o->dim() == dim();
}

View File

@ -49,7 +49,7 @@ TEST_F(DepthTextureTest, Equals) {
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(DepthTextureTest, IsTexture) {

View File

@ -30,7 +30,7 @@ size_t ExternalTexture::Hash() const {
return static_cast<size_t>(TypeInfo::Of<ExternalTexture>().full_hashcode);
}
bool ExternalTexture::Equals(const type::Type& other) const {
bool ExternalTexture::Equals(const Type& other) const {
return other.Is<ExternalTexture>();
}

View File

@ -41,11 +41,11 @@ TEST_F(ExternalTextureTest, Equals) {
auto* a = create<ExternalTexture>();
auto* b = create<ExternalTexture>();
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(ExternalTextureTest, IsTexture) {
type::F32 f32;
F32 f32;
ExternalTexture s;
Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>());
@ -56,7 +56,7 @@ TEST_F(ExternalTextureTest, IsTexture) {
}
TEST_F(ExternalTextureTest, Dim) {
type::F32 f32;
F32 f32;
ExternalTexture s;
EXPECT_EQ(s.dim(), ast::TextureDimension::k2d);
}

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::F16);
namespace tint::type {
F16::F16()
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -22,7 +22,7 @@
namespace tint::type {
/// A float 16 type
class F16 final : public Castable<F16, type::Type> {
class F16 final : public Castable<F16, Type> {
public:
/// Constructor
F16();

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::F32);
namespace tint::type {
F32::F32()
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -22,7 +22,7 @@
namespace tint::type {
/// A float 32 type
class F32 final : public Castable<F32, type::Type> {
class F32 final : public Castable<F32, Type> {
public:
/// Constructor
F32();

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::I32);
namespace tint::type {
I32::I32()
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -22,7 +22,7 @@
namespace tint::type {
/// A signed int 32 type.
class I32 final : public Castable<I32, type::Type> {
class I32 final : public Castable<I32, Type> {
public:
/// Constructor
I32();

View File

@ -23,7 +23,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Matrix);
namespace tint::type {
Matrix::Matrix(const Vector* column_type, uint32_t columns)
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -27,7 +27,7 @@ class Vector;
namespace tint::type {
/// A matrix type
class Matrix final : public Castable<Matrix, type::Type> {
class Matrix final : public Castable<Matrix, Type> {
public:
/// Constructor
/// @param column_type the type of a column of the matrix
@ -45,7 +45,7 @@ class Matrix final : public Castable<Matrix, type::Type> {
bool Equals(const Type& other) const override;
/// @returns the type of the matrix
const type::Type* type() const { return subtype_; }
const Type* type() const { return subtype_; }
/// @returns the number of rows in the matrix
uint32_t rows() const { return rows_; }
/// @returns the number of columns in the matrix
@ -70,7 +70,7 @@ class Matrix final : public Castable<Matrix, type::Type> {
uint32_t ColumnStride() const;
private:
const type::Type* const subtype_;
const Type* const subtype_;
const Vector* const column_type_;
const uint32_t rows_;
const uint32_t columns_;

View File

@ -21,13 +21,13 @@ namespace {
using MatrixTest = TestHelper;
TEST_F(MatrixTest, Creation) {
auto* a = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
auto* b = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
auto* c = create<Matrix>(create<Vector>(create<type::F32>(), 3u), 4u);
auto* d = create<Matrix>(create<Vector>(create<type::I32>(), 2u), 4u);
auto* e = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 2u);
auto* a = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
auto* b = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
auto* c = create<Matrix>(create<Vector>(create<F32>(), 3u), 4u);
auto* d = create<Matrix>(create<Vector>(create<I32>(), 2u), 4u);
auto* e = create<Matrix>(create<Vector>(create<I32>(), 3u), 2u);
EXPECT_EQ(a->type(), create<type::I32>());
EXPECT_EQ(a->type(), create<I32>());
EXPECT_EQ(a->rows(), 3u);
EXPECT_EQ(a->columns(), 4u);
@ -38,11 +38,11 @@ TEST_F(MatrixTest, Creation) {
}
TEST_F(MatrixTest, Hash) {
auto* a = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
auto* b = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
auto* c = create<Matrix>(create<Vector>(create<type::F32>(), 3u), 4u);
auto* d = create<Matrix>(create<Vector>(create<type::I32>(), 2u), 4u);
auto* e = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 2u);
auto* a = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
auto* b = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
auto* c = create<Matrix>(create<Vector>(create<F32>(), 3u), 4u);
auto* d = create<Matrix>(create<Vector>(create<I32>(), 2u), 4u);
auto* e = create<Matrix>(create<Vector>(create<I32>(), 3u), 2u);
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
@ -51,21 +51,21 @@ TEST_F(MatrixTest, Hash) {
}
TEST_F(MatrixTest, Equals) {
auto* a = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
auto* b = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 4u);
auto* c = create<Matrix>(create<Vector>(create<type::F32>(), 3u), 4u);
auto* d = create<Matrix>(create<Vector>(create<type::I32>(), 2u), 4u);
auto* e = create<Matrix>(create<Vector>(create<type::I32>(), 3u), 2u);
auto* a = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
auto* b = create<Matrix>(create<Vector>(create<I32>(), 3u), 4u);
auto* c = create<Matrix>(create<Vector>(create<F32>(), 3u), 4u);
auto* d = create<Matrix>(create<Vector>(create<I32>(), 2u), 4u);
auto* e = create<Matrix>(create<Vector>(create<I32>(), 3u), 2u);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(*e));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(MatrixTest, FriendlyName) {
type::I32 i32;
I32 i32;
Vector c{&i32, 3};
Matrix m{&c, 2};
EXPECT_EQ(m.FriendlyName(Symbols()), "mat2x3<i32>");

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::MultisampledTexture);
namespace tint::type {
MultisampledTexture::MultisampledTexture(ast::TextureDimension dim, const type::Type* type)
MultisampledTexture::MultisampledTexture(ast::TextureDimension dim, const Type* type)
: Base(dim), type_(type) {
TINT_ASSERT(Type, type_);
}
@ -34,7 +34,7 @@ size_t MultisampledTexture::Hash() const {
return utils::Hash(TypeInfo::Of<MultisampledTexture>().full_hashcode, dim(), type_);
}
bool MultisampledTexture::Equals(const type::Type& other) const {
bool MultisampledTexture::Equals(const Type& other) const {
if (auto* o = other.As<MultisampledTexture>()) {
return o->dim() == dim() && o->type_ == type_;
}

View File

@ -27,7 +27,7 @@ class MultisampledTexture final : public Castable<MultisampledTexture, Texture>
/// Constructor
/// @param dim the dimensionality of the texture
/// @param type the data type of the multisampled texture
MultisampledTexture(ast::TextureDimension dim, const type::Type* type);
MultisampledTexture(ast::TextureDimension dim, const Type* type);
/// Move constructor
MultisampledTexture(MultisampledTexture&&);
~MultisampledTexture() override;
@ -40,7 +40,7 @@ class MultisampledTexture final : public Castable<MultisampledTexture, Texture>
bool Equals(const Type& other) const override;
/// @returns the subtype of the sampled texture
const type::Type* type() const { return type_; }
const Type* type() const { return type_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
@ -48,7 +48,7 @@ class MultisampledTexture final : public Castable<MultisampledTexture, Texture>
std::string FriendlyName(const SymbolTable& symbols) const override;
private:
const type::Type* const type_;
const Type* const type_;
};
} // namespace tint::type

View File

@ -26,38 +26,38 @@ namespace {
using MultisampledTextureTest = TestHelper;
TEST_F(MultisampledTextureTest, Creation) {
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<type::F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::I32>());
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>());
EXPECT_EQ(a, b);
EXPECT_NE(a, c);
EXPECT_NE(a, d);
}
TEST_F(MultisampledTextureTest, Hash) {
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<type::F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::I32>());
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>());
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
EXPECT_NE(a->Hash(), d->Hash());
}
TEST_F(MultisampledTextureTest, Equals) {
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<type::F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<type::I32>());
auto* a = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* b = create<MultisampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* c = create<MultisampledTexture>(ast::TextureDimension::k3d, create<F32>());
auto* d = create<MultisampledTexture>(ast::TextureDimension::k2d, create<I32>());
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(MultisampledTextureTest, IsTexture) {
type::F32 f32;
F32 f32;
MultisampledTexture s(ast::TextureDimension::kCube, &f32);
Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>());
@ -68,19 +68,19 @@ TEST_F(MultisampledTextureTest, IsTexture) {
}
TEST_F(MultisampledTextureTest, Dim) {
type::F32 f32;
F32 f32;
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
}
TEST_F(MultisampledTextureTest, Type) {
type::F32 f32;
F32 f32;
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32);
}
TEST_F(MultisampledTextureTest, FriendlyName) {
type::F32 f32;
F32 f32;
MultisampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d<f32>");
}

View File

@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Pointer);
namespace tint::type {
Pointer::Pointer(const type::Type* subtype, ast::AddressSpace address_space, ast::Access access)
: Base(type::TypeFlags{}), subtype_(subtype), address_space_(address_space), access_(access) {
Pointer::Pointer(const Type* subtype, ast::AddressSpace address_space, ast::Access access)
: Base(TypeFlags{}), subtype_(subtype), address_space_(address_space), access_(access) {
TINT_ASSERT(Type, !subtype->Is<Reference>());
TINT_ASSERT(Type, access != ast::Access::kUndefined);
}
@ -32,7 +32,7 @@ size_t Pointer::Hash() const {
return utils::Hash(TypeInfo::Of<Pointer>().full_hashcode, address_space_, subtype_, access_);
}
bool Pointer::Equals(const type::Type& other) const {
bool Pointer::Equals(const Type& other) const {
if (auto* o = other.As<Pointer>()) {
return o->address_space_ == address_space_ && o->subtype_ == subtype_ &&
o->access_ == access_;

View File

@ -24,13 +24,13 @@
namespace tint::type {
/// A pointer type.
class Pointer final : public Castable<Pointer, type::Type> {
class Pointer final : public Castable<Pointer, Type> {
public:
/// Constructor
/// @param subtype the pointee type
/// @param address_space the address space of the pointer
/// @param access the resolved access control of the reference
Pointer(const type::Type* subtype, ast::AddressSpace address_space, ast::Access access);
Pointer(const Type* subtype, ast::AddressSpace address_space, ast::Access access);
/// Move constructor
Pointer(Pointer&&);
@ -44,7 +44,7 @@ class Pointer final : public Castable<Pointer, type::Type> {
bool Equals(const Type& other) const override;
/// @returns the pointee type
const type::Type* StoreType() const { return subtype_; }
const Type* StoreType() const { return subtype_; }
/// @returns the address space of the pointer
ast::AddressSpace AddressSpace() const { return address_space_; }

View File

@ -21,17 +21,13 @@ namespace {
using PointerTest = TestHelper;
TEST_F(PointerTest, Creation) {
auto* a =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c =
create<Pointer>(create<type::F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
auto* a = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<type::I32>());
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage);
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
@ -42,15 +38,11 @@ TEST_F(PointerTest, Creation) {
}
TEST_F(PointerTest, Hash) {
auto* a =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c =
create<Pointer>(create<type::F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
auto* a = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
@ -59,31 +51,26 @@ TEST_F(PointerTest, Hash) {
}
TEST_F(PointerTest, Equals) {
auto* a =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c =
create<Pointer>(create<type::F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
auto* a = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c = create<Pointer>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d = create<Pointer>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Pointer>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(*e));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(PointerTest, FriendlyName) {
auto* r = create<Pointer>(create<type::I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
auto* r = create<Pointer>(create<I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<i32, read>");
}
TEST_F(PointerTest, FriendlyNameWithAddressSpace) {
auto* r =
create<Pointer>(create<type::I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
auto* r = create<Pointer>(create<I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ptr<workgroup, i32, read>");
}

View File

@ -21,8 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Reference);
namespace tint::type {
Reference::Reference(const type::Type* subtype, ast::AddressSpace address_space, ast::Access access)
: Base(type::TypeFlags{}), subtype_(subtype), address_space_(address_space), access_(access) {
Reference::Reference(const Type* subtype, ast::AddressSpace address_space, ast::Access access)
: Base(TypeFlags{}), subtype_(subtype), address_space_(address_space), access_(access) {
TINT_ASSERT(Type, !subtype->Is<Reference>());
TINT_ASSERT(Type, access != ast::Access::kUndefined);
}
@ -31,7 +31,7 @@ size_t Reference::Hash() const {
return utils::Hash(TypeInfo::Of<Reference>().full_hashcode, address_space_, subtype_, access_);
}
bool Reference::Equals(const type::Type& other) const {
bool Reference::Equals(const Type& other) const {
if (auto* o = other.As<Reference>()) {
return o->address_space_ == address_space_ && o->subtype_ == subtype_ &&
o->access_ == access_;

View File

@ -24,13 +24,13 @@
namespace tint::type {
/// A reference type.
class Reference final : public Castable<Reference, type::Type> {
class Reference final : public Castable<Reference, Type> {
public:
/// Constructor
/// @param subtype the pointee type
/// @param address_space the address space of the reference
/// @param access the resolved access control of the reference
Reference(const type::Type* subtype, ast::AddressSpace address_space, ast::Access access);
Reference(const Type* subtype, ast::AddressSpace address_space, ast::Access access);
/// Move constructor
Reference(Reference&&);
@ -44,7 +44,7 @@ class Reference final : public Castable<Reference, type::Type> {
bool Equals(const Type& other) const override;
/// @returns the pointee type
const type::Type* StoreType() const { return subtype_; }
const Type* StoreType() const { return subtype_; }
/// @returns the address space of the reference
ast::AddressSpace AddressSpace() const { return address_space_; }

View File

@ -21,18 +21,17 @@ namespace {
using ReferenceTest = TestHelper;
TEST_F(ReferenceTest, Creation) {
auto* a = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* b = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* c = create<Reference>(create<type::F32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* d = create<Reference>(create<type::I32>(), ast::AddressSpace::kPrivate,
ast::Access::kReadWrite);
auto* e =
create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
auto* a =
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b =
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c =
create<Reference>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d =
create<Reference>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
EXPECT_TRUE(a->StoreType()->Is<type::I32>());
EXPECT_TRUE(a->StoreType()->Is<I32>());
EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage);
EXPECT_EQ(a->Access(), ast::Access::kReadWrite);
@ -43,16 +42,15 @@ TEST_F(ReferenceTest, Creation) {
}
TEST_F(ReferenceTest, Hash) {
auto* a = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* b = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* c = create<Reference>(create<type::F32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* d = create<Reference>(create<type::I32>(), ast::AddressSpace::kPrivate,
ast::Access::kReadWrite);
auto* e =
create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
auto* a =
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b =
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c =
create<Reference>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d =
create<Reference>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
@ -61,32 +59,30 @@ TEST_F(ReferenceTest, Hash) {
}
TEST_F(ReferenceTest, Equals) {
auto* a = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* b = create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* c = create<Reference>(create<type::F32>(), ast::AddressSpace::kStorage,
ast::Access::kReadWrite);
auto* d = create<Reference>(create<type::I32>(), ast::AddressSpace::kPrivate,
ast::Access::kReadWrite);
auto* e =
create<Reference>(create<type::I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
auto* a =
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* b =
create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* c =
create<Reference>(create<F32>(), ast::AddressSpace::kStorage, ast::Access::kReadWrite);
auto* d =
create<Reference>(create<I32>(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
auto* e = create<Reference>(create<I32>(), ast::AddressSpace::kStorage, ast::Access::kRead);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(*e));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(ReferenceTest, FriendlyName) {
auto* r = create<Reference>(create<type::I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
auto* r = create<Reference>(create<I32>(), ast::AddressSpace::kNone, ast::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<i32, read>");
}
TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) {
auto* r =
create<Reference>(create<type::I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
auto* r = create<Reference>(create<I32>(), ast::AddressSpace::kWorkgroup, ast::Access::kRead);
EXPECT_EQ(r->FriendlyName(Symbols()), "ref<workgroup, i32, read>");
}

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::SampledTexture);
namespace tint::type {
SampledTexture::SampledTexture(ast::TextureDimension dim, const type::Type* type)
SampledTexture::SampledTexture(ast::TextureDimension dim, const Type* type)
: Base(dim), type_(type) {
TINT_ASSERT(Type, type_);
}
@ -34,7 +34,7 @@ size_t SampledTexture::Hash() const {
return utils::Hash(TypeInfo::Of<SampledTexture>().full_hashcode, dim(), type_);
}
bool SampledTexture::Equals(const type::Type& other) const {
bool SampledTexture::Equals(const Type& other) const {
if (auto* o = other.As<SampledTexture>()) {
return o->dim() == dim() && o->type_ == type_;
}

View File

@ -27,7 +27,7 @@ class SampledTexture final : public Castable<SampledTexture, Texture> {
/// Constructor
/// @param dim the dimensionality of the texture
/// @param type the data type of the sampled texture
SampledTexture(ast::TextureDimension dim, const type::Type* type);
SampledTexture(ast::TextureDimension dim, const Type* type);
/// Move constructor
SampledTexture(SampledTexture&&);
~SampledTexture() override;
@ -40,7 +40,7 @@ class SampledTexture final : public Castable<SampledTexture, Texture> {
bool Equals(const Type& other) const override;
/// @returns the subtype of the sampled texture
type::Type* type() const { return const_cast<type::Type*>(type_); }
Type* type() const { return const_cast<Type*>(type_); }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be
@ -48,7 +48,7 @@ class SampledTexture final : public Castable<SampledTexture, Texture> {
std::string FriendlyName(const SymbolTable& symbols) const override;
private:
const type::Type* const type_;
const Type* const type_;
};
} // namespace tint::type

View File

@ -25,12 +25,12 @@ namespace {
using SampledTextureTest = TestHelper;
TEST_F(SampledTextureTest, Creation) {
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<type::I32>());
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>());
EXPECT_TRUE(a->type()->Is<type::F32>());
EXPECT_TRUE(a->type()->Is<F32>());
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
EXPECT_EQ(a, b);
@ -39,10 +39,10 @@ TEST_F(SampledTextureTest, Creation) {
}
TEST_F(SampledTextureTest, Hash) {
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<type::I32>());
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>());
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
@ -50,19 +50,19 @@ TEST_F(SampledTextureTest, Hash) {
}
TEST_F(SampledTextureTest, Equals) {
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<type::F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<type::F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<type::I32>());
auto* a = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
auto* b = create<SampledTexture>(ast::TextureDimension::kCube, create<F32>());
auto* c = create<SampledTexture>(ast::TextureDimension::k2d, create<F32>());
auto* d = create<SampledTexture>(ast::TextureDimension::kCube, create<I32>());
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(SampledTextureTest, IsTexture) {
type::F32 f32;
F32 f32;
SampledTexture s(ast::TextureDimension::kCube, &f32);
Texture* ty = &s;
EXPECT_FALSE(ty->Is<DepthTexture>());
@ -72,19 +72,19 @@ TEST_F(SampledTextureTest, IsTexture) {
}
TEST_F(SampledTextureTest, Dim) {
type::F32 f32;
F32 f32;
SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.dim(), ast::TextureDimension::k3d);
}
TEST_F(SampledTextureTest, Type) {
type::F32 f32;
F32 f32;
SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.type(), &f32);
}
TEST_F(SampledTextureTest, FriendlyName) {
type::F32 f32;
F32 f32;
SampledTexture s(ast::TextureDimension::k3d, &f32);
EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d<f32>");
}

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Sampler);
namespace tint::type {
Sampler::Sampler(ast::SamplerKind kind) : Base(type::TypeFlags{}), kind_(kind) {}
Sampler::Sampler(ast::SamplerKind kind) : Base(TypeFlags{}), kind_(kind) {}
Sampler::Sampler(Sampler&&) = default;
@ -31,7 +31,7 @@ size_t Sampler::Hash() const {
return utils::Hash(TypeInfo::Of<Sampler>().full_hashcode, kind_);
}
bool Sampler::Equals(const type::Type& other) const {
bool Sampler::Equals(const Type& other) const {
if (auto* o = other.As<Sampler>()) {
return o->kind_ == kind_;
}

View File

@ -23,7 +23,7 @@
namespace tint::type {
/// A sampler type.
class Sampler final : public Castable<Sampler, type::Type> {
class Sampler final : public Castable<Sampler, Type> {
public:
/// Constructor
/// @param kind the kind of sampler

View File

@ -52,7 +52,7 @@ TEST_F(SamplerTest, Equals) {
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(SamplerTest, FriendlyNameSampler) {

View File

@ -24,7 +24,7 @@ namespace tint::type {
StorageTexture::StorageTexture(ast::TextureDimension dim,
ast::TexelFormat format,
ast::Access access,
type::Type* subtype)
Type* subtype)
: Base(dim), texel_format_(format), access_(access), subtype_(subtype) {}
StorageTexture::StorageTexture(StorageTexture&&) = default;
@ -35,7 +35,7 @@ size_t StorageTexture::Hash() const {
return utils::Hash(TypeInfo::Of<StorageTexture>().full_hashcode, dim(), texel_format_, access_);
}
bool StorageTexture::Equals(const type::Type& other) const {
bool StorageTexture::Equals(const Type& other) const {
if (auto* o = other.As<StorageTexture>()) {
return o->dim() == dim() && o->texel_format_ == texel_format_ && o->access_ == access_;
}
@ -48,14 +48,14 @@ std::string StorageTexture::FriendlyName(const SymbolTable&) const {
return out.str();
}
type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManager& type_mgr) {
Type* StorageTexture::SubtypeFor(ast::TexelFormat format, TypeManager& type_mgr) {
switch (format) {
case ast::TexelFormat::kR32Uint:
case ast::TexelFormat::kRgba8Uint:
case ast::TexelFormat::kRg32Uint:
case ast::TexelFormat::kRgba16Uint:
case ast::TexelFormat::kRgba32Uint: {
return type_mgr.Get<type::U32>();
return type_mgr.Get<U32>();
}
case ast::TexelFormat::kR32Sint:
@ -63,7 +63,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage
case ast::TexelFormat::kRg32Sint:
case ast::TexelFormat::kRgba16Sint:
case ast::TexelFormat::kRgba32Sint: {
return type_mgr.Get<type::I32>();
return type_mgr.Get<I32>();
}
case ast::TexelFormat::kRgba8Unorm:
@ -72,7 +72,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage
case ast::TexelFormat::kRg32Float:
case ast::TexelFormat::kRgba16Float:
case ast::TexelFormat::kRgba32Float: {
return type_mgr.Get<type::F32>();
return type_mgr.Get<F32>();
}
case ast::TexelFormat::kUndefined:

View File

@ -39,7 +39,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
StorageTexture(ast::TextureDimension dim,
ast::TexelFormat format,
ast::Access access,
type::Type* subtype);
Type* subtype);
/// Move constructor
StorageTexture(StorageTexture&&);
@ -53,7 +53,7 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
bool Equals(const Type& other) const override;
/// @returns the storage subtype
type::Type* type() const { return subtype_; }
Type* type() const { return subtype_; }
/// @returns the texel format
ast::TexelFormat texel_format() const { return texel_format_; }
@ -67,14 +67,14 @@ class StorageTexture final : public Castable<StorageTexture, Texture> {
std::string FriendlyName(const SymbolTable& symbols) const override;
/// @param format the storage texture image format
/// @param type_mgr the type::TypeManager used to build the returned type
/// @param type_mgr the TypeManager used to build the returned type
/// @returns the storage texture subtype for the given TexelFormat
static type::Type* SubtypeFor(ast::TexelFormat format, type::TypeManager& type_mgr);
static Type* SubtypeFor(ast::TexelFormat format, TypeManager& type_mgr);
private:
ast::TexelFormat const texel_format_;
ast::Access const access_;
type::Type* const subtype_;
Type* const subtype_;
};
} // namespace tint::type

View File

@ -41,7 +41,7 @@ TEST_F(StorageTextureTest, Creation) {
auto* e =
Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead);
EXPECT_TRUE(a->type()->Is<type::F32>());
EXPECT_TRUE(a->type()->Is<F32>());
EXPECT_EQ(a->dim(), ast::TextureDimension::kCube);
EXPECT_EQ(a, b);
@ -84,7 +84,7 @@ TEST_F(StorageTextureTest, Equals) {
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(*e));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(StorageTextureTest, Dim) {
@ -106,43 +106,41 @@ TEST_F(StorageTextureTest, FriendlyName) {
}
TEST_F(StorageTextureTest, F32) {
type::Type* s = Create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
ast::Access::kReadWrite);
Type* s = Create(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Float,
ast::Access::kReadWrite);
auto program = Build();
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<type::F32>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<F32>());
}
TEST_F(StorageTextureTest, U32) {
auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types());
type::Type* s =
create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint,
ast::Access::kReadWrite, subtype);
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRg32Uint, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRg32Uint,
ast::Access::kReadWrite, subtype);
auto program = Build();
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<type::U32>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<U32>());
}
TEST_F(StorageTextureTest, I32) {
auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types());
type::Type* s =
create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint,
ast::Access::kReadWrite, subtype);
auto* subtype = StorageTexture::SubtypeFor(ast::TexelFormat::kRgba32Sint, Types());
Type* s = create<StorageTexture>(ast::TextureDimension::k2dArray, ast::TexelFormat::kRgba32Sint,
ast::Access::kReadWrite, subtype);
auto program = Build();
ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str();
ASSERT_TRUE(s->Is<Texture>());
ASSERT_TRUE(s->Is<StorageTexture>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<type::I32>());
EXPECT_TRUE(s->As<StorageTexture>()->type()->Is<I32>());
}
} // namespace

View File

@ -28,21 +28,21 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::StructMemberBase);
namespace tint::type {
namespace {
type::TypeFlags FlagsFrom(utils::VectorRef<const StructMemberBase*> members) {
type::TypeFlags flags{
type::TypeFlag::kConstructable,
type::TypeFlag::kCreationFixedFootprint,
type::TypeFlag::kFixedFootprint,
TypeFlags FlagsFrom(utils::VectorRef<const StructMemberBase*> members) {
TypeFlags flags{
TypeFlag::kConstructable,
TypeFlag::kCreationFixedFootprint,
TypeFlag::kFixedFootprint,
};
for (auto* member : members) {
if (!member->Type()->IsConstructible()) {
flags.Remove(type::TypeFlag::kConstructable);
flags.Remove(TypeFlag::kConstructable);
}
if (!member->Type()->HasFixedFootprint()) {
flags.Remove(type::TypeFlag::kFixedFootprint);
flags.Remove(TypeFlag::kFixedFootprint);
}
if (!member->Type()->HasCreationFixedFootprint()) {
flags.Remove(type::TypeFlag::kCreationFixedFootprint);
flags.Remove(TypeFlag::kCreationFixedFootprint);
}
}
return flags;
@ -70,7 +70,7 @@ size_t StructBase::Hash() const {
return utils::Hash(TypeInfo::Of<StructBase>().full_hashcode, name_);
}
bool StructBase::Equals(const type::Type& other) const {
bool StructBase::Equals(const Type& other) const {
if (auto* o = other.As<StructBase>()) {
return o->name_ == name_;
}
@ -101,9 +101,7 @@ std::string StructBase::FriendlyName(const SymbolTable& symbols) const {
std::string StructBase::Layout(const tint::SymbolTable& symbols) const {
std::stringstream ss;
auto member_name_of = [&](const type::StructMemberBase* sm) {
return symbols.NameFor(sm->Name());
};
auto member_name_of = [&](const StructMemberBase* sm) { return symbols.NameFor(sm->Name()); };
if (Members().IsEmpty()) {
return {};

View File

@ -45,7 +45,7 @@ enum class PipelineStageUsage {
};
/// StructBase holds the Type information for structures.
class StructBase : public Castable<StructBase, type::Type> {
class StructBase : public Castable<StructBase, Type> {
public:
/// Constructor
/// @param source the source of the structure
@ -167,7 +167,7 @@ class StructBase : public Castable<StructBase, type::Type> {
};
/// StructMemberBase holds the type information for structure members.
class StructMemberBase : public Castable<StructMemberBase, type::Node> {
class StructMemberBase : public Castable<StructMemberBase, Node> {
public:
/// Constructor
/// @param source the source of the struct member
@ -198,10 +198,10 @@ class StructMemberBase : public Castable<StructMemberBase, type::Node> {
/// Sets the owning structure to `s`
/// @param s the new structure owner
void SetStruct(const type::StructBase* s) { struct_ = s; }
void SetStruct(const StructBase* s) { struct_ = s; }
/// @returns the structure that owns this member
const type::StructBase* Struct() const { return struct_; }
const StructBase* Struct() const { return struct_; }
/// @returns the type of the member
const type::Type* Type() const { return type_; }
@ -224,7 +224,7 @@ class StructMemberBase : public Castable<StructMemberBase, type::Node> {
private:
const tint::Source source_;
const Symbol name_;
const type::StructBase* struct_;
const StructBase* struct_;
const type::Type* type_;
const uint32_t index_;
const uint32_t offset_;

View File

@ -24,37 +24,37 @@ using TypeStructTest = TestHelper;
TEST_F(TypeStructTest, Creation) {
auto name = Sym("S");
auto* s = create<type::StructBase>(Source{}, name, utils::Empty, 4u /* align */, 8u /* size */,
16u /* size_no_padding */);
auto* s = create<StructBase>(Source{}, name, utils::Empty, 4u /* align */, 8u /* size */,
16u /* size_no_padding */);
EXPECT_EQ(s->Align(), 4u);
EXPECT_EQ(s->Size(), 8u);
EXPECT_EQ(s->SizeNoPadding(), 16u);
}
TEST_F(TypeStructTest, Hash) {
auto* a = create<type::StructBase>(Source{}, Sym("a"), utils::Empty, 4u /* align */,
4u /* size */, 4u /* size_no_padding */);
auto* b = create<type::StructBase>(Source{}, Sym("b"), utils::Empty, 4u /* align */,
4u /* size */, 4u /* size_no_padding */);
auto* a = create<StructBase>(Source{}, Sym("a"), utils::Empty, 4u /* align */, 4u /* size */,
4u /* size_no_padding */);
auto* b = create<StructBase>(Source{}, Sym("b"), utils::Empty, 4u /* align */, 4u /* size */,
4u /* size_no_padding */);
EXPECT_NE(a->Hash(), b->Hash());
}
TEST_F(TypeStructTest, Equals) {
auto* a = create<type::StructBase>(Source{}, Sym("a"), utils::Empty, 4u /* align */,
4u /* size */, 4u /* size_no_padding */);
auto* b = create<type::StructBase>(Source{}, Sym("b"), utils::Empty, 4u /* align */,
4u /* size */, 4u /* size_no_padding */);
auto* a = create<StructBase>(Source{}, Sym("a"), utils::Empty, 4u /* align */, 4u /* size */,
4u /* size_no_padding */);
auto* b = create<StructBase>(Source{}, Sym("b"), utils::Empty, 4u /* align */, 4u /* size */,
4u /* size_no_padding */);
EXPECT_TRUE(a->Equals(*a));
EXPECT_FALSE(a->Equals(*b));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(TypeStructTest, FriendlyName) {
auto name = Sym("my_struct");
auto* s = create<type::StructBase>(Source{}, name, utils::Empty, 4u /* align */, 4u /* size */,
4u /* size_no_padding */);
auto* s = create<StructBase>(Source{}, name, utils::Empty, 4u /* align */, 4u /* size */,
4u /* size_no_padding */);
EXPECT_EQ(s->FriendlyName(Symbols()), "my_struct");
}

View File

@ -18,7 +18,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Texture);
namespace tint::type {
Texture::Texture(ast::TextureDimension dim) : Base(type::TypeFlags{}), dim_(dim) {}
Texture::Texture(ast::TextureDimension dim) : Base(TypeFlags{}), dim_(dim) {}
Texture::Texture(Texture&&) = default;

View File

@ -21,7 +21,7 @@
namespace tint::type {
/// A texture type.
class Texture : public Castable<Texture, type::Type> {
class Texture : public Castable<Texture, Type> {
public:
/// Constructor
/// @param dim the dimensionality of the texture

View File

@ -24,7 +24,7 @@ using TextureTypeDimTest = TestParamHelper<ast::TextureDimension>;
TEST_P(TextureTypeDimTest, DimMustMatch) {
// Check that the dim() query returns the right dimensionality.
type::F32 f32;
F32 f32;
// TextureType is an abstract class, so use concrete class
// SampledTexture in its stead.
SampledTexture st(GetParam(), &f32);

View File

@ -46,7 +46,7 @@ Type::~Type() = default;
const Type* Type::UnwrapPtr() const {
auto* type = this;
while (auto* ptr = type->As<type::Pointer>()) {
while (auto* ptr = type->As<Pointer>()) {
type = ptr->StoreType();
}
return type;
@ -54,7 +54,7 @@ const Type* Type::UnwrapPtr() const {
const Type* Type::UnwrapRef() const {
auto* type = this;
if (auto* ref = type->As<type::Reference>()) {
if (auto* ref = type->As<Reference>()) {
type = ref->StoreType();
}
return type;
@ -69,29 +69,28 @@ uint32_t Type::Align() const {
}
bool Type::is_scalar() const {
return IsAnyOf<type::F16, type::F32, type::U32, type::I32, type::AbstractNumeric, type::Bool>();
return IsAnyOf<F16, F32, U32, I32, AbstractNumeric, Bool>();
}
bool Type::is_numeric_scalar() const {
return IsAnyOf<type::F16, type::F32, type::U32, type::I32, type::AbstractNumeric>();
return IsAnyOf<F16, F32, U32, I32, AbstractNumeric>();
}
bool Type::is_float_scalar() const {
return IsAnyOf<type::F16, type::F32, type::AbstractNumeric>();
return IsAnyOf<F16, F32, AbstractNumeric>();
}
bool Type::is_float_matrix() const {
return Is([](const type::Matrix* m) { return m->type()->is_float_scalar(); });
return Is([](const Matrix* m) { return m->type()->is_float_scalar(); });
}
bool Type::is_square_float_matrix() const {
return Is([](const type::Matrix* m) {
return m->type()->is_float_scalar() && m->rows() == m->columns();
});
return Is(
[](const Matrix* m) { return m->type()->is_float_scalar() && m->rows() == m->columns(); });
}
bool Type::is_float_vector() const {
return Is([](const type::Vector* v) { return v->type()->is_float_scalar(); });
return Is([](const Vector* v) { return v->type()->is_float_scalar(); });
}
bool Type::is_float_scalar_or_vector() const {
@ -103,32 +102,31 @@ bool Type::is_float_scalar_or_vector_or_matrix() const {
}
bool Type::is_integer_scalar() const {
return IsAnyOf<type::U32, type::I32>();
return IsAnyOf<U32, I32>();
}
bool Type::is_signed_integer_scalar() const {
return IsAnyOf<type::I32, type::AbstractInt>();
return IsAnyOf<I32, AbstractInt>();
}
bool Type::is_unsigned_integer_scalar() const {
return Is<type::U32>();
return Is<U32>();
}
bool Type::is_signed_integer_vector() const {
return Is(
[](const type::Vector* v) { return v->type()->IsAnyOf<type::I32, type::AbstractInt>(); });
return Is([](const Vector* v) { return v->type()->IsAnyOf<I32, AbstractInt>(); });
}
bool Type::is_unsigned_integer_vector() const {
return Is([](const type::Vector* v) { return v->type()->Is<type::U32>(); });
return Is([](const Vector* v) { return v->type()->Is<U32>(); });
}
bool Type::is_unsigned_integer_scalar_or_vector() const {
return Is<type::U32>() || is_unsigned_integer_vector();
return Is<U32>() || is_unsigned_integer_vector();
}
bool Type::is_signed_integer_scalar_or_vector() const {
return IsAnyOf<type::I32, type::AbstractInt>() || is_signed_integer_vector();
return IsAnyOf<I32, AbstractInt>() || is_signed_integer_vector();
}
bool Type::is_integer_scalar_or_vector() const {
@ -136,35 +134,35 @@ bool Type::is_integer_scalar_or_vector() const {
}
bool Type::is_abstract_integer_vector() const {
return Is([](const type::Vector* v) { return v->type()->Is<type::AbstractInt>(); });
return Is([](const Vector* v) { return v->type()->Is<AbstractInt>(); });
}
bool Type::is_abstract_float_vector() const {
return Is([](const type::Vector* v) { return v->type()->Is<type::AbstractFloat>(); });
return Is([](const Vector* v) { return v->type()->Is<AbstractFloat>(); });
}
bool Type::is_abstract_integer_scalar_or_vector() const {
return Is<type::AbstractInt>() || is_abstract_integer_vector();
return Is<AbstractInt>() || is_abstract_integer_vector();
}
bool Type::is_abstract_float_scalar_or_vector() const {
return Is<type::AbstractFloat>() || is_abstract_float_vector();
return Is<AbstractFloat>() || is_abstract_float_vector();
}
bool Type::is_bool_vector() const {
return Is([](const type::Vector* v) { return v->type()->Is<type::Bool>(); });
return Is([](const Vector* v) { return v->type()->Is<Bool>(); });
}
bool Type::is_bool_scalar_or_vector() const {
return Is<type::Bool>() || is_bool_vector();
return Is<Bool>() || is_bool_vector();
}
bool Type::is_numeric_vector() const {
return Is([](const type::Vector* v) { return v->type()->is_numeric_scalar(); });
return Is([](const Vector* v) { return v->type()->is_numeric_scalar(); });
}
bool Type::is_scalar_vector() const {
return Is([](const type::Vector* v) { return v->type()->is_scalar(); });
return Is([](const Vector* v) { return v->type()->is_scalar(); });
}
bool Type::is_numeric_scalar_or_vector() const {
@ -172,17 +170,17 @@ bool Type::is_numeric_scalar_or_vector() const {
}
bool Type::is_handle() const {
return IsAnyOf<type::Sampler, type::Texture>();
return IsAnyOf<Sampler, Texture>();
}
bool Type::HoldsAbstract() const {
return Switch(
this, //
[&](const type::AbstractNumeric*) { return true; },
[&](const type::Vector* v) { return v->type()->HoldsAbstract(); },
[&](const type::Matrix* m) { return m->type()->HoldsAbstract(); },
[&](const type::Array* a) { return a->ElemType()->HoldsAbstract(); },
[&](const type::StructBase* s) {
[&](const AbstractNumeric*) { return true; },
[&](const Vector* v) { return v->type()->HoldsAbstract(); },
[&](const Matrix* m) { return m->type()->HoldsAbstract(); },
[&](const Array* a) { return a->ElemType()->HoldsAbstract(); },
[&](const StructBase* s) {
for (auto* m : s->Members()) {
if (m->Type()->HoldsAbstract()) {
return true;
@ -198,33 +196,33 @@ uint32_t Type::ConversionRank(const Type* from, const Type* to) {
}
return Switch(
from,
[&](const type::AbstractFloat*) {
[&](const AbstractFloat*) {
return Switch(
to, //
[&](const type::F32*) { return 1; }, //
[&](const type::F16*) { return 2; }, //
to, //
[&](const F32*) { return 1; }, //
[&](const F16*) { return 2; }, //
[&](Default) { return kNoConversion; });
},
[&](const type::AbstractInt*) {
[&](const AbstractInt*) {
return Switch(
to, //
[&](const type::I32*) { return 3; }, //
[&](const type::U32*) { return 4; }, //
[&](const type::AbstractFloat*) { return 5; }, //
[&](const type::F32*) { return 6; }, //
[&](const type::F16*) { return 7; }, //
to, //
[&](const I32*) { return 3; }, //
[&](const U32*) { return 4; }, //
[&](const AbstractFloat*) { return 5; }, //
[&](const F32*) { return 6; }, //
[&](const F16*) { return 7; }, //
[&](Default) { return kNoConversion; });
},
[&](const type::Vector* from_vec) {
if (auto* to_vec = to->As<type::Vector>()) {
[&](const Vector* from_vec) {
if (auto* to_vec = to->As<Vector>()) {
if (from_vec->Width() == to_vec->Width()) {
return ConversionRank(from_vec->type(), to_vec->type());
}
}
return kNoConversion;
},
[&](const type::Matrix* from_mat) {
if (auto* to_mat = to->As<type::Matrix>()) {
[&](const Matrix* from_mat) {
if (auto* to_mat = to->As<Matrix>()) {
if (from_mat->columns() == to_mat->columns() &&
from_mat->rows() == to_mat->rows()) {
return ConversionRank(from_mat->type(), to_mat->type());
@ -232,15 +230,15 @@ uint32_t Type::ConversionRank(const Type* from, const Type* to) {
}
return kNoConversion;
},
[&](const type::Array* from_arr) {
if (auto* to_arr = to->As<type::Array>()) {
[&](const Array* from_arr) {
if (auto* to_arr = to->As<Array>()) {
if (from_arr->Count() == to_arr->Count()) {
return ConversionRank(from_arr->ElemType(), to_arr->ElemType());
}
}
return kNoConversion;
},
[&](const type::StructBase* from_str) {
[&](const StructBase* from_str) {
auto concrete_tys = from_str->ConcreteTypes();
for (size_t i = 0; i < concrete_tys.Length(); i++) {
if (concrete_tys[i] == to) {
@ -261,21 +259,21 @@ const Type* Type::ElementOf(const Type* ty, uint32_t* count /* = nullptr */) {
}
return Switch(
ty, //
[&](const type::Vector* v) {
[&](const Vector* v) {
if (count) {
*count = v->Width();
}
return v->type();
},
[&](const type::Matrix* m) {
[&](const Matrix* m) {
if (count) {
*count = m->columns();
}
return m->ColumnType();
},
[&](const type::Array* a) {
[&](const Array* a) {
if (count) {
if (auto* const_count = a->Count()->As<type::ConstantArrayCount>()) {
if (auto* const_count = a->Count()->As<ConstantArrayCount>()) {
*count = const_count->value;
}
}
@ -303,7 +301,7 @@ const Type* Type::DeepestElementOf(const Type* ty, uint32_t* count /* = nullptr
return el_ty;
}
const type::Type* Type::Common(utils::VectorRef<const Type*> types) {
const Type* Type::Common(utils::VectorRef<const Type*> types) {
const auto count = types.Length();
if (count == 0) {
return nullptr;
@ -314,10 +312,10 @@ const type::Type* Type::Common(utils::VectorRef<const Type*> types) {
if (ty == common) {
continue; // ty == common
}
if (type::Type::ConversionRank(ty, common) != type::Type::kNoConversion) {
if (Type::ConversionRank(ty, common) != Type::kNoConversion) {
continue; // ty can be converted to common.
}
if (type::Type::ConversionRank(common, ty) != type::Type::kNoConversion) {
if (Type::ConversionRank(common, ty) != Type::kNoConversion) {
common = ty; // common can be converted to ty.
continue;
}

View File

@ -192,7 +192,7 @@ class Type : public Castable<Type, Node> {
/// @returns the lowest-ranking type that all types in `types` can be implicitly converted to,
/// or nullptr if there is no consistent common type across all types in `types`.
/// @see https://www.w3.org/TR/WGSL/#conversion-rank
static const type::Type* Common(utils::VectorRef<const Type*> types);
static const Type* Common(utils::VectorRef<const Type*> types);
protected:
/// Constructor

View File

@ -32,7 +32,7 @@ namespace tint::type {
class TypeManager final {
public:
/// Iterator is the type returned by begin() and end()
using TypeIterator = utils::BlockAllocator<type::Type>::ConstIterator;
using TypeIterator = utils::BlockAllocator<Type>::ConstIterator;
/// Constructor
TypeManager();
@ -69,7 +69,7 @@ class TypeManager final {
/// If an existing instance of `T` has been constructed, then the same
/// pointer is returned.
template <typename TYPE,
typename _ = std::enable_if<traits::IsTypeOrDerived<TYPE, type::Type>>,
typename _ = std::enable_if<traits::IsTypeOrDerived<TYPE, Type>>,
typename... ARGS>
TYPE* Get(ARGS&&... args) {
return types_.Get<TYPE>(std::forward<ARGS>(args)...);
@ -79,7 +79,7 @@ class TypeManager final {
/// @return a pointer to an instance of `T` with the provided arguments, or nullptr if the item
/// was not found.
template <typename TYPE,
typename _ = std::enable_if<traits::IsTypeOrDerived<TYPE, type::Type>>,
typename _ = std::enable_if<traits::IsTypeOrDerived<TYPE, Type>>,
typename... ARGS>
TYPE* Find(ARGS&&... args) const {
return types_.Find<TYPE>(std::forward<ARGS>(args)...);
@ -90,8 +90,8 @@ class TypeManager final {
/// If an existing instance of `T` has been constructed, then the same
/// pointer is returned.
template <typename TYPE,
typename _ = std::enable_if<traits::IsTypeOrDerived<TYPE, type::ArrayCount> ||
traits::IsTypeOrDerived<TYPE, type::StructMemberBase>>,
typename _ = std::enable_if<traits::IsTypeOrDerived<TYPE, ArrayCount> ||
traits::IsTypeOrDerived<TYPE, StructMemberBase>>,
typename... ARGS>
TYPE* GetNode(ARGS&&... args) {
return nodes_.Get<TYPE>(std::forward<ARGS>(args)...);
@ -103,8 +103,8 @@ class TypeManager final {
TypeIterator end() const { return types_.end(); }
private:
utils::UniqueAllocator<type::Type> types_;
utils::UniqueAllocator<type::Node> nodes_;
utils::UniqueAllocator<Type> types_;
utils::UniqueAllocator<Node> nodes_;
};
} // namespace tint::type

View File

@ -35,51 +35,51 @@ using TypeManagerTest = testing::Test;
TEST_F(TypeManagerTest, GetUnregistered) {
TypeManager tm;
auto* t = tm.Get<type::I32>();
auto* t = tm.Get<I32>();
ASSERT_NE(t, nullptr);
EXPECT_TRUE(t->Is<type::I32>());
EXPECT_TRUE(t->Is<I32>());
}
TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
TypeManager tm;
auto* t = tm.Get<type::I32>();
auto* t = tm.Get<I32>();
ASSERT_NE(t, nullptr);
EXPECT_TRUE(t->Is<type::I32>());
EXPECT_TRUE(t->Is<I32>());
auto* t2 = tm.Get<type::I32>();
auto* t2 = tm.Get<I32>();
EXPECT_EQ(t, t2);
}
TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
TypeManager tm;
type::Type* t = tm.Get<type::I32>();
Type* t = tm.Get<I32>();
ASSERT_NE(t, nullptr);
EXPECT_TRUE(t->Is<type::I32>());
EXPECT_TRUE(t->Is<I32>());
type::Type* t2 = tm.Get<type::U32>();
Type* t2 = tm.Get<U32>();
ASSERT_NE(t2, nullptr);
EXPECT_NE(t, t2);
EXPECT_TRUE(t2->Is<type::U32>());
EXPECT_TRUE(t2->Is<U32>());
}
TEST_F(TypeManagerTest, Find) {
TypeManager tm;
auto* created = tm.Get<type::I32>();
auto* created = tm.Get<I32>();
EXPECT_EQ(tm.Find<type::U32>(), nullptr);
EXPECT_EQ(tm.Find<type::I32>(), created);
EXPECT_EQ(tm.Find<U32>(), nullptr);
EXPECT_EQ(tm.Find<I32>(), created);
}
TEST_F(TypeManagerTest, WrapDoesntAffectInner) {
TypeManager inner;
TypeManager outer = TypeManager::Wrap(inner);
inner.Get<type::I32>();
inner.Get<I32>();
EXPECT_EQ(count(inner), 1u);
EXPECT_EQ(count(outer), 0u);
outer.Get<type::U32>();
outer.Get<U32>();
EXPECT_EQ(count(inner), 1u);
EXPECT_EQ(count(outer), 1u);

View File

@ -23,135 +23,135 @@ namespace tint::type {
namespace {
struct TypeTest : public TestHelper {
const type::AbstractFloat* af = create<type::AbstractFloat>();
const type::AbstractInt* ai = create<type::AbstractInt>();
const type::F32* f32 = create<type::F32>();
const type::F16* f16 = create<type::F16>();
const type::I32* i32 = create<type::I32>();
const type::U32* u32 = create<type::U32>();
const type::Vector* vec2_f32 = create<type::Vector>(f32, 2u);
const type::Vector* vec3_f32 = create<type::Vector>(f32, 3u);
const type::Vector* vec3_f16 = create<type::Vector>(f16, 3u);
const type::Vector* vec4_f32 = create<type::Vector>(f32, 4u);
const type::Vector* vec3_u32 = create<type::Vector>(u32, 3u);
const type::Vector* vec3_i32 = create<type::Vector>(i32, 3u);
const type::Vector* vec3_af = create<type::Vector>(af, 3u);
const type::Vector* vec3_ai = create<type::Vector>(ai, 3u);
const type::Matrix* mat2x4_f32 = create<type::Matrix>(vec4_f32, 2u);
const type::Matrix* mat3x4_f32 = create<type::Matrix>(vec4_f32, 3u);
const type::Matrix* mat4x2_f32 = create<type::Matrix>(vec2_f32, 4u);
const type::Matrix* mat4x3_f32 = create<type::Matrix>(vec3_f32, 4u);
const type::Matrix* mat4x3_f16 = create<type::Matrix>(vec3_f16, 4u);
const type::Matrix* mat4x3_af = create<type::Matrix>(vec3_af, 4u);
const type::Reference* ref_u32 =
create<type::Reference>(u32, ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
const type::StructBase* str_f32 = create<type::StructBase>(Source{},
Sym("str_f32"),
utils::Vector{
create<type::StructMemberBase>(
/* source */ Source{},
/* name */ Sym("x"),
/* type */ f32,
/* index */ 0u,
/* offset */ 0u,
/* align */ 4u,
/* size */ 4u,
/* location */ std::nullopt),
},
/* align*/ 4u,
/* size*/ 4u,
/* size_no_padding*/ 4u);
const type::StructBase* str_f16 = create<type::StructBase>(Source{},
Sym("str_f16"),
utils::Vector{
create<type::StructMemberBase>(
/* source */ Source{},
/* name */ Sym("x"),
/* type */ f16,
/* index */ 0u,
/* offset */ 0u,
/* align */ 4u,
/* size */ 4u,
/* location */ std::nullopt),
},
/* align*/ 4u,
/* size*/ 4u,
/* size_no_padding*/ 4u);
type::StructBase* str_af = create<type::StructBase>(Source{},
Sym("str_af"),
utils::Vector{
create<type::StructMemberBase>(
/* source */ Source{},
/* name */ Sym("x"),
/* type */ af,
/* index */ 0u,
/* offset */ 0u,
/* align */ 4u,
/* size */ 4u,
/* location */ std::nullopt),
},
/* align*/ 4u,
/* size*/ 4u,
/* size_no_padding*/ 4u);
const type::Array* arr_i32 = create<type::Array>(
const AbstractFloat* af = create<AbstractFloat>();
const AbstractInt* ai = create<AbstractInt>();
const F32* f32 = create<F32>();
const F16* f16 = create<F16>();
const I32* i32 = create<I32>();
const U32* u32 = create<U32>();
const Vector* vec2_f32 = create<Vector>(f32, 2u);
const Vector* vec3_f32 = create<Vector>(f32, 3u);
const Vector* vec3_f16 = create<Vector>(f16, 3u);
const Vector* vec4_f32 = create<Vector>(f32, 4u);
const Vector* vec3_u32 = create<Vector>(u32, 3u);
const Vector* vec3_i32 = create<Vector>(i32, 3u);
const Vector* vec3_af = create<Vector>(af, 3u);
const Vector* vec3_ai = create<Vector>(ai, 3u);
const Matrix* mat2x4_f32 = create<Matrix>(vec4_f32, 2u);
const Matrix* mat3x4_f32 = create<Matrix>(vec4_f32, 3u);
const Matrix* mat4x2_f32 = create<Matrix>(vec2_f32, 4u);
const Matrix* mat4x3_f32 = create<Matrix>(vec3_f32, 4u);
const Matrix* mat4x3_f16 = create<Matrix>(vec3_f16, 4u);
const Matrix* mat4x3_af = create<Matrix>(vec3_af, 4u);
const Reference* ref_u32 =
create<Reference>(u32, ast::AddressSpace::kPrivate, ast::Access::kReadWrite);
const StructBase* str_f32 = create<StructBase>(Source{},
Sym("str_f32"),
utils::Vector{
create<StructMemberBase>(
/* source */ Source{},
/* name */ Sym("x"),
/* type */ f32,
/* index */ 0u,
/* offset */ 0u,
/* align */ 4u,
/* size */ 4u,
/* location */ std::nullopt),
},
/* align*/ 4u,
/* size*/ 4u,
/* size_no_padding*/ 4u);
const StructBase* str_f16 = create<StructBase>(Source{},
Sym("str_f16"),
utils::Vector{
create<StructMemberBase>(
/* source */ Source{},
/* name */ Sym("x"),
/* type */ f16,
/* index */ 0u,
/* offset */ 0u,
/* align */ 4u,
/* size */ 4u,
/* location */ std::nullopt),
},
/* align*/ 4u,
/* size*/ 4u,
/* size_no_padding*/ 4u);
StructBase* str_af = create<StructBase>(Source{},
Sym("str_af"),
utils::Vector{
create<StructMemberBase>(
/* source */ Source{},
/* name */ Sym("x"),
/* type */ af,
/* index */ 0u,
/* offset */ 0u,
/* align */ 4u,
/* size */ 4u,
/* location */ std::nullopt),
},
/* align*/ 4u,
/* size*/ 4u,
/* size_no_padding*/ 4u);
const Array* arr_i32 = create<Array>(
/* element */ i32,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 4u,
/* size */ 5u * 4u,
/* stride */ 5u * 4u,
/* implicit_stride */ 5u * 4u);
const type::Array* arr_ai = create<type::Array>(
const Array* arr_ai = create<Array>(
/* element */ ai,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 4u,
/* size */ 5u * 4u,
/* stride */ 5u * 4u,
/* implicit_stride */ 5u * 4u);
const type::Array* arr_vec3_i32 = create<type::Array>(
const Array* arr_vec3_i32 = create<Array>(
/* element */ vec3_i32,
/* count */ create<ConstantArrayCount>(5u),
/* align */ 16u,
/* size */ 5u * 16u,
/* stride */ 5u * 16u,
/* implicit_stride */ 5u * 16u);
const type::Array* arr_vec3_ai = create<type::Array>(
const Array* arr_vec3_ai = create<Array>(
/* element */ vec3_ai,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 16u,
/* size */ 5u * 16u,
/* stride */ 5u * 16u,
/* implicit_stride */ 5u * 16u);
const type::Array* arr_mat4x3_f16 = create<type::Array>(
const Array* arr_mat4x3_f16 = create<Array>(
/* element */ mat4x3_f16,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 32u,
/* size */ 5u * 32u,
/* stride */ 5u * 32u,
/* implicit_stride */ 5u * 32u);
const type::Array* arr_mat4x3_f32 = create<type::Array>(
const Array* arr_mat4x3_f32 = create<Array>(
/* element */ mat4x3_f32,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 64u,
/* size */ 5u * 64u,
/* stride */ 5u * 64u,
/* implicit_stride */ 5u * 64u);
const type::Array* arr_mat4x3_af = create<type::Array>(
const Array* arr_mat4x3_af = create<Array>(
/* element */ mat4x3_af,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 64u,
/* size */ 5u * 64u,
/* stride */ 5u * 64u,
/* implicit_stride */ 5u * 64u);
const type::Array* arr_str_f16 = create<type::Array>(
const Array* arr_str_f16 = create<Array>(
/* element */ str_f16,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 4u,
/* size */ 5u * 4u,
/* stride */ 5u * 4u,
/* implicit_stride */ 5u * 4u);
const type::Array* arr_str_af = create<type::Array>(
const Array* arr_str_af = create<Array>(
/* element */ str_af,
/* count */ create<type::ConstantArrayCount>(5u),
/* count */ create<ConstantArrayCount>(5u),
/* align */ 4u,
/* size */ 5u * 4u,
/* stride */ 5u * 4u,

View File

@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::U32);
namespace tint::type {
U32::U32()
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -22,7 +22,7 @@
namespace tint::type {
/// A unsigned int 32 type.
class U32 final : public Castable<U32, type::Type> {
class U32 final : public Castable<U32, Type> {
public:
/// Constructor
U32();

View File

@ -22,7 +22,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Vector);
namespace tint::type {
Vector::Vector(Type const* subtype, uint32_t width)
: Base(type::TypeFlags{
: Base(TypeFlags{
Flag::kConstructable,
Flag::kCreationFixedFootprint,
Flag::kFixedFootprint,

View File

@ -22,7 +22,7 @@
namespace tint::type {
/// A vector type.
class Vector final : public Castable<Vector, type::Type> {
class Vector final : public Castable<Vector, Type> {
public:
/// Constructor
/// @param subtype the vector element type
@ -40,7 +40,7 @@ class Vector final : public Castable<Vector, type::Type> {
bool Equals(const Type& other) const override;
/// @returns the type of the vector elements
const type::Type* type() const { return subtype_; }
const Type* type() const { return subtype_; }
/// @param symbols the program's symbol table
/// @returns the name for this type that closely resembles how it would be

View File

@ -21,12 +21,12 @@ namespace {
using VectorTest = TestHelper;
TEST_F(VectorTest, Creation) {
auto* a = create<Vector>(create<type::I32>(), 2u);
auto* b = create<Vector>(create<type::I32>(), 2u);
auto* c = create<Vector>(create<type::F32>(), 2u);
auto* d = create<Vector>(create<type::F32>(), 3u);
auto* a = create<Vector>(create<I32>(), 2u);
auto* b = create<Vector>(create<I32>(), 2u);
auto* c = create<Vector>(create<F32>(), 2u);
auto* d = create<Vector>(create<F32>(), 3u);
EXPECT_EQ(a->type(), create<type::I32>());
EXPECT_EQ(a->type(), create<I32>());
EXPECT_EQ(a->Width(), 2u);
EXPECT_EQ(a, b);
@ -35,10 +35,10 @@ TEST_F(VectorTest, Creation) {
}
TEST_F(VectorTest, Hash) {
auto* a = create<Vector>(create<type::I32>(), 2u);
auto* b = create<Vector>(create<type::I32>(), 2u);
auto* c = create<Vector>(create<type::F32>(), 2u);
auto* d = create<Vector>(create<type::F32>(), 3u);
auto* a = create<Vector>(create<I32>(), 2u);
auto* b = create<Vector>(create<I32>(), 2u);
auto* c = create<Vector>(create<F32>(), 2u);
auto* d = create<Vector>(create<F32>(), 3u);
EXPECT_EQ(a->Hash(), b->Hash());
EXPECT_NE(a->Hash(), c->Hash());
@ -46,19 +46,19 @@ TEST_F(VectorTest, Hash) {
}
TEST_F(VectorTest, Equals) {
auto* a = create<Vector>(create<type::I32>(), 2u);
auto* b = create<Vector>(create<type::I32>(), 2u);
auto* c = create<Vector>(create<type::F32>(), 2u);
auto* d = create<Vector>(create<type::F32>(), 3u);
auto* a = create<Vector>(create<I32>(), 2u);
auto* b = create<Vector>(create<I32>(), 2u);
auto* c = create<Vector>(create<F32>(), 2u);
auto* d = create<Vector>(create<F32>(), 3u);
EXPECT_TRUE(a->Equals(*b));
EXPECT_FALSE(a->Equals(*c));
EXPECT_FALSE(a->Equals(*d));
EXPECT_FALSE(a->Equals(type::Void{}));
EXPECT_FALSE(a->Equals(Void{}));
}
TEST_F(VectorTest, FriendlyName) {
auto* f32 = create<type::F32>();
auto* f32 = create<F32>();
auto* v = create<Vector>(f32, 3u);
EXPECT_EQ(v->FriendlyName(Symbols()), "vec3<f32>");
}

View File

@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Void);
namespace tint::type {
Void::Void() : Base(type::TypeFlags{}) {}
Void::Void() : Base(TypeFlags{}) {}
Void::Void(Void&&) = default;

View File

@ -22,7 +22,7 @@
namespace tint::type {
/// A void type
class Void final : public Castable<Void, type::Type> {
class Void final : public Castable<Void, Type> {
public:
/// Constructor
Void();