mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Replace Type::(Is|As)U32 with Castable
Change-Id: I4999d45950fdffe4345cf0abae1b026244abba1d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34273 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
@@ -63,7 +63,7 @@ TEST_F(AccessControlTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ TEST_F(AliasTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ TEST_F(ArrayTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -45,7 +46,7 @@ TEST_F(BoolTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -46,7 +47,7 @@ TEST_F(DepthTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -45,7 +46,7 @@ TEST_F(F32TypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -45,7 +46,7 @@ TEST_F(I32TypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -54,7 +55,7 @@ TEST_F(MatrixTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -46,7 +47,7 @@ TEST_F(MultisampledTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -53,7 +54,7 @@ TEST_F(PointerTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -46,7 +47,7 @@ TEST_F(SampledTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -57,7 +58,7 @@ TEST_F(SamplerTypeTest, Is) {
|
||||
EXPECT_TRUE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
#include "src/type_determiner.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -50,7 +51,7 @@ TEST_F(StorageTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_TRUE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
@@ -111,7 +112,8 @@ TEST_F(StorageTextureTypeTest, U32Type) {
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
ASSERT_TRUE(s->Is<TextureType>());
|
||||
ASSERT_TRUE(s->As<TextureType>()->IsStorage());
|
||||
EXPECT_TRUE(s->As<TextureType>()->AsStorage()->type()->IsU32());
|
||||
EXPECT_TRUE(
|
||||
s->As<TextureType>()->AsStorage()->type()->Is<ast::type::U32Type>());
|
||||
}
|
||||
|
||||
TEST_F(StorageTextureTypeTest, I32Type) {
|
||||
|
||||
@@ -61,7 +61,7 @@ TEST_F(StructTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_TRUE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,6 @@ Type* Type::UnwrapAll() {
|
||||
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
|
||||
}
|
||||
|
||||
bool Type::IsU32() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsVector() const {
|
||||
return false;
|
||||
}
|
||||
@@ -107,11 +103,11 @@ bool Type::is_float_scalar_or_vector() {
|
||||
}
|
||||
|
||||
bool Type::is_integer_scalar() {
|
||||
return IsU32() || Is<I32Type>();
|
||||
return Is<U32Type>() || Is<I32Type>();
|
||||
}
|
||||
|
||||
bool Type::is_unsigned_integer_vector() {
|
||||
return IsVector() && AsVector()->type()->IsU32();
|
||||
return IsVector() && AsVector()->type()->Is<U32Type>();
|
||||
}
|
||||
|
||||
bool Type::is_signed_integer_vector() {
|
||||
@@ -119,7 +115,7 @@ bool Type::is_signed_integer_vector() {
|
||||
}
|
||||
|
||||
bool Type::is_unsigned_scalar_or_vector() {
|
||||
return IsU32() || (IsVector() && AsVector()->type()->IsU32());
|
||||
return Is<U32Type>() || (IsVector() && AsVector()->type()->Is<U32Type>());
|
||||
}
|
||||
|
||||
bool Type::is_signed_scalar_or_vector() {
|
||||
@@ -130,11 +126,6 @@ bool Type::is_integer_scalar_or_vector() {
|
||||
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
|
||||
}
|
||||
|
||||
const U32Type* Type::AsU32() const {
|
||||
assert(IsU32());
|
||||
return static_cast<const U32Type*>(this);
|
||||
}
|
||||
|
||||
const VectorType* Type::AsVector() const {
|
||||
assert(IsVector());
|
||||
return static_cast<const VectorType*>(this);
|
||||
@@ -145,11 +136,6 @@ const VoidType* Type::AsVoid() const {
|
||||
return static_cast<const VoidType*>(this);
|
||||
}
|
||||
|
||||
U32Type* Type::AsU32() {
|
||||
assert(IsU32());
|
||||
return static_cast<U32Type*>(this);
|
||||
}
|
||||
|
||||
VectorType* Type::AsVector() {
|
||||
assert(IsVector());
|
||||
return static_cast<VectorType*>(this);
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace tint {
|
||||
namespace ast {
|
||||
namespace type {
|
||||
|
||||
class U32Type;
|
||||
class VectorType;
|
||||
class VoidType;
|
||||
|
||||
@@ -37,8 +36,6 @@ class Type : public Castable<Type> {
|
||||
Type(Type&&);
|
||||
~Type() override;
|
||||
|
||||
/// @returns true if the type is a u32 type
|
||||
virtual bool IsU32() const;
|
||||
/// @returns true if the type is a vec type
|
||||
virtual bool IsVector() const;
|
||||
/// @returns true if the type is a void type
|
||||
@@ -98,15 +95,11 @@ class Type : public Castable<Type> {
|
||||
/// @returns true if this type is an integer scalar or vector
|
||||
bool is_integer_scalar_or_vector();
|
||||
|
||||
/// @returns the type as a u32 type
|
||||
const U32Type* AsU32() const;
|
||||
/// @returns the type as a vector type
|
||||
const VectorType* AsVector() const;
|
||||
/// @returns the type as a void type
|
||||
const VoidType* AsVoid() const;
|
||||
|
||||
/// @returns the type as a u32 type
|
||||
U32Type* AsU32();
|
||||
/// @returns the type as a vector type
|
||||
VectorType* AsVector();
|
||||
/// @returns the type as a void type
|
||||
|
||||
@@ -24,10 +24,6 @@ U32Type::~U32Type() = default;
|
||||
|
||||
U32Type::U32Type(U32Type&&) = default;
|
||||
|
||||
bool U32Type::IsU32() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string U32Type::type_name() const {
|
||||
return "__u32";
|
||||
}
|
||||
|
||||
@@ -32,9 +32,6 @@ class U32Type : public Castable<U32Type, Type> {
|
||||
U32Type(U32Type&&);
|
||||
~U32Type() override;
|
||||
|
||||
/// @returns true if the type is a u32 type
|
||||
bool IsU32() const override;
|
||||
|
||||
/// @returns the name for th type
|
||||
std::string type_name() const override;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_F(U32TypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_TRUE(ty->IsU32());
|
||||
EXPECT_TRUE(ty->Is<U32Type>());
|
||||
EXPECT_FALSE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
#include "src/ast/type/texture_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -54,7 +55,7 @@ TEST_F(VectorTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<SamplerType>());
|
||||
EXPECT_FALSE(ty->Is<StructType>());
|
||||
EXPECT_FALSE(ty->Is<TextureType>());
|
||||
EXPECT_FALSE(ty->IsU32());
|
||||
EXPECT_FALSE(ty->Is<U32Type>());
|
||||
EXPECT_TRUE(ty->IsVector());
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
|
||||
auto* t2 = tm.Get(std::make_unique<ast::type::U32Type>());
|
||||
ASSERT_NE(t2, nullptr);
|
||||
EXPECT_NE(t, t2);
|
||||
EXPECT_TRUE(t2->IsU32());
|
||||
EXPECT_TRUE(t2->Is<ast::type::U32Type>());
|
||||
}
|
||||
|
||||
TEST_F(TypeManagerTest, ResetClearsPreviousData) {
|
||||
|
||||
Reference in New Issue
Block a user