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:
parent
af37c4ae83
commit
f3639b787f
|
@ -24,6 +24,7 @@
|
||||||
#include "src/ast/struct_member_offset_decoration.h"
|
#include "src/ast/struct_member_offset_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/array_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/i32_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/ast/type/pointer_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/ast/type/struct_type.h"
|
||||||
|
@ -51,7 +52,7 @@ TEST_F(AccessControlTypeTest, Is) {
|
||||||
EXPECT_TRUE(ty->Is<AccessControlType>());
|
EXPECT_TRUE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_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/i32_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/ast/type/pointer_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/ast/type/struct_type.h"
|
||||||
|
@ -52,7 +53,7 @@ TEST_F(AliasTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_TRUE(ty->Is<AliasType>());
|
EXPECT_TRUE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "src/ast/stride_decoration.h"
|
#include "src/ast/stride_decoration.h"
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.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/i32_type.h"
|
||||||
#include "src/ast/type/u32_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<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_TRUE(ty->Is<ArrayType>());
|
EXPECT_TRUE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -24,10 +24,6 @@ BoolType::BoolType(BoolType&&) = default;
|
||||||
|
|
||||||
BoolType::~BoolType() = default;
|
BoolType::~BoolType() = default;
|
||||||
|
|
||||||
bool BoolType::IsBool() const {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string BoolType::type_name() const {
|
std::string BoolType::type_name() const {
|
||||||
return "__bool";
|
return "__bool";
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,6 @@ class BoolType : public Castable<BoolType, Type> {
|
||||||
BoolType(BoolType&&);
|
BoolType(BoolType&&);
|
||||||
~BoolType() override;
|
~BoolType() override;
|
||||||
|
|
||||||
/// @returns true if the type is a bool type
|
|
||||||
bool IsBool() const override;
|
|
||||||
|
|
||||||
/// @returns the name for this type
|
/// @returns the name for this type
|
||||||
std::string type_name() const override;
|
std::string type_name() const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,7 @@ TEST_F(BoolTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_TRUE(ty->IsBool());
|
EXPECT_TRUE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -32,7 +33,7 @@ TEST_F(DepthTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -31,7 +32,7 @@ TEST_F(F32TypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_TRUE(ty->IsF32());
|
EXPECT_TRUE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -31,7 +32,7 @@ TEST_F(I32TypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_TRUE(ty->IsI32());
|
EXPECT_TRUE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_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/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -41,7 +42,7 @@ TEST_F(MatrixTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_TRUE(ty->IsMatrix());
|
EXPECT_TRUE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/ast/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -33,7 +34,7 @@ TEST_F(MultisampledTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_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/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -40,7 +41,7 @@ TEST_F(PointerTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/ast/type/f32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -33,7 +34,7 @@ TEST_F(SampledTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -42,7 +43,7 @@ TEST_F(SamplerTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/type_determiner.h"
|
#include "src/type_determiner.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -36,7 +37,7 @@ TEST_F(StorageTextureTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_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/i32_type.h"
|
||||||
#include "src/ast/type/u32_type.h"
|
#include "src/ast/type/u32_type.h"
|
||||||
#include "src/ast/type/vector_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<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -66,10 +66,6 @@ Type* Type::UnwrapAll() {
|
||||||
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
|
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::IsBool() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Type::IsF32() const {
|
bool Type::IsF32() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +115,7 @@ uint64_t Type::BaseAlignment(MemoryLayout) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::is_scalar() {
|
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() {
|
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();
|
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 {
|
const F32Type* Type::AsF32() const {
|
||||||
assert(IsF32());
|
assert(IsF32());
|
||||||
return static_cast<const F32Type*>(this);
|
return static_cast<const F32Type*>(this);
|
||||||
|
@ -217,11 +208,6 @@ const VoidType* Type::AsVoid() const {
|
||||||
return static_cast<const VoidType*>(this);
|
return static_cast<const VoidType*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
BoolType* Type::AsBool() {
|
|
||||||
assert(IsBool());
|
|
||||||
return static_cast<BoolType*>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
F32Type* Type::AsF32() {
|
F32Type* Type::AsF32() {
|
||||||
assert(IsF32());
|
assert(IsF32());
|
||||||
return static_cast<F32Type*>(this);
|
return static_cast<F32Type*>(this);
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
class BoolType;
|
|
||||||
class F32Type;
|
class F32Type;
|
||||||
class I32Type;
|
class I32Type;
|
||||||
class MatrixType;
|
class MatrixType;
|
||||||
|
@ -45,8 +44,6 @@ class Type : public Castable<Type> {
|
||||||
Type(Type&&);
|
Type(Type&&);
|
||||||
~Type() override;
|
~Type() override;
|
||||||
|
|
||||||
/// @returns true if the type is a bool type
|
|
||||||
virtual bool IsBool() const;
|
|
||||||
/// @returns true if the type is an f32 type
|
/// @returns true if the type is an f32 type
|
||||||
virtual bool IsF32() const;
|
virtual bool IsF32() const;
|
||||||
/// @returns true if the type is an i32 type
|
/// @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
|
/// @returns true if this type is an integer scalar or vector
|
||||||
bool is_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
|
/// @returns the type as a f32 type
|
||||||
const F32Type* AsF32() const;
|
const F32Type* AsF32() const;
|
||||||
/// @returns the type as an i32 type
|
/// @returns the type as an i32 type
|
||||||
|
@ -145,8 +140,6 @@ class Type : public Castable<Type> {
|
||||||
/// @returns the type as a void type
|
/// @returns the type as a void type
|
||||||
const VoidType* AsVoid() const;
|
const VoidType* AsVoid() const;
|
||||||
|
|
||||||
/// @returns the type as a bool type
|
|
||||||
BoolType* AsBool();
|
|
||||||
/// @returns the type as a f32 type
|
/// @returns the type as a f32 type
|
||||||
F32Type* AsF32();
|
F32Type* AsF32();
|
||||||
/// @returns the type as an i32 type
|
/// @returns the type as an i32 type
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -31,7 +32,7 @@ TEST_F(U32TypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_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/i32_type.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -40,7 +41,7 @@ TEST_F(VectorTypeTest, Is) {
|
||||||
EXPECT_FALSE(ty->Is<AccessControlType>());
|
EXPECT_FALSE(ty->Is<AccessControlType>());
|
||||||
EXPECT_FALSE(ty->Is<AliasType>());
|
EXPECT_FALSE(ty->Is<AliasType>());
|
||||||
EXPECT_FALSE(ty->Is<ArrayType>());
|
EXPECT_FALSE(ty->Is<ArrayType>());
|
||||||
EXPECT_FALSE(ty->IsBool());
|
EXPECT_FALSE(ty->Is<BoolType>());
|
||||||
EXPECT_FALSE(ty->IsF32());
|
EXPECT_FALSE(ty->IsF32());
|
||||||
EXPECT_FALSE(ty->IsI32());
|
EXPECT_FALSE(ty->IsI32());
|
||||||
EXPECT_FALSE(ty->IsMatrix());
|
EXPECT_FALSE(ty->IsMatrix());
|
||||||
|
|
|
@ -3597,7 +3597,7 @@ TypedExpression FunctionEmitter::MakeSimpleSelect(
|
||||||
// a VariablePointers* capability, which is not allowed in by WebGPU.
|
// a VariablePointers* capability, which is not allowed in by WebGPU.
|
||||||
auto* op_ty = operand1.type;
|
auto* op_ty = operand1.type;
|
||||||
if (op_ty->IsVector() || op_ty->is_float_scalar() ||
|
if (op_ty->IsVector() || op_ty->is_float_scalar() ||
|
||||||
op_ty->is_integer_scalar() || op_ty->IsBool()) {
|
op_ty->is_integer_scalar() || op_ty->Is<ast::type::BoolType>()) {
|
||||||
ast::ExpressionList params;
|
ast::ExpressionList params;
|
||||||
params.push_back(operand1.expr);
|
params.push_back(operand1.expr);
|
||||||
params.push_back(operand2.expr);
|
params.push_back(operand2.expr);
|
||||||
|
|
|
@ -1277,7 +1277,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
||||||
create<ast::ScalarConstructorExpression>(
|
create<ast::ScalarConstructorExpression>(
|
||||||
create<ast::FloatLiteral>(ast_type, spirv_const->GetFloat()))};
|
create<ast::FloatLiteral>(ast_type, spirv_const->GetFloat()))};
|
||||||
}
|
}
|
||||||
if (ast_type->IsBool()) {
|
if (ast_type->Is<ast::type::BoolType>()) {
|
||||||
const bool value = spirv_const->AsNullConstant()
|
const bool value = spirv_const->AsNullConstant()
|
||||||
? false
|
? false
|
||||||
: spirv_const->AsBoolConstant()->value();
|
: spirv_const->AsBoolConstant()->value();
|
||||||
|
@ -1334,7 +1334,7 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
||||||
auto* original_type = type;
|
auto* original_type = type;
|
||||||
type = type->UnwrapIfNeeded();
|
type = type->UnwrapIfNeeded();
|
||||||
|
|
||||||
if (type->IsBool()) {
|
if (type->Is<ast::type::BoolType>()) {
|
||||||
return create<ast::ScalarConstructorExpression>(
|
return create<ast::ScalarConstructorExpression>(
|
||||||
create<ast::BoolLiteral>(type, false));
|
create<ast::BoolLiteral>(type, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/ast/type/matrix_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/ast/type/pointer_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/ast/type/struct_type.h"
|
||||||
|
@ -96,7 +97,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
|
||||||
EXPECT_TRUE(p->BuildInternalModule());
|
EXPECT_TRUE(p->BuildInternalModule());
|
||||||
|
|
||||||
auto* type = p->ConvertType(100);
|
auto* type = p->ConvertType(100);
|
||||||
EXPECT_TRUE(type->IsBool());
|
EXPECT_TRUE(type->Is<ast::type::BoolType>());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ TEST_F(ParserImplTest, TypeDecl_Bool) {
|
||||||
EXPECT_FALSE(t.errored);
|
EXPECT_FALSE(t.errored);
|
||||||
ASSERT_NE(t.value, nullptr) << p->error();
|
ASSERT_NE(t.value, nullptr) << p->error();
|
||||||
EXPECT_EQ(t.value, bool_type);
|
EXPECT_EQ(t.value, bool_type);
|
||||||
ASSERT_TRUE(t->IsBool());
|
ASSERT_TRUE(t->Is<ast::type::BoolType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_F32) {
|
TEST_F(ParserImplTest, TypeDecl_F32) {
|
||||||
|
|
|
@ -1190,7 +1190,7 @@ TEST_P(Expr_Binary_LogicalTest, Scalar) {
|
||||||
|
|
||||||
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
||||||
ASSERT_NE(expr.result_type(), nullptr);
|
ASSERT_NE(expr.result_type(), nullptr);
|
||||||
EXPECT_TRUE(expr.result_type()->IsBool());
|
EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(Expr_Binary_LogicalTest, Vector) {
|
TEST_P(Expr_Binary_LogicalTest, Vector) {
|
||||||
|
@ -1211,7 +1211,8 @@ TEST_P(Expr_Binary_LogicalTest, Vector) {
|
||||||
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
||||||
ASSERT_NE(expr.result_type(), nullptr);
|
ASSERT_NE(expr.result_type(), nullptr);
|
||||||
ASSERT_TRUE(expr.result_type()->IsVector());
|
ASSERT_TRUE(expr.result_type()->IsVector());
|
||||||
EXPECT_TRUE(expr.result_type()->AsVector()->type()->IsBool());
|
EXPECT_TRUE(
|
||||||
|
expr.result_type()->AsVector()->type()->Is<ast::type::BoolType>());
|
||||||
EXPECT_EQ(expr.result_type()->AsVector()->size(), 3u);
|
EXPECT_EQ(expr.result_type()->AsVector()->size(), 3u);
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
||||||
|
@ -1236,7 +1237,7 @@ TEST_P(Expr_Binary_CompareTest, Scalar) {
|
||||||
|
|
||||||
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
||||||
ASSERT_NE(expr.result_type(), nullptr);
|
ASSERT_NE(expr.result_type(), nullptr);
|
||||||
EXPECT_TRUE(expr.result_type()->IsBool());
|
EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(Expr_Binary_CompareTest, Vector) {
|
TEST_P(Expr_Binary_CompareTest, Vector) {
|
||||||
|
@ -1257,7 +1258,8 @@ TEST_P(Expr_Binary_CompareTest, Vector) {
|
||||||
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
|
||||||
ASSERT_NE(expr.result_type(), nullptr);
|
ASSERT_NE(expr.result_type(), nullptr);
|
||||||
ASSERT_TRUE(expr.result_type()->IsVector());
|
ASSERT_TRUE(expr.result_type()->IsVector());
|
||||||
EXPECT_TRUE(expr.result_type()->AsVector()->type()->IsBool());
|
EXPECT_TRUE(
|
||||||
|
expr.result_type()->AsVector()->type()->Is<ast::type::BoolType>());
|
||||||
EXPECT_EQ(expr.result_type()->AsVector()->size(), 3u);
|
EXPECT_EQ(expr.result_type()->AsVector()->size(), 3u);
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
||||||
|
@ -1616,7 +1618,7 @@ TEST_P(Intrinsic, Test) {
|
||||||
|
|
||||||
EXPECT_TRUE(td()->DetermineResultType(&expr));
|
EXPECT_TRUE(td()->DetermineResultType(&expr));
|
||||||
ASSERT_NE(expr.result_type(), nullptr);
|
ASSERT_NE(expr.result_type(), nullptr);
|
||||||
EXPECT_TRUE(expr.result_type()->IsBool());
|
EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
|
||||||
}
|
}
|
||||||
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
||||||
Intrinsic,
|
Intrinsic,
|
||||||
|
@ -1644,7 +1646,8 @@ TEST_P(Intrinsic_FloatMethod, Vector) {
|
||||||
|
|
||||||
ASSERT_NE(expr.result_type(), nullptr);
|
ASSERT_NE(expr.result_type(), nullptr);
|
||||||
ASSERT_TRUE(expr.result_type()->IsVector());
|
ASSERT_TRUE(expr.result_type()->IsVector());
|
||||||
EXPECT_TRUE(expr.result_type()->AsVector()->type()->IsBool());
|
EXPECT_TRUE(
|
||||||
|
expr.result_type()->AsVector()->type()->Is<ast::type::BoolType>());
|
||||||
EXPECT_EQ(expr.result_type()->AsVector()->size(), 3u);
|
EXPECT_EQ(expr.result_type()->AsVector()->size(), 3u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1666,7 +1669,7 @@ TEST_P(Intrinsic_FloatMethod, Scalar) {
|
||||||
EXPECT_TRUE(td()->Determine());
|
EXPECT_TRUE(td()->Determine());
|
||||||
EXPECT_TRUE(td()->DetermineResultType(&expr));
|
EXPECT_TRUE(td()->DetermineResultType(&expr));
|
||||||
ASSERT_NE(expr.result_type(), nullptr);
|
ASSERT_NE(expr.result_type(), nullptr);
|
||||||
EXPECT_TRUE(expr.result_type()->IsBool());
|
EXPECT_TRUE(expr.result_type()->Is<ast::type::BoolType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(Intrinsic_FloatMethod, MissingParam) {
|
TEST_P(Intrinsic_FloatMethod, MissingParam) {
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/alias_type.h"
|
#include "src/ast/type/alias_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/ast/type/f32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/ast/type/i32_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/ast/type/matrix_type.h"
|
||||||
|
@ -1542,7 +1543,7 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, ast::Literal* lit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitZeroValue(std::ostream& out, ast::type::Type* type) {
|
bool GeneratorImpl::EmitZeroValue(std::ostream& out, ast::type::Type* type) {
|
||||||
if (type->IsBool()) {
|
if (type->Is<ast::type::BoolType>()) {
|
||||||
out << "false";
|
out << "false";
|
||||||
} else if (type->IsF32()) {
|
} else if (type->IsF32()) {
|
||||||
out << "0.0f";
|
out << "0.0f";
|
||||||
|
@ -2057,7 +2058,7 @@ bool GeneratorImpl::EmitType(std::ostream& out,
|
||||||
for (uint32_t size : sizes) {
|
for (uint32_t size : sizes) {
|
||||||
out << "[" << size << "]";
|
out << "[" << size << "]";
|
||||||
}
|
}
|
||||||
} else if (type->IsBool()) {
|
} else if (type->Is<ast::type::BoolType>()) {
|
||||||
out << "bool";
|
out << "bool";
|
||||||
} else if (type->IsF32()) {
|
} else if (type->IsF32()) {
|
||||||
out << "float";
|
out << "float";
|
||||||
|
|
|
@ -194,7 +194,7 @@ uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) {
|
||||||
uint32_t type_size = calculate_alignment_size(ary->type());
|
uint32_t type_size = calculate_alignment_size(ary->type());
|
||||||
return ary->size() * type_size;
|
return ary->size() * type_size;
|
||||||
}
|
}
|
||||||
if (type->IsBool()) {
|
if (type->Is<ast::type::BoolType>()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (type->IsPointer()) {
|
if (type->IsPointer()) {
|
||||||
|
@ -928,7 +928,7 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitZeroValue(ast::type::Type* type) {
|
bool GeneratorImpl::EmitZeroValue(ast::type::Type* type) {
|
||||||
if (type->IsBool()) {
|
if (type->Is<ast::type::BoolType>()) {
|
||||||
out_ << "false";
|
out_ << "false";
|
||||||
} else if (type->IsF32()) {
|
} else if (type->IsF32()) {
|
||||||
out_ << "0.0f";
|
out_ << "0.0f";
|
||||||
|
@ -1812,7 +1812,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) {
|
||||||
for (uint32_t size : sizes) {
|
for (uint32_t size : sizes) {
|
||||||
out_ << "[" << size << "]";
|
out_ << "[" << size << "]";
|
||||||
}
|
}
|
||||||
} else if (type->IsBool()) {
|
} else if (type->Is<ast::type::BoolType>()) {
|
||||||
out_ << "bool";
|
out_ << "bool";
|
||||||
} else if (type->IsF32()) {
|
} else if (type->IsF32()) {
|
||||||
out_ << "float";
|
out_ << "float";
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
#include "src/ast/type/depth_texture_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/ast/type/f32_type.h"
|
||||||
#include "src/ast/type/i32_type.h"
|
#include "src/ast/type/i32_type.h"
|
||||||
|
@ -750,7 +751,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
||||||
} else if (type->IsI32()) {
|
} else if (type->IsI32()) {
|
||||||
ast::SintLiteral l(type, 0);
|
ast::SintLiteral l(type, 0);
|
||||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||||
} else if (type->IsBool()) {
|
} else if (type->Is<ast::type::BoolType>()) {
|
||||||
ast::BoolLiteral l(type, false);
|
ast::BoolLiteral l(type, false);
|
||||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1407,7 +1408,8 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(ast::type::Type* to_type,
|
||||||
(from_type->is_float_vector() &&
|
(from_type->is_float_vector() &&
|
||||||
to_type->is_unsigned_integer_vector())) {
|
to_type->is_unsigned_integer_vector())) {
|
||||||
op = spv::Op::OpConvertFToU;
|
op = spv::Op::OpConvertFToU;
|
||||||
} else if ((from_type->IsBool() && to_type->IsBool()) ||
|
} else if ((from_type->Is<ast::type::BoolType>() &&
|
||||||
|
to_type->Is<ast::type::BoolType>()) ||
|
||||||
(from_type->IsU32() && to_type->IsU32()) ||
|
(from_type->IsU32() && to_type->IsU32()) ||
|
||||||
(from_type->IsI32() && to_type->IsI32()) ||
|
(from_type->IsI32() && to_type->IsI32()) ||
|
||||||
(from_type->IsF32() && to_type->IsF32()) ||
|
(from_type->IsF32() && to_type->IsF32()) ||
|
||||||
|
@ -2414,7 +2416,7 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) {
|
||||||
if (!GenerateArrayType(type->As<ast::type::ArrayType>(), result)) {
|
if (!GenerateArrayType(type->As<ast::type::ArrayType>(), result)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (type->IsBool()) {
|
} else if (type->Is<ast::type::BoolType>()) {
|
||||||
push_type(spv::Op::OpTypeBool, {result});
|
push_type(spv::Op::OpTypeBool, {result});
|
||||||
} else if (type->IsF32()) {
|
} else if (type->IsF32()) {
|
||||||
push_type(spv::Op::OpTypeFloat, {result, Operand::Int(32)});
|
push_type(spv::Op::OpTypeFloat, {result, Operand::Int(32)});
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/type/access_control_type.h"
|
#include "src/ast/type/access_control_type.h"
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/ast/type/depth_texture_type.h"
|
#include "src/ast/type/depth_texture_type.h"
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/ast/type/matrix_type.h"
|
||||||
#include "src/ast/type/multisampled_texture_type.h"
|
#include "src/ast/type/multisampled_texture_type.h"
|
||||||
|
@ -430,7 +431,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) {
|
||||||
out_ << ", " << ary->size();
|
out_ << ", " << ary->size();
|
||||||
|
|
||||||
out_ << ">";
|
out_ << ">";
|
||||||
} else if (type->IsBool()) {
|
} else if (type->Is<ast::type::BoolType>()) {
|
||||||
out_ << "bool";
|
out_ << "bool";
|
||||||
} else if (type->IsF32()) {
|
} else if (type->IsF32()) {
|
||||||
out_ << "f32";
|
out_ << "f32";
|
||||||
|
|
Loading…
Reference in New Issue