Replace Type::(Is|As)Void with Castable

Change-Id: If8a27c69c91a968a40a982c02b9fcaf9481e60b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34275
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 8a083ce9c8
commit 16ec1bb626
13 changed files with 26 additions and 52 deletions

View File

@@ -66,10 +66,6 @@ Type* Type::UnwrapAll() {
return UnwrapIfNeeded()->UnwrapPtrIfNeeded()->UnwrapIfNeeded();
}
bool Type::IsVoid() const {
return false;
}
uint64_t Type::MinBufferBindingSize(MemoryLayout) const {
return 0;
}
@@ -124,16 +120,6 @@ bool Type::is_integer_scalar_or_vector() {
return is_unsigned_scalar_or_vector() || is_signed_scalar_or_vector();
}
const VoidType* Type::AsVoid() const {
assert(IsVoid());
return static_cast<const VoidType*>(this);
}
VoidType* Type::AsVoid() {
assert(IsVoid());
return static_cast<VoidType*>(this);
}
} // namespace type
} // namespace ast
} // namespace tint

View File

@@ -23,8 +23,6 @@ namespace tint {
namespace ast {
namespace type {
class VoidType;
/// Supported memory layouts for calculating sizes
enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
@@ -35,9 +33,6 @@ class Type : public Castable<Type> {
Type(Type&&);
~Type() override;
/// @returns true if the type is a void type
virtual bool IsVoid() const;
/// @returns the name for this type. The |type_name| is unique over all types.
virtual std::string type_name() const = 0;
@@ -92,12 +87,6 @@ class Type : public Castable<Type> {
/// @returns true if this type is an integer scalar or vector
bool is_integer_scalar_or_vector();
/// @returns the type as a void type
const VoidType* AsVoid() const;
/// @returns the type as a void type
VoidType* AsVoid();
protected:
Type();
};

View File

@@ -24,10 +24,6 @@ VoidType::VoidType(VoidType&&) = default;
VoidType::~VoidType() = default;
bool VoidType::IsVoid() const {
return true;
}
std::string VoidType::type_name() const {
return "__void";
}

View File

@@ -32,9 +32,6 @@ class VoidType : public Castable<VoidType, Type> {
VoidType(VoidType&&);
~VoidType() override;
/// @returns true if the type is a void type
bool IsVoid() const override;
/// @returns the name for this type
std::string type_name() const override;
};