Validator: remove IsStorable and tests
This function, along with unit tests, already exist on Resolver. Bug: tint:642 Change-Id: I35fe7ee6dc52a6f58ad6145bd15b071795ac069d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46680 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
61dabab673
commit
1fe1a5e641
|
@ -269,29 +269,4 @@ bool ValidatorImpl::ValidateCase(const ast::CaseStatement* c) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ValidatorImpl::IsStorable(type::Type* type) {
|
||||
if (type == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (type->is_scalar() || type->Is<type::Vector>() ||
|
||||
type->Is<type::Matrix>()) {
|
||||
return true;
|
||||
}
|
||||
if (type::Array* array_type = type->As<type::Array>()) {
|
||||
return IsStorable(array_type->type());
|
||||
}
|
||||
if (type::Struct* struct_type = type->As<type::Struct>()) {
|
||||
for (const auto* member : struct_type->impl()->members()) {
|
||||
if (!IsStorable(member->type())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (type::Alias* alias_type = type->As<type::Alias>()) {
|
||||
return IsStorable(alias_type->type());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace tint
|
||||
|
|
|
@ -101,11 +101,6 @@ class ValidatorImpl {
|
|||
/// @param funcs the functions to check
|
||||
/// @returns true if the valdiation was successful
|
||||
bool ValidateEntryPoint(const ast::FunctionList& funcs);
|
||||
/// Returns true if the given type is storable. This uses and
|
||||
/// updates `storable_` and `not_storable_`.
|
||||
/// @param type the given type
|
||||
/// @returns true if the given type is storable.
|
||||
bool IsStorable(type::Type* type);
|
||||
|
||||
/// Testing method to inserting a given variable into the current scope.
|
||||
/// @param var the variable to register
|
||||
|
|
|
@ -327,125 +327,5 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
|||
EXPECT_TRUE(v.ValidateStatements(body)) << v.error();
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Void) {
|
||||
auto* void_ty = ty.void_();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.IsStorable(void_ty));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Scalar) {
|
||||
auto* bool_ = ty.bool_();
|
||||
auto* i32 = ty.i32();
|
||||
auto* u32 = ty.u32();
|
||||
auto* f32 = ty.f32();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(bool_));
|
||||
EXPECT_TRUE(v.IsStorable(i32));
|
||||
EXPECT_TRUE(v.IsStorable(u32));
|
||||
EXPECT_TRUE(v.IsStorable(f32));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Vector) {
|
||||
auto* vec2_i32 = ty.vec2<int>();
|
||||
auto* vec3_i32 = ty.vec3<int>();
|
||||
auto* vec4_i32 = ty.vec4<int>();
|
||||
auto* vec2_u32 = ty.vec2<unsigned>();
|
||||
auto* vec3_u32 = ty.vec3<unsigned>();
|
||||
auto* vec4_u32 = ty.vec4<unsigned>();
|
||||
auto* vec2_f32 = ty.vec2<float>();
|
||||
auto* vec3_f32 = ty.vec3<float>();
|
||||
auto* vec4_f32 = ty.vec4<float>();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(vec2_i32));
|
||||
EXPECT_TRUE(v.IsStorable(vec3_i32));
|
||||
EXPECT_TRUE(v.IsStorable(vec4_i32));
|
||||
EXPECT_TRUE(v.IsStorable(vec2_u32));
|
||||
EXPECT_TRUE(v.IsStorable(vec3_u32));
|
||||
EXPECT_TRUE(v.IsStorable(vec4_u32));
|
||||
EXPECT_TRUE(v.IsStorable(vec2_f32));
|
||||
EXPECT_TRUE(v.IsStorable(vec3_f32));
|
||||
EXPECT_TRUE(v.IsStorable(vec4_f32));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Matrix) {
|
||||
auto* mat2x2 = ty.mat2x2<float>();
|
||||
auto* mat2x3 = ty.mat2x3<float>();
|
||||
auto* mat2x4 = ty.mat2x4<float>();
|
||||
auto* mat3x2 = ty.mat3x2<float>();
|
||||
auto* mat3x3 = ty.mat3x3<float>();
|
||||
auto* mat3x4 = ty.mat3x4<float>();
|
||||
auto* mat4x2 = ty.mat4x2<float>();
|
||||
auto* mat4x3 = ty.mat4x3<float>();
|
||||
auto* mat4x4 = ty.mat4x4<float>();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(mat2x2));
|
||||
EXPECT_TRUE(v.IsStorable(mat2x3));
|
||||
EXPECT_TRUE(v.IsStorable(mat2x4));
|
||||
EXPECT_TRUE(v.IsStorable(mat3x2));
|
||||
EXPECT_TRUE(v.IsStorable(mat3x3));
|
||||
EXPECT_TRUE(v.IsStorable(mat3x4));
|
||||
EXPECT_TRUE(v.IsStorable(mat4x2));
|
||||
EXPECT_TRUE(v.IsStorable(mat4x3));
|
||||
EXPECT_TRUE(v.IsStorable(mat4x4));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Pointer) {
|
||||
auto* ptr_ty = ty.pointer<int>(ast::StorageClass::kPrivate);
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.IsStorable(ptr_ty));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_AliasVoid) {
|
||||
auto* alias = ty.alias("myalias", ty.void_());
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.IsStorable(alias));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_AliasI32) {
|
||||
auto* alias = ty.alias("myalias", ty.i32());
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(alias));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_ArraySizedOfStorable) {
|
||||
auto* arr = ty.array(ty.i32(), 5);
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(arr));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_ArrayUnsizedOfStorable) {
|
||||
auto* arr = ty.array<int>();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(arr));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Struct_AllMembersStorable) {
|
||||
ast::StructMemberList members{Member("a", ty.i32()), Member("b", ty.f32())};
|
||||
auto* s = create<ast::Struct>(Source{}, members, ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("mystruct", s);
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(s_ty));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint
|
||||
|
|
Loading…
Reference in New Issue