Rename type::Array to type::ArrayType
This is to avoid name conflicts once we move all classes from namespace
`type` to `sem`.
Bug: tint:724
Change-Id: Icc3d81ae62eb3b329ce28e78a23ea27f29c9263b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48360
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index a11a446..f532847 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -82,7 +82,7 @@
return ResourceBinding::SampledKind::kUnknown;
}
- if (auto* at = base_type->As<type::Array>()) {
+ if (auto* at = base_type->As<type::ArrayType>()) {
base_type = at->type();
} else if (auto* mt = base_type->As<type::Matrix>()) {
base_type = mt->type();
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index 826c3b6..62616b7 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -645,13 +645,13 @@
return *inspector_;
}
- type::Array* u32_array_type(uint32_t count) {
+ type::ArrayType* u32_array_type(uint32_t count) {
if (array_type_memo_.find(count) == array_type_memo_.end()) {
array_type_memo_[count] =
- create<type::Array>(ty.u32(), count,
- ast::DecorationList{
- create<ast::StrideDecoration>(4),
- });
+ create<type::ArrayType>(ty.u32(), count,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(4),
+ });
}
return array_type_memo_[count];
}
@@ -671,7 +671,7 @@
std::unique_ptr<Inspector> inspector_;
type::Sampler sampler_type_;
type::Sampler comparison_sampler_type_;
- std::map<uint32_t, type::Array*> array_type_memo_;
+ std::map<uint32_t, type::ArrayType*> array_type_memo_;
std::map<std::tuple<type::Type*, uint32_t>, type::Vector*> vector_type_memo_;
};
diff --git a/src/intrinsic_table.cc b/src/intrinsic_table.cc
index 39df6a5..4bcd8c7 100644
--- a/src/intrinsic_table.cc
+++ b/src/intrinsic_table.cc
@@ -404,7 +404,7 @@
: element_builder_(element_builder) {}
bool MatchUnwrapped(MatchState& state, type::Type* ty) const override {
- if (auto* arr = ty->As<type::Array>()) {
+ if (auto* arr = ty->As<type::ArrayType>()) {
if (arr->size() == 0) {
return element_builder_->Match(state, arr->type());
}
@@ -414,7 +414,7 @@
type::Type* Build(BuildState& state) const override {
auto* el = element_builder_->Build(state);
- return state.ty_mgr.Get<type::Array>(el, 0, ast::DecorationList{});
+ return state.ty_mgr.Get<type::ArrayType>(el, 0, ast::DecorationList{});
}
std::string str() const override {
diff --git a/src/program_builder.h b/src/program_builder.h
index 8e3802c..a930fd5 100644
--- a/src/program_builder.h
+++ b/src/program_builder.h
@@ -490,16 +490,19 @@
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array.
/// @return the tint AST type for a array of size `n` of type `T`
- type::Array* array(type::Type* subtype, uint32_t n = 0) const {
- return builder->create<type::Array>(subtype, n, ast::DecorationList{});
+ type::ArrayType* array(type::Type* subtype, uint32_t n = 0) const {
+ return builder->create<type::ArrayType>(subtype, n,
+ ast::DecorationList{});
}
/// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array.
/// @param stride the array stride.
/// @return the tint AST type for a array of size `n` of type `T`
- type::Array* array(type::Type* subtype, uint32_t n, uint32_t stride) const {
- return builder->create<type::Array>(
+ type::ArrayType* array(type::Type* subtype,
+ uint32_t n,
+ uint32_t stride) const {
+ return builder->create<type::ArrayType>(
subtype, n,
ast::DecorationList{
builder->create<ast::StrideDecoration>(stride),
@@ -508,14 +511,14 @@
/// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0>
- type::Array* array() const {
+ type::ArrayType* array() const {
return array(Of<T>(), N);
}
/// @param stride the array stride
/// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0>
- type::Array* array(uint32_t stride) const {
+ type::ArrayType* array(uint32_t stride) const {
return array(Of<T>(), N, stride);
}
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index fd3ada4..7fc36ee 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -762,7 +762,7 @@
if (!ParseArrayDecorations(rtarr_ty, &decorations)) {
return nullptr;
}
- return create<type::Array>(ast_elem_ty, 0, std::move(decorations));
+ return create<type::ArrayType>(ast_elem_ty, 0, std::move(decorations));
}
type::Type* ParserImpl::ConvertType(
@@ -807,8 +807,8 @@
if (remap_buffer_block_type_.count(elem_type_id)) {
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
}
- return create<type::Array>(ast_elem_ty, static_cast<uint32_t>(num_elem),
- std::move(decorations));
+ return create<type::ArrayType>(ast_elem_ty, static_cast<uint32_t>(num_elem),
+ std::move(decorations));
}
bool ParserImpl::ParseArrayDecorations(
@@ -1493,7 +1493,7 @@
return create<ast::TypeConstructorExpression>(Source{}, type,
std::move(ast_components));
}
- if (auto* arr_ty = type->As<type::Array>()) {
+ if (auto* arr_ty = type->As<type::ArrayType>()) {
ast::ExpressionList ast_components;
for (size_t i = 0; i < arr_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc
index ab21b4d..b1ccd14 100644
--- a/src/reader/spirv/parser_impl_convert_type_test.cc
+++ b/src/reader/spirv/parser_impl_convert_type_test.cc
@@ -326,8 +326,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::Array>());
- auto* arr_type = type->As<type::Array>();
+ EXPECT_TRUE(type->Is<type::ArrayType>());
+ auto* arr_type = type->As<type::ArrayType>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 0u);
@@ -361,7 +361,7 @@
EXPECT_TRUE(p->BuildInternalModule());
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- auto* arr_type = type->As<type::Array>();
+ auto* arr_type = type->As<type::ArrayType>();
EXPECT_TRUE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
ASSERT_EQ(arr_type->decorations().size(), 1u);
@@ -409,8 +409,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::Array>());
- auto* arr_type = type->As<type::Array>();
+ EXPECT_TRUE(type->Is<type::ArrayType>());
+ auto* arr_type = type->As<type::ArrayType>();
EXPECT_FALSE(arr_type->IsRuntimeArray());
ASSERT_NE(arr_type, nullptr);
EXPECT_EQ(arr_type->size(), 42u);
@@ -496,8 +496,8 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::Array>());
- auto* arr_type = type->As<type::Array>();
+ EXPECT_TRUE(type->Is<type::ArrayType>());
+ auto* arr_type = type->As<type::ArrayType>();
ASSERT_NE(arr_type, nullptr);
ASSERT_EQ(arr_type->decorations().size(), 1u);
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 794cad8..f7ee20f 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -1052,7 +1052,7 @@
size = val.value;
}
- return create<type::Array>(subtype.value, size, std::move(decos));
+ return create<type::ArrayType>(subtype.value, size, std::move(decos));
});
}
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc
index afef34e..1bbb9bd 100644
--- a/src/reader/wgsl/parser_impl_global_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -191,8 +191,8 @@
EXPECT_FALSE(str->IsBlockDecorated());
const auto* ty = str->impl()->members()[0]->type();
- ASSERT_TRUE(ty->Is<type::Array>());
- const auto* arr = ty->As<type::Array>();
+ ASSERT_TRUE(ty->Is<type::ArrayType>());
+ const auto* arr = ty->As<type::ArrayType>();
ASSERT_EQ(arr->decorations().size(), 1u);
auto* stride = arr->decorations()[0];
diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc
index 995c411..66fc791 100644
--- a/src/reader/wgsl/parser_impl_type_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_type_decl_test.cc
@@ -338,9 +338,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Array>());
+ ASSERT_TRUE(t->Is<type::ArrayType>());
- auto* a = t->As<type::Array>();
+ auto* a = t->As<type::ArrayType>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
ASSERT_TRUE(a->type()->Is<type::F32>());
@@ -354,9 +354,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Array>());
+ ASSERT_TRUE(t->Is<type::ArrayType>());
- auto* a = t->As<type::Array>();
+ auto* a = t->As<type::ArrayType>();
ASSERT_FALSE(a->IsRuntimeArray());
ASSERT_EQ(a->size(), 5u);
ASSERT_TRUE(a->type()->Is<type::F32>());
@@ -374,9 +374,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Array>());
+ ASSERT_TRUE(t->Is<type::ArrayType>());
- auto* a = t->As<type::Array>();
+ auto* a = t->As<type::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<type::F32>());
@@ -393,9 +393,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Array>());
+ ASSERT_TRUE(t->Is<type::ArrayType>());
- auto* a = t->As<type::Array>();
+ auto* a = t->As<type::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<type::F32>());
@@ -414,9 +414,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Array>());
+ ASSERT_TRUE(t->Is<type::ArrayType>());
- auto* a = t->As<type::Array>();
+ auto* a = t->As<type::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<type::F32>());
@@ -517,9 +517,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Array>());
+ ASSERT_TRUE(t->Is<type::ArrayType>());
- auto* a = t->As<type::Array>();
+ auto* a = t->As<type::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->Is<type::U32>());
}
@@ -531,9 +531,9 @@
EXPECT_FALSE(t.errored);
ASSERT_NE(t.value, nullptr) << p->error();
ASSERT_FALSE(p->has_error());
- ASSERT_TRUE(t->Is<type::Array>());
+ ASSERT_TRUE(t->Is<type::ArrayType>());
- auto* a = t->As<type::Array>();
+ auto* a = t->As<type::ArrayType>();
ASSERT_TRUE(a->IsRuntimeArray());
ASSERT_TRUE(a->type()->is_unsigned_integer_vector());
}
diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc
index ea372e5..cb3455e 100644
--- a/src/resolver/decoration_validation_test.cc
+++ b/src/resolver/decoration_validation_test.cc
@@ -127,9 +127,10 @@
auto& params = GetParam();
ast::StructMemberList members{Member(
- "a", create<type::Array>(ty.f32(), 0,
- ast::DecorationList{createDecoration(
- Source{{12, 34}}, *this, params.kind)}))};
+ "a",
+ create<type::ArrayType>(ty.f32(), 0,
+ ast::DecorationList{createDecoration(
+ Source{{12, 34}}, *this, params.kind)}))};
auto* s = create<ast::Struct>(
members, ast::DecorationList{create<ast::StructBlockDecoration>()});
auto* s_ty = ty.struct_("mystruct", s);
@@ -333,10 +334,10 @@
SCOPED_TRACE(ss.str());
auto* arr =
- create<type::Array>(el_ty, 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(params.stride),
- });
+ create<type::ArrayType>(el_ty, 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(params.stride),
+ });
Global(Source{{12, 34}}, "myarray", arr, ast::StorageClass::kInput);
@@ -421,11 +422,11 @@
Params{ty_mat4x4<f32>, (default_mat4x4.align - 1) * 7, false}));
TEST_F(ArrayStrideTest, MultipleDecorations) {
- auto* arr = create<type::Array>(ty.i32(), 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(4),
- create<ast::StrideDecoration>(4),
- });
+ auto* arr = create<type::ArrayType>(ty.i32(), 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(4),
+ create<ast::StrideDecoration>(4),
+ });
Global(Source{{12, 34}}, "myarray", arr, ast::StorageClass::kInput);
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index 31f9dcc..ed826d7 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -123,7 +123,7 @@
type->Is<type::Matrix>()) {
return true;
}
- if (type::Array* arr = type->As<type::Array>()) {
+ if (type::ArrayType* arr = type->As<type::ArrayType>()) {
return IsStorable(arr->type());
}
if (type::Struct* str = type->As<type::Struct>()) {
@@ -149,7 +149,7 @@
if (auto* mat = type->As<type::Matrix>()) {
return IsHostShareable(mat->type());
}
- if (auto* arr = type->As<type::Array>()) {
+ if (auto* arr = type->As<type::ArrayType>()) {
return IsHostShareable(arr->type());
}
if (auto* str = type->As<type::Struct>()) {
@@ -228,7 +228,7 @@
if (!Structure(str)) {
return false;
}
- } else if (auto* arr = ty->As<type::Array>()) {
+ } else if (auto* arr = ty->As<type::ArrayType>()) {
if (!Array(arr, Source{})) {
return false;
}
@@ -248,7 +248,7 @@
variable_to_info_.emplace(var, info);
// Resolve variable's type
- if (auto* arr = info->type->As<type::Array>()) {
+ if (auto* arr = info->type->As<type::ArrayType>()) {
if (!Array(arr, var->source())) {
return nullptr;
}
@@ -358,7 +358,7 @@
bool Resolver::ValidateVariable(const ast::Variable* var) {
auto* type = variable_to_info_[var]->type;
- if (auto* r = type->UnwrapAll()->As<type::Array>()) {
+ if (auto* r = type->UnwrapAll()->As<type::ArrayType>()) {
if (r->IsRuntimeArray()) {
diagnostics_.add_error(
"v-0015",
@@ -568,7 +568,7 @@
builder_->Symbols().NameFor(func->symbol()),
func->source());
return false;
- } else if (auto* arr = member_ty->As<type::Array>()) {
+ } else if (auto* arr = member_ty->As<type::ArrayType>()) {
if (arr->IsRuntimeArray()) {
diagnostics_.add_error(
"entry point IO types cannot contain runtime sized arrays",
@@ -946,7 +946,7 @@
auto* res = TypeOf(expr->array());
auto* parent_type = res->UnwrapAll();
type::Type* ret = nullptr;
- if (auto* arr = parent_type->As<type::Array>()) {
+ if (auto* arr = parent_type->As<type::ArrayType>()) {
ret = arr->type();
} else if (auto* vec = parent_type->As<type::Vector>()) {
ret = vec->type();
@@ -962,7 +962,7 @@
// If we're extracting from a pointer, we return a pointer.
if (auto* ptr = res->As<type::Pointer>()) {
ret = builder_->create<type::Pointer>(ret, ptr->storage_class());
- } else if (auto* arr = parent_type->As<type::Array>()) {
+ } else if (auto* arr = parent_type->As<type::ArrayType>()) {
if (!arr->type()->is_scalar()) {
// If we extract a non-scalar from an array then we also get a pointer. We
// will generate a Function storage class variable to store this into.
@@ -1916,9 +1916,9 @@
return true;
}
return false;
- } else if (cty->Is<type::Array>()) {
+ } else if (cty->Is<type::ArrayType>()) {
if (auto* sem =
- Array(ty->UnwrapAliasIfNeeded()->As<type::Array>(), source)) {
+ Array(ty->UnwrapAliasIfNeeded()->As<type::ArrayType>(), source)) {
align = sem->Align();
size = sem->Size();
return true;
@@ -1929,7 +1929,7 @@
return false;
}
-const sem::Array* Resolver::Array(type::Array* arr, const Source& source) {
+const sem::Array* Resolver::Array(type::ArrayType* arr, const Source& source) {
if (auto* sem = builder_->Sem().Get(arr)) {
// Semantic info already constructed for this array type
return sem;
@@ -2000,7 +2000,7 @@
bool Resolver::ValidateStructure(const type::Struct* st) {
for (auto* member : st->impl()->members()) {
- if (auto* r = member->type()->UnwrapAll()->As<type::Array>()) {
+ if (auto* r = member->type()->UnwrapAll()->As<type::ArrayType>()) {
if (r->IsRuntimeArray()) {
if (member != st->impl()->members().back()) {
diagnostics_.add_error(
@@ -2391,7 +2391,7 @@
return true;
}
- if (auto* arr = ty->As<type::Array>()) {
+ if (auto* arr = ty->As<type::ArrayType>()) {
return ApplyStorageClassUsageToType(sc, arr->type(), usage);
}
diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h
index 321d0aa..067941e 100644
--- a/src/resolver/resolver.h
+++ b/src/resolver/resolver.h
@@ -256,7 +256,7 @@
/// returned.
/// @param arr the Array to get semantic information for
/// @param source the Source of the ast node with this array as its type
- const sem::Array* Array(type::Array* arr, const Source& source);
+ const sem::Array* Array(type::ArrayType* arr, const Source& source);
/// @returns the StructInfo for the structure `str`, building it if it hasn't
/// been constructed already. If an error is raised, nullptr is returned.
diff --git a/src/sem/array.cc b/src/sem/array.cc
index 7dc6aa9..2126a53 100644
--- a/src/sem/array.cc
+++ b/src/sem/array.cc
@@ -19,7 +19,10 @@
namespace tint {
namespace sem {
-Array::Array(type::Array* type, uint32_t align, uint32_t size, uint32_t stride)
+Array::Array(type::ArrayType* type,
+ uint32_t align,
+ uint32_t size,
+ uint32_t stride)
: type_(type), align_(align), size_(size), stride_(stride) {}
} // namespace sem
diff --git a/src/sem/array.h b/src/sem/array.h
index e2c98d6..c9861c6 100644
--- a/src/sem/array.h
+++ b/src/sem/array.h
@@ -23,7 +23,7 @@
// Forward declarations
namespace type {
-class Array;
+class ArrayType;
} // namespace type
namespace sem {
@@ -37,10 +37,10 @@
/// @param size the byte size of the structure
/// @param stride the number of bytes from the start of one element of the
/// array to the start of the next element
- Array(type::Array* type, uint32_t align, uint32_t size, uint32_t stride);
+ Array(type::ArrayType* type, uint32_t align, uint32_t size, uint32_t stride);
/// @return the resolved type of the Array
- type::Array* Type() const { return type_; }
+ type::ArrayType* Type() const { return type_; }
/// @returns the byte alignment of the array
/// @note this may differ from the alignment of a structure member of this
@@ -57,7 +57,7 @@
uint32_t Stride() const { return stride_; }
private:
- type::Array* const type_;
+ type::ArrayType* const type_;
uint32_t const align_;
uint32_t const size_;
uint32_t const stride_;
diff --git a/src/sem/type_mappings.h b/src/sem/type_mappings.h
index 2787bbe..b92bc4c 100644
--- a/src/sem/type_mappings.h
+++ b/src/sem/type_mappings.h
@@ -30,7 +30,7 @@
class Variable;
} // namespace ast
namespace type {
-class Array;
+class ArrayType;
class Struct;
} // namespace type
@@ -53,7 +53,7 @@
/// rules will be used to infer the return type based on the argument type.
struct TypeMappings {
//! @cond Doxygen_Suppress
- Array* operator()(type::Array*);
+ Array* operator()(type::ArrayType*);
Call* operator()(ast::CallExpression*);
Expression* operator()(ast::Expression*);
Function* operator()(ast::Function*);
diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc
index 55485a4..c08495e 100644
--- a/src/transform/bound_array_accessors.cc
+++ b/src/transform/bound_array_accessors.cc
@@ -42,7 +42,7 @@
auto& diags = ctx->dst->Diagnostics();
auto* ret_type = ctx->src->Sem().Get(expr->array())->Type()->UnwrapAll();
- if (!ret_type->Is<type::Array>() && !ret_type->Is<type::Matrix>() &&
+ if (!ret_type->Is<type::ArrayType>() && !ret_type->Is<type::Matrix>() &&
!ret_type->Is<type::Vector>()) {
return nullptr;
}
@@ -52,10 +52,10 @@
uint32_t size = 0;
bool is_vec = ret_type->Is<type::Vector>();
- bool is_arr = ret_type->Is<type::Array>();
+ bool is_arr = ret_type->Is<type::ArrayType>();
if (is_vec || is_arr) {
size = is_vec ? ret_type->As<type::Vector>()->size()
- : ret_type->As<type::Array>()->size();
+ : ret_type->As<type::ArrayType>()->size();
} else {
// The row accessor would have been an embedded array accessor and already
// handled, so we just need to do columns here.
diff --git a/src/transform/decompose_storage_access.cc b/src/transform/decompose_storage_access.cc
index fb77b55..002d32f 100644
--- a/src/transform/decompose_storage_access.cc
+++ b/src/transform/decompose_storage_access.cc
@@ -447,7 +447,7 @@
member->Declaration()->type()->UnwrapAll());
values.emplace_back(ctx.dst->Call(load, "buffer", offset));
}
- } else if (auto* arr_ty = el_ty->As<type::Array>()) {
+ } else if (auto* arr_ty = el_ty->As<type::ArrayType>()) {
auto& sem = ctx.src->Sem();
auto* arr = sem.Get(arr_ty);
for (uint32_t i = 0; i < arr_ty->size(); i++) {
@@ -518,7 +518,7 @@
auto* call = ctx.dst->Call(store, "buffer", offset, access);
body.emplace_back(ctx.dst->create<ast::CallStatement>(call));
}
- } else if (auto* arr_ty = el_ty->As<type::Array>()) {
+ } else if (auto* arr_ty = el_ty->As<type::ArrayType>()) {
auto& sem = ctx.src->Sem();
auto* arr = sem.Get(arr_ty);
for (uint32_t i = 0; i < arr_ty->size(); i++) {
@@ -678,7 +678,7 @@
if (auto* accessor = node->As<ast::ArrayAccessorExpression>()) {
if (auto access = state.TakeAccess(accessor->array())) {
// X[Y]
- if (auto* arr_ty = access.type->As<type::Array>()) {
+ if (auto* arr_ty = access.type->As<type::ArrayType>()) {
auto stride = sem.Get(arr_ty)->Stride();
auto offset = Mul(stride, accessor->idx_expr());
state.AddAccesss(accessor,
diff --git a/src/transform/hlsl.cc b/src/transform/hlsl.cc
index 83d309e..6fa55dc 100644
--- a/src/transform/hlsl.cc
+++ b/src/transform/hlsl.cc
@@ -96,7 +96,7 @@
}
auto* src_ty = src_sem_expr->Type();
- if (src_ty->IsAnyOf<type::Array, type::Struct>()) {
+ if (src_ty->IsAnyOf<type::ArrayType, type::Struct>()) {
// Create a new symbol for the constant
auto dst_symbol = ctx.dst->Symbols().New();
// Clone the type
diff --git a/src/type/access_control_type_test.cc b/src/type/access_control_type_test.cc
index e390400..2ce6856 100644
--- a/src/type/access_control_type_test.cc
+++ b/src/type/access_control_type_test.cc
@@ -37,7 +37,7 @@
Type* ty = &at;
EXPECT_TRUE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/alias_type_test.cc b/src/type/alias_type_test.cc
index cb7e51e..b9f5c2b 100644
--- a/src/type/alias_type_test.cc
+++ b/src/type/alias_type_test.cc
@@ -33,7 +33,7 @@
type::Type* ty = at;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_TRUE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/array_type.cc b/src/type/array_type.cc
index d84c36b..f7f7208 100644
--- a/src/type/array_type.cc
+++ b/src/type/array_type.cc
@@ -18,19 +18,21 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Array);
+TINT_INSTANTIATE_TYPEINFO(tint::type::ArrayType);
namespace tint {
namespace type {
-Array::Array(Type* subtype, uint32_t size, ast::DecorationList decorations)
+ArrayType::ArrayType(Type* subtype,
+ uint32_t size,
+ ast::DecorationList decorations)
: subtype_(subtype), size_(size), decos_(decorations) {}
-Array::Array(Array&&) = default;
+ArrayType::ArrayType(ArrayType&&) = default;
-Array::~Array() = default;
+ArrayType::~ArrayType() = default;
-std::string Array::type_name() const {
+std::string ArrayType::type_name() const {
TINT_ASSERT(subtype_);
std::string type_name = "__array" + subtype_->type_name();
@@ -46,7 +48,7 @@
return type_name;
}
-std::string Array::FriendlyName(const SymbolTable& symbols) const {
+std::string ArrayType::FriendlyName(const SymbolTable& symbols) const {
std::ostringstream out;
for (auto* deco : decos_) {
if (auto* stride = deco->As<ast::StrideDecoration>()) {
@@ -61,11 +63,11 @@
return out.str();
}
-Array* Array::Clone(CloneContext* ctx) const {
+ArrayType* ArrayType::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto* ty = ctx->Clone(type());
auto decos = ctx->Clone(decorations());
- return ctx->dst->create<Array>(ty, size_, decos);
+ return ctx->dst->create<ArrayType>(ty, size_, decos);
}
} // namespace type
diff --git a/src/type/array_type.h b/src/type/array_type.h
index 73456bc..2dc8228 100644
--- a/src/type/array_type.h
+++ b/src/type/array_type.h
@@ -24,17 +24,19 @@
namespace type {
/// An array type. If size is zero then it is a runtime array.
-class Array : public Castable<Array, Type> {
+// TODO(amaiorano): https://crbug.com/tint/724 Fold into sem::Array once parsers
+// don't create this anymore.
+class ArrayType : public Castable<ArrayType, Type> {
public:
/// Constructor
/// @param subtype the type of the array elements
/// @param size the number of elements in the array. `0` represents a
/// runtime-sized array.
/// @param decorations the array decorations
- Array(Type* subtype, uint32_t size, ast::DecorationList decorations);
+ ArrayType(Type* subtype, uint32_t size, ast::DecorationList decorations);
/// Move constructor
- Array(Array&&);
- ~Array() override;
+ ArrayType(ArrayType&&);
+ ~ArrayType() override;
/// @returns true if this is a runtime array.
/// i.e. the size is determined at runtime
@@ -59,7 +61,7 @@
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
- Array* Clone(CloneContext* ctx) const override;
+ ArrayType* Clone(CloneContext* ctx) const override;
private:
Type* const subtype_;
diff --git a/src/type/array_type_test.cc b/src/type/array_type_test.cc
index 062addd..8986d10 100644
--- a/src/type/array_type_test.cc
+++ b/src/type/array_type_test.cc
@@ -24,30 +24,30 @@
TEST_F(ArrayTest, CreateSizedArray) {
U32 u32;
- Array arr{&u32, 3, ast::DecorationList{}};
+ ArrayType arr{&u32, 3, ast::DecorationList{}};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 3u);
- EXPECT_TRUE(arr.Is<Array>());
+ EXPECT_TRUE(arr.Is<ArrayType>());
EXPECT_FALSE(arr.IsRuntimeArray());
}
TEST_F(ArrayTest, CreateRuntimeArray) {
U32 u32;
- Array arr{&u32, 0, ast::DecorationList{}};
+ ArrayType arr{&u32, 0, ast::DecorationList{}};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 0u);
- EXPECT_TRUE(arr.Is<Array>());
+ EXPECT_TRUE(arr.Is<ArrayType>());
EXPECT_TRUE(arr.IsRuntimeArray());
}
TEST_F(ArrayTest, Is) {
I32 i32;
- Array arr{&i32, 3, ast::DecorationList{}};
+ ArrayType arr{&i32, 3, ast::DecorationList{}};
Type* ty = &arr;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_TRUE(ty->Is<Array>());
+ EXPECT_TRUE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
@@ -62,35 +62,36 @@
TEST_F(ArrayTest, TypeName) {
I32 i32;
- Array arr{&i32, 0, ast::DecorationList{}};
+ ArrayType arr{&i32, 0, ast::DecorationList{}};
EXPECT_EQ(arr.type_name(), "__array__i32");
}
TEST_F(ArrayTest, FriendlyNameRuntimeSized) {
- Array arr{ty.i32(), 0, ast::DecorationList{}};
+ ArrayType arr{ty.i32(), 0, ast::DecorationList{}};
EXPECT_EQ(arr.FriendlyName(Symbols()), "array<i32>");
}
TEST_F(ArrayTest, FriendlyNameStaticSized) {
- Array arr{ty.i32(), 5, ast::DecorationList{}};
+ ArrayType arr{ty.i32(), 5, ast::DecorationList{}};
EXPECT_EQ(arr.FriendlyName(Symbols()), "array<i32, 5>");
}
TEST_F(ArrayTest, FriendlyNameWithStride) {
- Array arr{ty.i32(), 5,
- ast::DecorationList{create<ast::StrideDecoration>(32)}};
+ ArrayType arr{ty.i32(), 5,
+ ast::DecorationList{create<ast::StrideDecoration>(32)}};
EXPECT_EQ(arr.FriendlyName(Symbols()), "[[stride(32)]] array<i32, 5>");
}
TEST_F(ArrayTest, TypeName_RuntimeArray) {
I32 i32;
- Array arr{&i32, 3, ast::DecorationList{}};
+ ArrayType arr{&i32, 3, ast::DecorationList{}};
EXPECT_EQ(arr.type_name(), "__array__i32_3");
}
TEST_F(ArrayTest, TypeName_WithStride) {
I32 i32;
- Array arr{&i32, 3, ast::DecorationList{create<ast::StrideDecoration>(16)}};
+ ArrayType arr{&i32, 3,
+ ast::DecorationList{create<ast::StrideDecoration>(16)}};
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
}
diff --git a/src/type/bool_type_test.cc b/src/type/bool_type_test.cc
index 7751c53..bd96693 100644
--- a/src/type/bool_type_test.cc
+++ b/src/type/bool_type_test.cc
@@ -27,7 +27,7 @@
Type* ty = &b;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_TRUE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/depth_texture_type_test.cc b/src/type/depth_texture_type_test.cc
index 8406feb..10364c0 100644
--- a/src/type/depth_texture_type_test.cc
+++ b/src/type/depth_texture_type_test.cc
@@ -32,7 +32,7 @@
Type* ty = &d;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/external_texture_type_test.cc b/src/type/external_texture_type_test.cc
index c181159..1129c92 100644
--- a/src/type/external_texture_type_test.cc
+++ b/src/type/external_texture_type_test.cc
@@ -33,7 +33,7 @@
Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/f32_type_test.cc b/src/type/f32_type_test.cc
index 2985597..23686a4 100644
--- a/src/type/f32_type_test.cc
+++ b/src/type/f32_type_test.cc
@@ -27,7 +27,7 @@
Type* ty = &f;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_TRUE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/i32_type_test.cc b/src/type/i32_type_test.cc
index 38aca92..9170155 100644
--- a/src/type/i32_type_test.cc
+++ b/src/type/i32_type_test.cc
@@ -27,7 +27,7 @@
Type* ty = &i;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_TRUE(ty->Is<I32>());
diff --git a/src/type/matrix_type_test.cc b/src/type/matrix_type_test.cc
index 09dc8f0..40c7d5c 100644
--- a/src/type/matrix_type_test.cc
+++ b/src/type/matrix_type_test.cc
@@ -36,7 +36,7 @@
Type* ty = &m;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/multisampled_texture_type_test.cc b/src/type/multisampled_texture_type_test.cc
index 2e15846..bcafafc 100644
--- a/src/type/multisampled_texture_type_test.cc
+++ b/src/type/multisampled_texture_type_test.cc
@@ -33,7 +33,7 @@
Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/pointer_type_test.cc b/src/type/pointer_type_test.cc
index f79211c..65c5178 100644
--- a/src/type/pointer_type_test.cc
+++ b/src/type/pointer_type_test.cc
@@ -35,7 +35,7 @@
Type* ty = &p;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/sampled_texture_type_test.cc b/src/type/sampled_texture_type_test.cc
index 3dc6c38..bfbaff8 100644
--- a/src/type/sampled_texture_type_test.cc
+++ b/src/type/sampled_texture_type_test.cc
@@ -32,7 +32,7 @@
Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/sampler_type_test.cc b/src/type/sampler_type_test.cc
index a3ea06d..fb6ccdf 100644
--- a/src/type/sampler_type_test.cc
+++ b/src/type/sampler_type_test.cc
@@ -38,7 +38,7 @@
Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc
index ff8efc7..4dee89c 100644
--- a/src/type/storage_texture_type_test.cc
+++ b/src/type/storage_texture_type_test.cc
@@ -34,7 +34,7 @@
Type* ty = s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/struct_type_test.cc b/src/type/struct_type_test.cc
index 6ea9bb2..c90bf48 100644
--- a/src/type/struct_type_test.cc
+++ b/src/type/struct_type_test.cc
@@ -37,7 +37,7 @@
type::Type* ty = s;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/u32_type_test.cc b/src/type/u32_type_test.cc
index c320cb5..af3752d 100644
--- a/src/type/u32_type_test.cc
+++ b/src/type/u32_type_test.cc
@@ -27,7 +27,7 @@
Type* ty = &u;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/type/vector_type_test.cc b/src/type/vector_type_test.cc
index 8c4a793..ab0cf3c 100644
--- a/src/type/vector_type_test.cc
+++ b/src/type/vector_type_test.cc
@@ -35,7 +35,7 @@
Type* ty = &v;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
- EXPECT_FALSE(ty->Is<Array>());
+ EXPECT_FALSE(ty->Is<ArrayType>());
EXPECT_FALSE(ty->Is<Bool>());
EXPECT_FALSE(ty->Is<F32>());
EXPECT_FALSE(ty->Is<I32>());
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index fed3572..f4741ce 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -1315,8 +1315,9 @@
return EmitZeroValue(out, expr->type());
}
- bool brackets =
- expr->type()->UnwrapAliasIfNeeded()->IsAnyOf<type::Array, type::Struct>();
+ bool brackets = expr->type()
+ ->UnwrapAliasIfNeeded()
+ ->IsAnyOf<type::ArrayType, type::Struct>();
if (brackets) {
out << "{";
@@ -1643,7 +1644,7 @@
return false;
}
// Array name is output as part of the type
- if (!type->Is<type::Array>()) {
+ if (!type->Is<type::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(v->symbol());
}
}
@@ -1909,7 +1910,7 @@
if (!EmitType(out, var->DeclaredType(), var->StorageClass(), name)) {
return false;
}
- if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is<type::Array>()) {
+ if (!var->DeclaredType()->UnwrapAliasIfNeeded()->Is<type::ArrayType>()) {
out << " " << name;
}
@@ -2397,10 +2398,10 @@
if (auto* alias = type->As<type::Alias>()) {
out << builder_.Symbols().NameFor(alias->symbol());
- } else if (auto* ary = type->As<type::Array>()) {
+ } else if (auto* ary = type->As<type::ArrayType>()) {
type::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (auto* arr = base_type->As<type::Array>()) {
+ while (auto* arr = base_type->As<type::ArrayType>()) {
if (arr->IsRuntimeArray()) {
TINT_ICE(diagnostics_)
<< "Runtime arrays may only exist in storage buffers, which should "
@@ -2564,7 +2565,7 @@
return false;
}
// Array member name will be output with the type
- if (!mem->type()->Is<type::Array>()) {
+ if (!mem->type()->Is<type::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(mem->symbol());
}
@@ -2663,7 +2664,7 @@
builder_.Symbols().NameFor(var->symbol()))) {
return false;
}
- if (!type->Is<type::Array>()) {
+ if (!type->Is<type::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(var->symbol());
}
out << constructor_out.str() << ";" << std::endl;
@@ -2725,7 +2726,7 @@
builder_.Symbols().NameFor(var->symbol()))) {
return false;
}
- if (!type->Is<type::Array>()) {
+ if (!type->Is<type::ArrayType>()) {
out << " " << builder_.Symbols().NameFor(var->symbol());
}
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index b50c263..30016a5 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -886,7 +886,7 @@
}
bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) {
- if (expr->type()->IsAnyOf<type::Array, type::Struct>()) {
+ if (expr->type()->IsAnyOf<type::ArrayType, type::Struct>()) {
out_ << "{";
} else {
if (!EmitType(expr->type(), "")) {
@@ -915,7 +915,7 @@
}
}
- if (expr->type()->IsAnyOf<type::Array, type::Struct>()) {
+ if (expr->type()->IsAnyOf<type::ArrayType, type::Struct>()) {
out_ << "}";
} else {
out_ << ")";
@@ -936,7 +936,7 @@
return EmitZeroValue(vec->type());
} else if (auto* mat = type->As<type::Matrix>()) {
return EmitZeroValue(mat->type());
- } else if (auto* arr = type->As<type::Array>()) {
+ } else if (auto* arr = type->As<type::ArrayType>()) {
out_ << "{";
if (!EmitZeroValue(arr->type())) {
return false;
@@ -1325,7 +1325,7 @@
return false;
}
// Array name is output as part of the type
- if (!type->Is<type::Array>()) {
+ if (!type->Is<type::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(v->symbol());
}
}
@@ -1908,10 +1908,10 @@
if (auto* alias = type->As<type::Alias>()) {
out_ << program_->Symbols().NameFor(alias->symbol());
- } else if (auto* ary = type->As<type::Array>()) {
+ } else if (auto* ary = type->As<type::ArrayType>()) {
type::Type* base_type = ary;
std::vector<uint32_t> sizes;
- while (auto* arr = base_type->As<type::Array>()) {
+ while (auto* arr = base_type->As<type::ArrayType>()) {
if (arr->IsRuntimeArray()) {
sizes.push_back(1);
} else {
@@ -2120,7 +2120,7 @@
auto* ty = mem->type()->UnwrapAliasIfNeeded();
// Array member name will be output with the type
- if (!ty->Is<type::Array>()) {
+ if (!ty->Is<type::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(mem->symbol());
}
@@ -2222,7 +2222,7 @@
if (!EmitType(var->Type(), program_->Symbols().NameFor(decl->symbol()))) {
return false;
}
- if (!var->Type()->Is<type::Array>()) {
+ if (!var->Type()->Is<type::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(decl->symbol());
}
@@ -2265,7 +2265,7 @@
if (!EmitType(type, program_->Symbols().NameFor(var->symbol()))) {
return false;
}
- if (!type->Is<type::Array>()) {
+ if (!type->Is<type::ArrayType>()) {
out_ << " " << program_->Symbols().NameFor(var->symbol());
}
@@ -2326,7 +2326,7 @@
}
}
- if (auto* arr = ty->As<type::Array>()) {
+ if (auto* arr = ty->As<type::ArrayType>()) {
auto* sem = program_->Sem().Get(arr);
if (!sem) {
TINT_ICE(diagnostics_) << "Array missing semantic info";
diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
index 9b6e19e..72d6ade 100644
--- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
@@ -52,7 +52,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
- type::Array ary(ty.f32(), 5, ast::DecorationList{});
+ type::ArrayType ary(ty.f32(), 5, ast::DecorationList{});
auto* var = Var("a", &ary, ast::StorageClass::kNone);
auto* stmt = create<ast::VariableDeclStatement>(var);
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 4482b7d..3d955f8 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -112,7 +112,7 @@
/// @param type the given type, which must not be null
/// @returns the nested matrix type, or nullptr if none
type::Matrix* GetNestedMatrixType(type::Type* type) {
- while (auto* arr = type->As<type::Array>()) {
+ while (auto* arr = type->As<type::ArrayType>()) {
type = arr->type();
}
return type->As<type::Matrix>();
@@ -827,8 +827,8 @@
// If the source is a pointer we access chain into it. We also access chain
// into an array of non-scalar types.
if (info->source_type->Is<type::Pointer>() ||
- (info->source_type->Is<type::Array>() &&
- !info->source_type->As<type::Array>()->type()->is_scalar())) {
+ (info->source_type->Is<type::ArrayType>() &&
+ !info->source_type->As<type::ArrayType>()->type()->is_scalar())) {
info->access_chain_indices.push_back(idx_id);
info->source_type = TypeOf(expr);
return true;
@@ -1045,8 +1045,8 @@
auto* ary_res_type = TypeOf(array->array());
if (!ary_res_type->Is<type::Pointer>() &&
- (ary_res_type->Is<type::Array>() &&
- !ary_res_type->As<type::Array>()->type()->is_scalar())) {
+ (ary_res_type->Is<type::ArrayType>() &&
+ !ary_res_type->As<type::ArrayType>()->type()->is_scalar())) {
type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction);
auto result_type_id = GenerateTypeIfNeeded(&ptr);
if (result_type_id == 0) {
@@ -1250,7 +1250,7 @@
subtype = vec->type()->UnwrapAll();
} else if (auto* mat = subtype->As<type::Matrix>()) {
subtype = mat->type()->UnwrapAll();
- } else if (auto* arr = subtype->As<type::Array>()) {
+ } else if (auto* arr = subtype->As<type::ArrayType>()) {
subtype = arr->type()->UnwrapAll();
} else if (auto* str = subtype->As<type::Struct>()) {
subtype = str->impl()->members()[i]->type()->UnwrapAll();
@@ -1329,7 +1329,7 @@
// If the result is not a vector then we should have validated that the
// value type is a correctly sized vector so we can just use it directly.
if (result_type == value_type || result_type->Is<type::Matrix>() ||
- result_type->Is<type::Array>() || result_type->Is<type::Struct>()) {
+ result_type->Is<type::ArrayType>() || result_type->Is<type::Struct>()) {
out << "_" << id;
ops.push_back(Operand::Int(id));
@@ -2953,7 +2953,7 @@
result)) {
return 0;
}
- } else if (auto* arr = type->As<type::Array>()) {
+ } else if (auto* arr = type->As<type::ArrayType>()) {
if (!GenerateArrayType(arr, result)) {
return 0;
}
@@ -3084,7 +3084,7 @@
return true;
}
-bool Builder::GenerateArrayType(type::Array* ary, const Operand& result) {
+bool Builder::GenerateArrayType(type::ArrayType* ary, const Operand& result) {
auto elem_type = GenerateTypeIfNeeded(ary->type());
if (elem_type == 0) {
return false;
diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h
index d66c4e2..d70280b 100644
--- a/src/writer/spirv/builder.h
+++ b/src/writer/spirv/builder.h
@@ -433,7 +433,7 @@
/// @param ary the array to generate
/// @param result the result operand
/// @returns true if the array was successfully generated
- bool GenerateArrayType(type::Array* ary, const Operand& result);
+ bool GenerateArrayType(type::ArrayType* ary, const Operand& result);
/// Generates a matrix type declaration
/// @param mat the matrix to generate
/// @param result the result operand
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index a93a5bf..eeb9fc6 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -390,7 +390,7 @@
return true;
} else if (auto* alias = type->As<type::Alias>()) {
out_ << program_->Symbols().NameFor(alias->symbol());
- } else if (auto* ary = type->As<type::Array>()) {
+ } else if (auto* ary = type->As<type::ArrayType>()) {
for (auto* deco : ary->decorations()) {
if (auto* stride = deco->As<ast::StrideDecoration>()) {
out_ << "[[stride(" << stride->stride() << ")]] ";
diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc
index 85c6cdc..87f9df1 100644
--- a/src/writer/wgsl/generator_impl_type_test.cc
+++ b/src/writer/wgsl/generator_impl_type_test.cc
@@ -73,10 +73,10 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
- auto* a = create<type::Array>(ty.bool_(), 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(16u),
- });
+ auto* a = create<type::ArrayType>(ty.bool_(), 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(16u),
+ });
AST().AddConstructedType(ty.alias("make_type_reachable", a));
GeneratorImpl& gen = Build();
@@ -86,11 +86,11 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
- auto* a = create<type::Array>(ty.bool_(), 4,
- ast::DecorationList{
- create<ast::StrideDecoration>(16u),
- create<ast::StrideDecoration>(32u),
- });
+ auto* a = create<type::ArrayType>(ty.bool_(), 4,
+ ast::DecorationList{
+ create<ast::StrideDecoration>(16u),
+ create<ast::StrideDecoration>(32u),
+ });
AST().AddConstructedType(ty.alias("make_type_reachable", a));
GeneratorImpl& gen = Build();
@@ -100,7 +100,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
- auto* a = create<type::Array>(ty.bool_(), 0, ast::DecorationList{});
+ auto* a = create<type::ArrayType>(ty.bool_(), 0, ast::DecorationList{});
AST().AddConstructedType(ty.alias("make_type_reachable", a));
GeneratorImpl& gen = Build();