Add Castsable::IsAnyOf<T1, T2, ...>()

This makes it a little easier to check if an object is one of any of the
types provided. Updated Type query functions to make use of IsAnyOf.
Added tests.

Change-Id: I12ea62b32042b6675d998ab85b86f2fe15861330
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44462
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Antonio Maiorano
2021-03-15 17:29:03 +00:00
committed by Commit Bot service account
parent 81a4753c38
commit a089a56c73
3 changed files with 75 additions and 3 deletions

View File

@@ -71,7 +71,7 @@ Type* Type::UnwrapAll() {
}
bool Type::is_scalar() const {
return is_float_scalar() || is_integer_scalar() || Is<Bool>();
return IsAnyOf<F32, U32, I32, Bool>();
}
bool Type::is_float_scalar() const {
@@ -91,7 +91,7 @@ bool Type::is_float_scalar_or_vector() const {
}
bool Type::is_integer_scalar() const {
return Is<U32>() || Is<I32>();
return IsAnyOf<U32, I32>();
}
bool Type::is_unsigned_integer_vector() const {
@@ -123,7 +123,7 @@ bool Type::is_bool_scalar_or_vector() const {
}
bool Type::is_handle() const {
return Is<type::Sampler>() || Is<type::Texture>();
return IsAnyOf<Sampler, Texture>();
}
} // namespace type