mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Replace Type::(Is|As)Bool with Castable
Change-Id: I60ed33bd9a54b14bb9b35f3cd999a2604c2c4450 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34265 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "src/ast/struct_member_offset_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
@@ -51,7 +52,7 @@ TEST_F(AccessControlTypeTest, Is) {
|
||||
EXPECT_TRUE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
@@ -52,7 +53,7 @@ TEST_F(AliasTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_TRUE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "src/ast/stride_decoration.h"
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
@@ -56,7 +57,7 @@ TEST_F(ArrayTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_TRUE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -24,10 +24,6 @@ BoolType::BoolType(BoolType&&) = default;
|
||||
|
||||
BoolType::~BoolType() = default;
|
||||
|
||||
bool BoolType::IsBool() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BoolType::type_name() const {
|
||||
return "__bool";
|
||||
}
|
||||
|
||||
@@ -32,9 +32,6 @@ class BoolType : public Castable<BoolType, Type> {
|
||||
BoolType(BoolType&&);
|
||||
~BoolType() override;
|
||||
|
||||
/// @returns true if the type is a bool type
|
||||
bool IsBool() const override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@ TEST_F(BoolTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_TRUE(ty->IsBool());
|
||||
EXPECT_TRUE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -32,7 +33,7 @@ TEST_F(DepthTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -31,7 +32,7 @@ TEST_F(F32TypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_TRUE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -31,7 +32,7 @@ TEST_F(I32TypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_TRUE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -41,7 +42,7 @@ TEST_F(MatrixTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_TRUE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/f32_type.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -33,7 +34,7 @@ TEST_F(MultisampledTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -40,7 +41,7 @@ TEST_F(PointerTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/f32_type.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -33,7 +34,7 @@ TEST_F(SampledTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -42,7 +43,7 @@ TEST_F(SamplerTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/type_determiner.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -36,7 +37,7 @@ TEST_F(StorageTextureTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/u32_type.h"
|
||||
#include "src/ast/type/vector_type.h"
|
||||
@@ -48,7 +49,7 @@ TEST_F(StructTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -66,10 +66,6 @@ Type* Type::UnwrapAll() {
|
||||
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
|
||||
}
|
||||
|
||||
bool Type::IsBool() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Type::IsF32() const {
|
||||
return false;
|
||||
}
|
||||
@@ -119,7 +115,7 @@ uint64_t Type::BaseAlignment(MemoryLayout) const {
|
||||
}
|
||||
|
||||
bool Type::is_scalar() {
|
||||
return is_float_scalar() || is_integer_scalar() || IsBool();
|
||||
return is_float_scalar() || is_integer_scalar() || Is<BoolType>();
|
||||
}
|
||||
|
||||
bool Type::is_float_scalar() {
|
||||
@@ -162,11 +158,6 @@ bool Type::is_integer_scalar_or_vector() {
|
||||
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
|
||||
}
|
||||
|
||||
const BoolType* Type::AsBool() const {
|
||||
assert(IsBool());
|
||||
return static_cast<const BoolType*>(this);
|
||||
}
|
||||
|
||||
const F32Type* Type::AsF32() const {
|
||||
assert(IsF32());
|
||||
return static_cast<const F32Type*>(this);
|
||||
@@ -217,11 +208,6 @@ const VoidType* Type::AsVoid() const {
|
||||
return static_cast<const VoidType*>(this);
|
||||
}
|
||||
|
||||
BoolType* Type::AsBool() {
|
||||
assert(IsBool());
|
||||
return static_cast<BoolType*>(this);
|
||||
}
|
||||
|
||||
F32Type* Type::AsF32() {
|
||||
assert(IsF32());
|
||||
return static_cast<F32Type*>(this);
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace tint {
|
||||
namespace ast {
|
||||
namespace type {
|
||||
|
||||
class BoolType;
|
||||
class F32Type;
|
||||
class I32Type;
|
||||
class MatrixType;
|
||||
@@ -45,8 +44,6 @@ class Type : public Castable<Type> {
|
||||
Type(Type&&);
|
||||
~Type() override;
|
||||
|
||||
/// @returns true if the type is a bool type
|
||||
virtual bool IsBool() const;
|
||||
/// @returns true if the type is an f32 type
|
||||
virtual bool IsF32() const;
|
||||
/// @returns true if the type is an i32 type
|
||||
@@ -122,8 +119,6 @@ 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 bool type
|
||||
const BoolType* AsBool() const;
|
||||
/// @returns the type as a f32 type
|
||||
const F32Type* AsF32() const;
|
||||
/// @returns the type as an i32 type
|
||||
@@ -145,8 +140,6 @@ class Type : public Castable<Type> {
|
||||
/// @returns the type as a void type
|
||||
const VoidType* AsVoid() const;
|
||||
|
||||
/// @returns the type as a bool type
|
||||
BoolType* AsBool();
|
||||
/// @returns the type as a f32 type
|
||||
F32Type* AsF32();
|
||||
/// @returns the type as an i32 type
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
@@ -31,7 +32,7 @@ TEST_F(U32TypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "src/ast/test_helper.h"
|
||||
#include "src/ast/type/access_control_type.h"
|
||||
#include "src/ast/type/array_type.h"
|
||||
#include "src/ast/type/bool_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -40,7 +41,7 @@ TEST_F(VectorTypeTest, Is) {
|
||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||
EXPECT_FALSE(ty->Is<AliasType>());
|
||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||
EXPECT_FALSE(ty->IsBool());
|
||||
EXPECT_FALSE(ty->Is<BoolType>());
|
||||
EXPECT_FALSE(ty->IsF32());
|
||||
EXPECT_FALSE(ty->IsI32());
|
||||
EXPECT_FALSE(ty->IsMatrix());
|
||||
|
||||
Reference in New Issue
Block a user