mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 05:27:49 +00:00
Rename all type UnwrapXXX() methods
Give them sensible names. Make them act consistently. Remove those that were not used. Change-Id: Ib043a4093cfae9f81630643e1a0e4eae7bca2440 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50305 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
fcda15ef67
commit
f14e0e1c8c
@@ -22,9 +22,7 @@ namespace sem {
|
||||
Expression::Expression(ast::Expression* declaration,
|
||||
const sem::Type* type,
|
||||
Statement* statement)
|
||||
: declaration_(declaration),
|
||||
type_(type->UnwrapIfNeeded()),
|
||||
statement_(statement) {
|
||||
: declaration_(declaration), type_(type), statement_(statement) {
|
||||
TINT_ASSERT(type_);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ Function::VariableBindings Function::ReferencedStorageTextureVariables() const {
|
||||
VariableBindings ret;
|
||||
|
||||
for (auto* var : ReferencedModuleVariables()) {
|
||||
auto* unwrapped_type = var->Type()->UnwrapIfNeeded();
|
||||
auto* unwrapped_type = var->Type()->UnwrapAccess();
|
||||
auto* storage_texture = unwrapped_type->As<sem::StorageTexture>();
|
||||
if (storage_texture == nullptr) {
|
||||
continue;
|
||||
@@ -155,7 +155,7 @@ Function::VariableBindings Function::ReferencedDepthTextureVariables() const {
|
||||
VariableBindings ret;
|
||||
|
||||
for (auto* var : ReferencedModuleVariables()) {
|
||||
auto* unwrapped_type = var->Type()->UnwrapIfNeeded();
|
||||
auto* unwrapped_type = var->Type()->UnwrapAccess();
|
||||
auto* storage_texture = unwrapped_type->As<sem::DepthTexture>();
|
||||
if (storage_texture == nullptr) {
|
||||
continue;
|
||||
@@ -182,7 +182,7 @@ Function::VariableBindings Function::ReferencedSamplerVariablesImpl(
|
||||
VariableBindings ret;
|
||||
|
||||
for (auto* var : ReferencedModuleVariables()) {
|
||||
auto* unwrapped_type = var->Type()->UnwrapIfNeeded();
|
||||
auto* unwrapped_type = var->Type()->UnwrapAccess();
|
||||
auto* sampler = unwrapped_type->As<sem::Sampler>();
|
||||
if (sampler == nullptr || sampler->kind() != kind) {
|
||||
continue;
|
||||
@@ -200,7 +200,7 @@ Function::VariableBindings Function::ReferencedSampledTextureVariablesImpl(
|
||||
VariableBindings ret;
|
||||
|
||||
for (auto* var : ReferencedModuleVariables()) {
|
||||
auto* unwrapped_type = var->Type()->UnwrapIfNeeded();
|
||||
auto* unwrapped_type = var->Type()->UnwrapAccess();
|
||||
auto* texture = unwrapped_type->As<sem::Texture>();
|
||||
if (texture == nullptr) {
|
||||
continue;
|
||||
|
||||
@@ -36,7 +36,7 @@ Type::Type(Type&&) = default;
|
||||
|
||||
Type::~Type() = default;
|
||||
|
||||
const Type* Type::UnwrapPtrIfNeeded() const {
|
||||
const Type* Type::UnwrapPtr() const {
|
||||
auto* type = this;
|
||||
while (auto* ptr = type->As<sem::Pointer>()) {
|
||||
type = ptr->type();
|
||||
@@ -44,7 +44,7 @@ const Type* Type::UnwrapPtrIfNeeded() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
const Type* Type::UnwrapIfNeeded() const {
|
||||
const Type* Type::UnwrapAccess() const {
|
||||
auto* type = this;
|
||||
while (auto* access = type->As<sem::AccessControl>()) {
|
||||
type = access->type();
|
||||
@@ -57,14 +57,13 @@ const Type* Type::UnwrapAll() const {
|
||||
while (true) {
|
||||
if (auto* ptr = type->As<sem::Pointer>()) {
|
||||
type = ptr->type();
|
||||
continue;
|
||||
}
|
||||
if (auto* access = type->As<sem::AccessControl>()) {
|
||||
} else if (auto* access = type->As<sem::AccessControl>()) {
|
||||
type = access->type();
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
bool Type::is_scalar() const {
|
||||
|
||||
@@ -45,19 +45,16 @@ class Type : public Castable<Type, Node> {
|
||||
/// declared in WGSL.
|
||||
virtual std::string FriendlyName(const SymbolTable& symbols) const = 0;
|
||||
|
||||
/// @returns the pointee type if this is a pointer, `this` otherwise
|
||||
const Type* UnwrapPtrIfNeeded() const;
|
||||
/// @returns the inner most pointee type if this is a pointer, `this`
|
||||
/// otherwise
|
||||
const Type* UnwrapPtr() const;
|
||||
|
||||
/// Removes all levels of access control.
|
||||
/// This is just enough to assist with WGSL translation
|
||||
/// in that you want see through one level of pointer to get from an
|
||||
/// identifier-like expression as an l-value to its corresponding r-value,
|
||||
/// plus see through the wrappers on either side.
|
||||
/// @returns the completely unaliased type.
|
||||
const Type* UnwrapIfNeeded() const;
|
||||
/// @returns the inner most type if this is an access control, `this`
|
||||
/// otherwise
|
||||
const Type* UnwrapAccess() const;
|
||||
|
||||
/// Returns the type found after removing all layers of access control and
|
||||
/// pointer.
|
||||
/// pointer
|
||||
/// @returns the unwrapped type
|
||||
const Type* UnwrapAll() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user