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:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent af37c4ae83
commit f3639b787f
29 changed files with 61 additions and 66 deletions

View File

@@ -3597,7 +3597,7 @@ TypedExpression FunctionEmitter::MakeSimpleSelect(
// a VariablePointers* capability, which is not allowed in by WebGPU.
auto* op_ty = operand1.type;
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;
params.push_back(operand1.expr);
params.push_back(operand2.expr);

View File

@@ -1277,7 +1277,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
create<ast::ScalarConstructorExpression>(
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()
? false
: spirv_const->AsBoolConstant()->value();
@@ -1334,7 +1334,7 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
auto* original_type = type;
type = type->UnwrapIfNeeded();
if (type->IsBool()) {
if (type->Is<ast::type::BoolType>()) {
return create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(type, false));
}

View File

@@ -19,6 +19,7 @@
#include "gmock/gmock.h"
#include "src/ast/struct.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/pointer_type.h"
#include "src/ast/type/struct_type.h"
@@ -96,7 +97,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) {
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(100);
EXPECT_TRUE(type->IsBool());
EXPECT_TRUE(type->Is<ast::type::BoolType>());
EXPECT_TRUE(p->error().empty());
}

View File

@@ -87,7 +87,7 @@ TEST_F(ParserImplTest, TypeDecl_Bool) {
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
EXPECT_EQ(t.value, bool_type);
ASSERT_TRUE(t->IsBool());
ASSERT_TRUE(t->Is<ast::type::BoolType>());
}
TEST_F(ParserImplTest, TypeDecl_F32) {