mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Replace Type::(Is|As)I32 with Castable
Change-Id: Id130581f72e762bd398a4c1c509cdbe21739e750 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34267 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
@@ -975,7 +975,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
||||
case SpvOpSpecConstant: {
|
||||
ast_type = ConvertType(inst.type_id());
|
||||
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
|
||||
if (ast_type->IsI32()) {
|
||||
if (ast_type->Is<ast::type::I32Type>()) {
|
||||
ast_expr =
|
||||
create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
|
||||
ast_type, static_cast<int32_t>(literal_value)));
|
||||
@@ -1267,7 +1267,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(ast_type, spirv_const->GetU32()))};
|
||||
}
|
||||
if (ast_type->IsI32()) {
|
||||
if (ast_type->Is<ast::type::I32Type>()) {
|
||||
return {ast_type,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(ast_type, spirv_const->GetS32()))};
|
||||
@@ -1342,7 +1342,7 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(type, 0u));
|
||||
}
|
||||
if (type->IsI32()) {
|
||||
if (type->Is<ast::type::I32Type>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(type, 0));
|
||||
}
|
||||
@@ -1445,7 +1445,8 @@ ast::type::Type* ParserImpl::GetSignedIntMatchingShape(ast::type::Type* other) {
|
||||
Fail() << "no type provided";
|
||||
}
|
||||
auto* i32 = ast_module_.create<ast::type::I32Type>();
|
||||
if (other->Is<ast::type::F32Type>() || other->IsU32() || other->IsI32()) {
|
||||
if (other->Is<ast::type::F32Type>() || other->IsU32() ||
|
||||
other->Is<ast::type::I32Type>()) {
|
||||
return i32;
|
||||
}
|
||||
auto* vec_ty = other->AsVector();
|
||||
@@ -1463,7 +1464,8 @@ ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape(
|
||||
return nullptr;
|
||||
}
|
||||
auto* u32 = ast_module_.create<ast::type::U32Type>();
|
||||
if (other->Is<ast::type::F32Type>() || other->IsU32() || other->IsI32()) {
|
||||
if (other->Is<ast::type::F32Type>() || other->IsU32() ||
|
||||
other->Is<ast::type::I32Type>()) {
|
||||
return u32;
|
||||
}
|
||||
auto* vec_ty = other->AsVector();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#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/i32_type.h"
|
||||
#include "src/ast/type/matrix_type.h"
|
||||
#include "src/ast/type/pointer_type.h"
|
||||
#include "src/ast/type/struct_type.h"
|
||||
@@ -107,7 +108,7 @@ TEST_F(SpvParserTest, ConvertType_I32) {
|
||||
EXPECT_TRUE(p->BuildInternalModule());
|
||||
|
||||
auto* type = p->ConvertType(2);
|
||||
EXPECT_TRUE(type->IsI32());
|
||||
EXPECT_TRUE(type->Is<ast::type::I32Type>());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
}
|
||||
|
||||
@@ -197,17 +198,17 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) {
|
||||
|
||||
auto* v2xi32 = p->ConvertType(20);
|
||||
EXPECT_TRUE(v2xi32->IsVector());
|
||||
EXPECT_TRUE(v2xi32->AsVector()->type()->IsI32());
|
||||
EXPECT_TRUE(v2xi32->AsVector()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(v2xi32->AsVector()->size(), 2u);
|
||||
|
||||
auto* v3xi32 = p->ConvertType(30);
|
||||
EXPECT_TRUE(v3xi32->IsVector());
|
||||
EXPECT_TRUE(v3xi32->AsVector()->type()->IsI32());
|
||||
EXPECT_TRUE(v3xi32->AsVector()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(v3xi32->AsVector()->size(), 3u);
|
||||
|
||||
auto* v4xi32 = p->ConvertType(40);
|
||||
EXPECT_TRUE(v4xi32->IsVector());
|
||||
EXPECT_TRUE(v4xi32->AsVector()->type()->IsI32());
|
||||
EXPECT_TRUE(v4xi32->AsVector()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(v4xi32->AsVector()->size(), 4u);
|
||||
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "src/ast/type/f32_type.h"
|
||||
#include "src/ast/type/i32_type.h"
|
||||
#include "src/ast/type/multisampled_texture_type.h"
|
||||
#include "src/ast/type/sampled_texture_type.h"
|
||||
#include "src/ast/type/sampler_type.h"
|
||||
@@ -90,7 +91,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) {
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->IsI32());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
@@ -170,7 +171,7 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) {
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsSampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->IsI32());
|
||||
ASSERT_TRUE(t->AsTexture()->AsSampled()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
@@ -236,7 +237,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) {
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->IsTexture());
|
||||
ASSERT_TRUE(t->AsTexture()->IsMultisampled());
|
||||
ASSERT_TRUE(t->AsTexture()->AsMultisampled()->type()->IsI32());
|
||||
ASSERT_TRUE(
|
||||
t->AsTexture()->AsMultisampled()->type()->Is<ast::type::I32Type>());
|
||||
EXPECT_EQ(t->AsTexture()->dim(), ast::type::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
||||
ASSERT_NE(t.value, nullptr);
|
||||
ASSERT_TRUE(t->Is<ast::type::AliasType>());
|
||||
auto* alias = t->As<ast::type::AliasType>();
|
||||
ASSERT_TRUE(alias->type()->IsI32());
|
||||
ASSERT_TRUE(alias->type()->Is<ast::type::I32Type>());
|
||||
ASSERT_EQ(alias->type(), i32);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ TEST_F(ParserImplTest, TypeDecl_I32) {
|
||||
EXPECT_FALSE(t.errored);
|
||||
ASSERT_NE(t.value, nullptr) << p->error();
|
||||
EXPECT_EQ(t.value, int_type);
|
||||
ASSERT_TRUE(t->IsI32());
|
||||
ASSERT_TRUE(t->Is<ast::type::I32Type>());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, TypeDecl_U32) {
|
||||
|
||||
Reference in New Issue
Block a user