Rename type::Struct to type::StructType
This is to avoid name conflicts once we move all classes from namespace
`type` to `sem`.
Bug: tint:724
Change-Id: I23cdec636cb5bcf0bbba03ee7bb7c44252ddade7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48361
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/ast/module.cc b/src/ast/module.cc
index 50217c0..c26e6ed 100644
--- a/src/ast/module.cc
+++ b/src/ast/module.cc
@@ -85,10 +85,10 @@
if (auto* alias = ty->As<type::Alias>()) {
out << alias->symbol().to_str() << " -> " << alias->type()->type_name()
<< std::endl;
- if (auto* str = alias->type()->As<type::Struct>()) {
+ if (auto* str = alias->type()->As<type::StructType>()) {
str->impl()->to_str(sem, out, indent);
}
- } else if (auto* str = ty->As<type::Struct>()) {
+ } else if (auto* str = ty->As<type::StructType>()) {
out << str->symbol().to_str() << " ";
str->impl()->to_str(sem, out, indent);
}
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index f532847..c9ca62d 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -386,7 +386,7 @@
auto binding_info = ruv.second;
auto* unwrapped_type = var->Type()->UnwrapIfNeeded();
- auto* str = unwrapped_type->As<type::Struct>();
+ auto* str = unwrapped_type->As<type::StructType>();
if (str == nullptr) {
continue;
}
@@ -551,7 +551,7 @@
auto* unwrapped_type = type->UnwrapAll();
- if (auto* struct_ty = unwrapped_type->As<type::Struct>()) {
+ if (auto* struct_ty = unwrapped_type->As<type::StructType>()) {
// Recurse into members.
for (auto* member : struct_ty->impl()->members()) {
AddEntryPointInOutVariables(
@@ -606,7 +606,7 @@
continue;
}
- auto* str = var->Type()->UnwrapIfNeeded()->As<type::Struct>();
+ auto* str = var->Type()->UnwrapIfNeeded()->As<type::StructType>();
if (!str) {
continue;
}
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index 62616b7..f3ea311 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -62,7 +62,7 @@
/// Generates a struct that contains user-defined IO members
/// @param name the name of the generated struct
/// @param inout_vars tuples of {name, loc} that will be the struct members
- type::Struct* MakeInOutStruct(
+ type::StructType* MakeInOutStruct(
std::string name,
std::vector<std::tuple<std::string, uint32_t>> inout_vars) {
ast::StructMemberList members;
@@ -212,9 +212,9 @@
/// @param member_types a vector of member types
/// @param is_block whether or not to decorate as a Block
/// @returns a struct type
- type::Struct* MakeStructType(const std::string& name,
- std::vector<type::Type*> member_types,
- bool is_block) {
+ type::StructType* MakeStructType(const std::string& name,
+ std::vector<type::Type*> member_types,
+ bool is_block) {
ast::StructMemberList members;
for (auto* type : member_types) {
members.push_back(Member(StructMemberName(members.size(), type), type));
@@ -235,8 +235,9 @@
/// @param name name for the type
/// @param member_types a vector of member types
/// @returns a struct type that has the layout for an uniform buffer.
- type::Struct* MakeUniformBufferType(const std::string& name,
- std::vector<type::Type*> member_types) {
+ type::StructType* MakeUniformBufferType(
+ const std::string& name,
+ std::vector<type::Type*> member_types) {
auto* struct_type = MakeStructType(name, member_types, true);
return struct_type;
}
@@ -247,7 +248,7 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a storage buffer, and the control type wraps the
/// struct.
- std::tuple<type::Struct*, type::AccessControl*> MakeStorageBufferTypes(
+ std::tuple<type::StructType*, type::AccessControl*> MakeStorageBufferTypes(
const std::string& name,
std::vector<type::Type*> member_types) {
auto* struct_type = MakeStructType(name, member_types, true);
@@ -262,7 +263,7 @@
/// @returns a tuple {struct type, access control type}, where the struct has
/// the layout for a read-only storage buffer, and the control type
/// wraps the struct.
- std::tuple<type::Struct*, type::AccessControl*>
+ std::tuple<type::StructType*, type::AccessControl*>
MakeReadOnlyStorageBufferTypes(const std::string& name,
std::vector<type::Type*> member_types) {
auto* struct_type = MakeStructType(name, member_types, true);
@@ -1680,18 +1681,19 @@
}
TEST_F(InspectorGetResourceBindingsTest, Simple) {
- type::Struct* ub_struct_type = MakeUniformBufferType("ub_type", {ty.i32()});
+ type::StructType* ub_struct_type =
+ MakeUniformBufferType("ub_type", {ty.i32()});
AddUniformBuffer("ub_var", ub_struct_type, 0, 0);
MakeStructVariableReferenceBodyFunction("ub_func", "ub_var", {{0, ty.i32()}});
- type::Struct* sb_struct_type;
+ type::StructType* sb_struct_type;
type::AccessControl* sb_control_type;
std::tie(sb_struct_type, sb_control_type) =
MakeStorageBufferTypes("sb_type", {ty.i32()});
AddStorageBuffer("sb_var", sb_control_type, 1, 0);
MakeStructVariableReferenceBodyFunction("sb_func", "sb_var", {{0, ty.i32()}});
- type::Struct* rosb_struct_type;
+ type::StructType* rosb_struct_type;
type::AccessControl* rosb_control_type;
std::tie(rosb_struct_type, rosb_control_type) =
MakeReadOnlyStorageBufferTypes("rosb_type", {ty.i32()});
@@ -1801,7 +1803,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
- type::Struct* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()});
+ type::StructType* foo_struct_type =
+ MakeUniformBufferType("foo_type", {ty.i32()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}});
@@ -1844,7 +1847,8 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
- type::Struct* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()});
+ type::StructType* foo_struct_type =
+ MakeUniformBufferType("foo_type", {ty.i32()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}});
@@ -1870,7 +1874,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
- type::Struct* foo_struct_type =
+ type::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.i32(), ty.u32(), ty.f32()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -1898,7 +1902,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) {
- type::Struct* foo_struct_type =
+ type::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.vec3<f32>()});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -1926,7 +1930,7 @@
}
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
- type::Struct* ub_struct_type =
+ type::StructType* ub_struct_type =
MakeUniformBufferType("ub_type", {ty.i32(), ty.u32(), ty.f32()});
AddUniformBuffer("ub_foo", ub_struct_type, 0, 0);
AddUniformBuffer("ub_bar", ub_struct_type, 0, 1);
@@ -1985,7 +1989,7 @@
// TODO(bclayton) - This is not a legal structure layout for uniform buffer
// usage. Once crbug.com/tint/628 is implemented, this will fail validation
// and will need to be fixed.
- type::Struct* foo_struct_type =
+ type::StructType* foo_struct_type =
MakeUniformBufferType("foo_type", {ty.i32(), u32_array_type(4)});
AddUniformBuffer("foo_ub", foo_struct_type, 0, 0);
@@ -2012,7 +2016,7 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32()});
@@ -2041,7 +2045,7 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32(), ty.u32(), ty.f32()});
@@ -2071,7 +2075,7 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
- type::Struct* sb_struct_type;
+ type::StructType* sb_struct_type;
type::AccessControl* sb_control_type;
std::tie(sb_struct_type, sb_control_type) =
MakeStorageBufferTypes("sb_type", {ty.i32(), ty.u32(), ty.f32()});
@@ -2132,7 +2136,7 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(4)});
@@ -2161,7 +2165,7 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(0)});
@@ -2190,7 +2194,7 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.vec3<f32>()});
@@ -2220,7 +2224,7 @@
}
TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32()});
@@ -2242,7 +2246,7 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32()});
@@ -2272,7 +2276,7 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
MultipleStorageBuffers) {
- type::Struct* sb_struct_type;
+ type::StructType* sb_struct_type;
type::AccessControl* sb_control_type;
std::tie(sb_struct_type, sb_control_type) =
MakeReadOnlyStorageBufferTypes("sb_type", {ty.i32(), ty.u32(), ty.f32()});
@@ -2333,7 +2337,7 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(4)});
@@ -2363,7 +2367,7 @@
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
ContainingRuntimeArray) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(0)});
@@ -2392,7 +2396,7 @@
}
TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
- type::Struct* foo_struct_type;
+ type::StructType* foo_struct_type;
type::AccessControl* foo_control_type;
std::tie(foo_struct_type, foo_control_type) =
MakeStorageBufferTypes("foo_type", {ty.i32()});
diff --git a/src/program_builder.h b/src/program_builder.h
index a930fd5..e1b0863 100644
--- a/src/program_builder.h
+++ b/src/program_builder.h
@@ -561,8 +561,8 @@
/// @param impl the struct implementation
/// @returns a struct pointer
template <typename NAME>
- type::Struct* struct_(NAME&& name, ast::Struct* impl) const {
- return builder->create<type::Struct>(
+ type::StructType* struct_(NAME&& name, ast::Struct* impl) const {
+ return builder->create<type::StructType>(
builder->Sym(std::forward<NAME>(name)), impl);
}
@@ -1174,18 +1174,18 @@
return create<ast::ReturnStatement>(Expr(std::forward<EXPR>(val)));
}
- /// Creates a ast::Struct and type::Struct, registering the type::Struct with
- /// the AST().ConstructedTypes().
+ /// Creates a ast::Struct and type::StructType, registering the
+ /// type::StructType with the AST().ConstructedTypes().
/// @param source the source information
/// @param name the struct name
/// @param members the struct members
/// @param decorations the optional struct decorations
/// @returns the struct type
template <typename NAME>
- type::Struct* Structure(const Source& source,
- NAME&& name,
- ast::StructMemberList members,
- ast::DecorationList decorations = {}) {
+ type::StructType* Structure(const Source& source,
+ NAME&& name,
+ ast::StructMemberList members,
+ ast::DecorationList decorations = {}) {
auto* impl =
create<ast::Struct>(source, std::move(members), std::move(decorations));
auto* type = ty.struct_(Sym(std::forward<NAME>(name)), impl);
@@ -1193,16 +1193,16 @@
return type;
}
- /// Creates a ast::Struct and type::Struct, registering the type::Struct with
- /// the AST().ConstructedTypes().
+ /// Creates a ast::Struct and type::StructType, registering the
+ /// type::StructType with the AST().ConstructedTypes().
/// @param name the struct name
/// @param members the struct members
/// @param decorations the optional struct decorations
/// @returns the struct type
template <typename NAME>
- type::Struct* Structure(NAME&& name,
- ast::StructMemberList members,
- ast::DecorationList decorations = {}) {
+ type::StructType* Structure(NAME&& name,
+ ast::StructMemberList members,
+ ast::DecorationList decorations = {}) {
auto* impl =
create<ast::Struct>(std::move(members), std::move(decorations));
auto* type = ty.struct_(Sym(std::forward<NAME>(name)), impl);
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index 7fc36ee..8a17c3c 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -947,7 +947,7 @@
namer_.SuggestSanitizedName(type_id, "S");
auto name = namer_.GetName(type_id);
- auto* result = builder_.create<type::Struct>(
+ auto* result = builder_.create<type::StructType>(
builder_.Symbols().Register(name), ast_struct);
id_to_type_[type_id] = result;
if (num_non_writable_members == members.size()) {
@@ -1501,7 +1501,7 @@
return create<ast::TypeConstructorExpression>(Source{}, original_type,
std::move(ast_components));
}
- if (auto* struct_ty = type->As<type::Struct>()) {
+ if (auto* struct_ty = type->As<type::StructType>()) {
ast::ExpressionList ast_components;
for (auto* member : struct_ty->impl()->members()) {
ast_components.emplace_back(MakeNullValue(member->type()));
diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc
index b1ccd14..17600dd 100644
--- a/src/reader/spirv/parser_impl_convert_type_test.cc
+++ b/src/reader/spirv/parser_impl_convert_type_test.cc
@@ -550,10 +550,10 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::Struct>());
+ EXPECT_TRUE(type->Is<type::StructType>());
Program program = p->program();
- EXPECT_THAT(program.str(type->As<type::Struct>()->impl()), Eq(R"(Struct{
+ EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
StructMember{field0: __u32}
StructMember{field1: __f32}
}
@@ -571,10 +571,10 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::Struct>());
+ EXPECT_TRUE(type->Is<type::StructType>());
Program program = p->program();
- EXPECT_THAT(program.str(type->As<type::Struct>()->impl()), Eq(R"(Struct{
+ EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
[[block]]
StructMember{field0: __u32}
}
@@ -596,10 +596,10 @@
auto* type = p->ConvertType(10);
ASSERT_NE(type, nullptr);
- EXPECT_TRUE(type->Is<type::Struct>());
+ EXPECT_TRUE(type->Is<type::StructType>());
Program program = p->program();
- EXPECT_THAT(program.str(type->As<type::Struct>()->impl()), Eq(R"(Struct{
+ EXPECT_THAT(program.str(type->As<type::StructType>()->impl()), Eq(R"(Struct{
StructMember{[[ offset 0 ]] field0: __f32}
StructMember{[[ offset 8 ]] field1: __vec_2__f32}
StructMember{[[ offset 16 ]] field2: __mat_2_2__f32}
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index f7ee20f..95514e8 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -1121,7 +1121,7 @@
// struct_decl
// : struct_decoration_decl* STRUCT IDENT struct_body_decl
-Maybe<type::Struct*> ParserImpl::struct_decl(ast::DecorationList& decos) {
+Maybe<type::StructType*> ParserImpl::struct_decl(ast::DecorationList& decos) {
auto t = peek();
auto source = t.source();
@@ -1136,7 +1136,7 @@
if (body.errored)
return Failure::kErrored;
- return create<type::Struct>(
+ return create<type::StructType>(
builder_.Symbols().Register(name.value),
create<ast::Struct>(source, std::move(body.value), std::move(decos)));
}
diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h
index 7f4929b..ba756fd 100644
--- a/src/reader/wgsl/parser_impl.h
+++ b/src/reader/wgsl/parser_impl.h
@@ -379,7 +379,7 @@
/// `struct_decoration_decl*` provided as `decos`.
/// @returns the struct type or nullptr on error
/// @param decos the list of decorations for the struct declaration.
- Maybe<type::Struct*> struct_decl(ast::DecorationList& decos);
+ Maybe<type::StructType*> struct_decl(ast::DecorationList& decos);
/// Parses a `struct_body_decl` grammar element, erroring on parse failure.
/// @returns the struct members
Expect<ast::StructMemberList> expect_struct_body_decl();
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc
index 1bbb9bd..923828a 100644
--- a/src/reader/wgsl/parser_impl_global_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -102,8 +102,8 @@
auto program = p->program();
ASSERT_EQ(program.AST().ConstructedTypes().size(), 2u);
- ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<type::Struct>());
- auto* str = program.AST().ConstructedTypes()[0]->As<type::Struct>();
+ ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is<type::StructType>());
+ auto* str = program.AST().ConstructedTypes()[0]->As<type::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is<type::Alias>());
@@ -165,9 +165,9 @@
auto* t = program.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<type::Struct>());
+ ASSERT_TRUE(t->Is<type::StructType>());
- auto* str = t->As<type::Struct>();
+ auto* str = t->As<type::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
EXPECT_EQ(str->impl()->members().size(), 2u);
}
@@ -183,9 +183,9 @@
auto* t = program.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<type::Struct>());
+ ASSERT_TRUE(t->Is<type::StructType>());
- auto* str = t->As<type::Struct>();
+ auto* str = t->As<type::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_FALSE(str->IsBlockDecorated());
@@ -210,9 +210,9 @@
auto* t = program.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
- ASSERT_TRUE(t->Is<type::Struct>());
+ ASSERT_TRUE(t->Is<type::StructType>());
- auto* str = t->As<type::Struct>();
+ auto* str = t->As<type::StructType>();
EXPECT_EQ(str->symbol(), program.Symbols().Get("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_TRUE(str->IsBlockDecorated());
diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc
index 17e2819..04a712d 100644
--- a/src/reader/wgsl/parser_impl_type_alias_test.cc
+++ b/src/reader/wgsl/parser_impl_type_alias_test.cc
@@ -38,7 +38,7 @@
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
auto p = parser("type a = B");
- type::Struct str(p->builder().Symbols().Get("B"), {});
+ type::StructType str(p->builder().Symbols().Get("B"), {});
p->register_constructed("B", &str);
auto t = p->type_alias();
@@ -49,9 +49,9 @@
ASSERT_TRUE(t->Is<type::Alias>());
auto* alias = t->As<type::Alias>();
EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "a");
- ASSERT_TRUE(alias->type()->Is<type::Struct>());
+ ASSERT_TRUE(alias->type()->Is<type::StructType>());
- auto* s = alias->type()->As<type::Struct>();
+ auto* s = alias->type()->As<type::StructType>();
EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B"));
EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B"));
}
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index ed826d7..75b6224 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -126,7 +126,7 @@
if (type::ArrayType* arr = type->As<type::ArrayType>()) {
return IsStorable(arr->type());
}
- if (type::Struct* str = type->As<type::Struct>()) {
+ if (type::StructType* str = type->As<type::StructType>()) {
for (const auto* member : str->impl()->members()) {
if (!IsStorable(member->type())) {
return false;
@@ -152,7 +152,7 @@
if (auto* arr = type->As<type::ArrayType>()) {
return IsHostShareable(arr->type());
}
- if (auto* str = type->As<type::Struct>()) {
+ if (auto* str = type->As<type::StructType>()) {
for (auto* member : str->impl()->members()) {
if (!IsHostShareable(member->type())) {
return false;
@@ -224,7 +224,7 @@
bool Resolver::Type(type::Type* ty) {
ty = ty->UnwrapAliasIfNeeded();
- if (auto* str = ty->As<type::Struct>()) {
+ if (auto* str = ty->As<type::StructType>()) {
if (!Structure(str)) {
return false;
}
@@ -331,7 +331,7 @@
// satisfying the storage class constraints.
auto* access = info->type->As<type::AccessControl>();
- auto* str = access ? access->type()->As<type::Struct>() : nullptr;
+ auto* str = access ? access->type()->As<type::StructType>() : nullptr;
if (!str) {
diagnostics_.add_error(
"variables declared in the <storage> storage class must be of an "
@@ -519,7 +519,7 @@
}
// Check that we saw a pipeline IO attribute iff we need one.
- if (Canonical(ty)->Is<type::Struct>()) {
+ if (Canonical(ty)->Is<type::StructType>()) {
if (pipeline_io_attribute) {
diagnostics_.add_error(
"entry point IO attributes must not be used on structure " +
@@ -555,12 +555,12 @@
return false;
}
- if (auto* struct_ty = Canonical(ty)->As<type::Struct>()) {
+ if (auto* struct_ty = Canonical(ty)->As<type::StructType>()) {
// Validate the decorations for each struct members, and also check for
// invalid member types.
for (auto* member : struct_ty->impl()->members()) {
auto* member_ty = Canonical(member->type());
- if (member_ty->Is<type::Struct>()) {
+ if (member_ty->Is<type::StructType>()) {
diagnostics_.add_error(
"entry point IO types cannot contain nested structures",
member->source());
@@ -646,7 +646,7 @@
return false;
}
- if (auto* str = param_info->type->As<type::Struct>()) {
+ if (auto* str = param_info->type->As<type::StructType>()) {
auto* info = Structure(str);
if (!info) {
return false;
@@ -670,7 +670,7 @@
}
}
- if (auto* str = Canonical(func->return_type())->As<type::Struct>()) {
+ if (auto* str = Canonical(func->return_type())->As<type::StructType>()) {
if (!ApplyStorageClassUsageToType(ast::StorageClass::kNone, str,
func->source())) {
diagnostics_.add_note("while instantiating return type for " +
@@ -1296,7 +1296,7 @@
type::Type* ret = nullptr;
std::vector<uint32_t> swizzle;
- if (auto* ty = data_type->As<type::Struct>()) {
+ if (auto* ty = data_type->As<type::StructType>()) {
Mark(expr->member());
auto symbol = expr->member()->symbol();
auto* str = Structure(ty);
@@ -1909,7 +1909,7 @@
align = vector_align[mat->rows()];
size = vector_align[mat->rows()] * mat->columns();
return true;
- } else if (auto* s = cty->As<type::Struct>()) {
+ } else if (auto* s = cty->As<type::StructType>()) {
if (auto* si = Structure(s)) {
align = si->align;
size = si->size;
@@ -1998,7 +1998,7 @@
return create_semantic(implicit_stride);
}
-bool Resolver::ValidateStructure(const type::Struct* st) {
+bool Resolver::ValidateStructure(const type::StructType* st) {
for (auto* member : st->impl()->members()) {
if (auto* r = member->type()->UnwrapAll()->As<type::ArrayType>()) {
if (r->IsRuntimeArray()) {
@@ -2053,7 +2053,7 @@
return true;
}
-Resolver::StructInfo* Resolver::Structure(type::Struct* str) {
+Resolver::StructInfo* Resolver::Structure(type::StructType* str) {
auto info_it = struct_info_.find(str);
if (info_it != struct_info_.end()) {
// StructInfo already resolved for this structure type
@@ -2369,7 +2369,7 @@
const Source& usage) {
ty = ty->UnwrapIfNeeded();
- if (auto* str = ty->As<type::Struct>()) {
+ if (auto* str = ty->As<type::StructType>()) {
auto* info = Structure(str);
if (!info) {
return false;
diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h
index 067941e..740ebfa 100644
--- a/src/resolver/resolver.h
+++ b/src/resolver/resolver.h
@@ -245,7 +245,7 @@
const ast::ExpressionList& values);
bool ValidateParameter(const ast::Variable* param);
bool ValidateReturn(const ast::ReturnStatement* ret);
- bool ValidateStructure(const type::Struct* st);
+ bool ValidateStructure(const type::StructType* st);
bool ValidateSwitch(const ast::SwitchStatement* s);
bool ValidateVariable(const ast::Variable* param);
bool ValidateVectorConstructor(const type::Vector* vec_type,
@@ -260,7 +260,7 @@
/// @returns the StructInfo for the structure `str`, building it if it hasn't
/// been constructed already. If an error is raised, nullptr is returned.
- StructInfo* Structure(type::Struct* str);
+ StructInfo* Structure(type::StructType* str);
/// @returns the VariableInfo for the variable `var`, building it if it hasn't
/// been constructed already. If an error is raised, nullptr is returned.
@@ -330,7 +330,7 @@
std::unordered_map<const ast::Variable*, VariableInfo*> variable_to_info_;
std::unordered_map<ast::CallExpression*, FunctionCallInfo> function_calls_;
std::unordered_map<ast::Expression*, ExpressionInfo> expr_info_;
- std::unordered_map<type::Struct*, StructInfo*> struct_info_;
+ std::unordered_map<type::StructType*, StructInfo*> struct_info_;
std::unordered_map<type::Type*, type::Type*> type_to_canonical_;
std::unordered_set<ast::Node*> marked_;
FunctionInfo* current_function_ = nullptr;
diff --git a/src/sem/struct.cc b/src/sem/struct.cc
index e4d0c3c..4426800 100644
--- a/src/sem/struct.cc
+++ b/src/sem/struct.cc
@@ -23,7 +23,7 @@
namespace tint {
namespace sem {
-Struct::Struct(type::Struct* type,
+Struct::Struct(type::StructType* type,
StructMemberList members,
uint32_t align,
uint32_t size,
diff --git a/src/sem/struct.h b/src/sem/struct.h
index 8d3c93d..d4119f4 100644
--- a/src/sem/struct.h
+++ b/src/sem/struct.h
@@ -31,7 +31,7 @@
class StructMember;
} // namespace ast
namespace type {
-class Struct;
+class StructType;
} // namespace type
namespace sem {
@@ -63,7 +63,7 @@
/// alignment padding
/// @param storage_class_usage a set of all the storage class usages
/// @param pipeline_stage_uses a set of all the pipeline stage uses
- Struct(type::Struct* type,
+ Struct(type::StructType* type,
StructMemberList members,
uint32_t align,
uint32_t size,
@@ -75,7 +75,7 @@
~Struct() override;
/// @returns the structure type
- type::Struct* Type() const { return type_; }
+ type::StructType* Type() const { return type_; }
/// @returns the members of the structure
const StructMemberList& Members() const { return members_; }
@@ -128,7 +128,7 @@
}
private:
- type::Struct* const type_;
+ type::StructType* const type_;
StructMemberList const members_;
uint32_t const align_;
uint32_t const size_;
diff --git a/src/sem/type_mappings.h b/src/sem/type_mappings.h
index b92bc4c..fa4573f 100644
--- a/src/sem/type_mappings.h
+++ b/src/sem/type_mappings.h
@@ -31,7 +31,7 @@
} // namespace ast
namespace type {
class ArrayType;
-class Struct;
+class StructType;
} // namespace type
namespace sem {
@@ -59,7 +59,7 @@
Function* operator()(ast::Function*);
MemberAccessorExpression* operator()(ast::MemberAccessorExpression*);
Statement* operator()(ast::Statement*);
- Struct* operator()(type::Struct*);
+ Struct* operator()(type::StructType*);
StructMember* operator()(ast::StructMember*);
Variable* operator()(ast::Variable*);
//! @endcond
diff --git a/src/transform/calculate_array_length.cc b/src/transform/calculate_array_length.cc
index ae1d054..c60a99d 100644
--- a/src/transform/calculate_array_length.cc
+++ b/src/transform/calculate_array_length.cc
@@ -77,8 +77,8 @@
// get_buffer_size_intrinsic() emits the function decorated with
// BufferSizeIntrinsic that is transformed by the HLSL writer into a call to
// [RW]ByteAddressBuffer.GetDimensions().
- std::unordered_map<type::Struct*, Symbol> buffer_size_intrinsics;
- auto get_buffer_size_intrinsic = [&](type::Struct* buffer_type) {
+ std::unordered_map<type::StructType*, Symbol> buffer_size_intrinsics;
+ auto get_buffer_size_intrinsic = [&](type::StructType* buffer_type) {
return utils::GetOrCreate(buffer_size_intrinsics, buffer_type, [&] {
auto name = ctx.dst->Symbols().New();
auto* func = ctx.dst->create<ast::Function>(
@@ -138,7 +138,7 @@
auto* storage_buffer_expr = accessor->structure();
auto* storage_buffer_sem = sem.Get(storage_buffer_expr);
auto* storage_buffer_type =
- storage_buffer_sem->Type()->UnwrapAll()->As<type::Struct>();
+ storage_buffer_sem->Type()->UnwrapAll()->As<type::StructType>();
// Generate BufferSizeIntrinsic for this storage type if we haven't
// already
@@ -146,7 +146,7 @@
if (!storage_buffer_type) {
TINT_ICE(ctx.dst->Diagnostics())
- << "arrayLength(X.Y) expected X to be type::Struct, got "
+ << "arrayLength(X.Y) expected X to be type::StructType, got "
<< storage_buffer_type->FriendlyName(ctx.src->Symbols());
break;
}
diff --git a/src/transform/canonicalize_entry_point_io.cc b/src/transform/canonicalize_entry_point_io.cc
index 38f7d68..3066d23 100644
--- a/src/transform/canonicalize_entry_point_io.cc
+++ b/src/transform/canonicalize_entry_point_io.cc
@@ -66,7 +66,7 @@
// Strip entry point IO decorations from struct declarations.
// TODO(jrprice): This code is duplicated with the SPIR-V transform.
for (auto* ty : ctx.src->AST().ConstructedTypes()) {
- if (auto* struct_ty = ty->As<type::Struct>()) {
+ if (auto* struct_ty = ty->As<type::StructType>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
for (auto* member : struct_ty->impl()->members()) {
@@ -81,7 +81,7 @@
}
// Redeclare the struct.
- auto* new_struct = ctx.dst->create<type::Struct>(
+ auto* new_struct = ctx.dst->create<type::StructType>(
ctx.Clone(struct_ty->symbol()),
ctx.dst->create<ast::Struct>(
new_struct_members, ctx.Clone(struct_ty->impl()->decorations())));
@@ -107,11 +107,11 @@
std::function<ast::Expression*()> func_const_initializer;
- if (auto* struct_ty = param_ty->As<type::Struct>()) {
+ if (auto* struct_ty = param_ty->As<type::StructType>()) {
// Pull out all struct members and build initializer list.
std::vector<Symbol> member_names;
for (auto* member : struct_ty->impl()->members()) {
- if (member->type()->UnwrapAll()->Is<type::Struct>()) {
+ if (member->type()->UnwrapAll()->Is<type::StructType>()) {
TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
}
@@ -174,7 +174,7 @@
StructMemberComparator);
// Create the new struct type.
- auto* in_struct = ctx.dst->create<type::Struct>(
+ auto* in_struct = ctx.dst->create<type::StructType>(
ctx.dst->Symbols().New(),
ctx.dst->create<ast::Struct>(new_struct_members,
ast::DecorationList{}));
@@ -193,10 +193,10 @@
} else {
ast::StructMemberList new_struct_members;
- if (auto* struct_ty = ret_type->As<type::Struct>()) {
+ if (auto* struct_ty = ret_type->As<type::StructType>()) {
// Rebuild struct with only the entry point IO attributes.
for (auto* member : struct_ty->impl()->members()) {
- if (member->type()->UnwrapAll()->Is<type::Struct>()) {
+ if (member->type()->UnwrapAll()->Is<type::StructType>()) {
TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
}
@@ -220,7 +220,7 @@
StructMemberComparator);
// Create the new struct type.
- auto* out_struct = ctx.dst->create<type::Struct>(
+ auto* out_struct = ctx.dst->create<type::StructType>(
ctx.dst->Symbols().New(),
ctx.dst->create<ast::Struct>(new_struct_members,
ast::DecorationList{}));
@@ -237,7 +237,7 @@
};
ast::ExpressionList ret_values;
- if (ret_type->Is<type::Struct>()) {
+ if (ret_type->Is<type::StructType>()) {
if (!ret->value()->Is<ast::IdentifierExpression>()) {
// Create a const to hold the return value expression to avoid
// re-evaluating it multiple times.
diff --git a/src/transform/decompose_storage_access.cc b/src/transform/decompose_storage_access.cc
index 002d32f..0ae2587 100644
--- a/src/transform/decompose_storage_access.cc
+++ b/src/transform/decompose_storage_access.cc
@@ -341,7 +341,7 @@
if (auto* alias = ty->As<type::Alias>()) {
return alias;
}
- if (auto* str = ty->As<type::Struct>()) {
+ if (auto* str = ty->As<type::StructType>()) {
return str;
}
// Not a constructed type
@@ -438,7 +438,7 @@
ctx.dst->Add("offset", i * MatrixColumnStride(mat_ty));
values.emplace_back(ctx.dst->Call(load, "buffer", offset));
}
- } else if (auto* str_ty = el_ty->As<type::Struct>()) {
+ } else if (auto* str_ty = el_ty->As<type::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -505,7 +505,7 @@
auto* call = ctx.dst->Call(store, "buffer", offset, access);
body.emplace_back(ctx.dst->create<ast::CallStatement>(call));
}
- } else if (auto* str_ty = el_ty->As<type::Struct>()) {
+ } else if (auto* str_ty = el_ty->As<type::StructType>()) {
auto& sem = ctx.src->Sem();
auto* str = sem.Get(str_ty);
for (auto* member : str->Members()) {
@@ -660,7 +660,7 @@
}
} else {
if (auto access = state.TakeAccess(accessor->structure())) {
- auto* str_ty = access.type->As<type::Struct>();
+ auto* str_ty = access.type->As<type::StructType>();
auto* member =
sem.Get(str_ty)->FindMember(accessor->member()->symbol());
auto offset = member->Offset();
diff --git a/src/transform/hlsl.cc b/src/transform/hlsl.cc
index 6fa55dc..a1d7dbf 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::ArrayType, type::Struct>()) {
+ if (src_ty->IsAnyOf<type::ArrayType, type::StructType>()) {
// Create a new symbol for the constant
auto dst_symbol = ctx.dst->Symbols().New();
// Clone the type
diff --git a/src/transform/spirv.cc b/src/transform/spirv.cc
index 0077198..b8c44e6 100644
--- a/src/transform/spirv.cc
+++ b/src/transform/spirv.cc
@@ -111,7 +111,7 @@
// Strip entry point IO decorations from struct declarations.
for (auto* ty : ctx.src->AST().ConstructedTypes()) {
- if (auto* struct_ty = ty->As<type::Struct>()) {
+ if (auto* struct_ty = ty->As<type::StructType>()) {
// Build new list of struct members without entry point IO decorations.
ast::StructMemberList new_struct_members;
for (auto* member : struct_ty->impl()->members()) {
@@ -126,7 +126,7 @@
}
// Redeclare the struct.
- auto* new_struct = ctx.dst->create<type::Struct>(
+ auto* new_struct = ctx.dst->create<type::StructType>(
ctx.Clone(struct_ty->symbol()),
ctx.dst->create<ast::Struct>(
new_struct_members, ctx.Clone(struct_ty->impl()->decorations())));
@@ -255,7 +255,7 @@
type::Type* ty,
type::Type* declared_ty,
const ast::DecorationList& decorations) const {
- if (!ty->Is<type::Struct>()) {
+ if (!ty->Is<type::StructType>()) {
// Base case: create a global variable and return.
ast::DecorationList new_decorations =
RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) {
@@ -272,7 +272,7 @@
// Recurse into struct members and build the initializer list.
std::vector<Symbol> init_value_names;
- auto* struct_ty = ty->As<type::Struct>();
+ auto* struct_ty = ty->As<type::StructType>();
for (auto* member : struct_ty->impl()->members()) {
auto member_var = HoistToInputVariables(
ctx, func, member->type(), member->type(), member->decorations());
@@ -308,7 +308,7 @@
Symbol store_value,
ast::StatementList& stores) const {
// Base case.
- if (!ty->Is<type::Struct>()) {
+ if (!ty->Is<type::StructType>()) {
// Create a global variable.
ast::DecorationList new_decorations =
RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) {
@@ -332,7 +332,7 @@
}
// Recurse into struct members.
- auto* struct_ty = ty->As<type::Struct>();
+ auto* struct_ty = ty->As<type::StructType>();
for (auto* member : struct_ty->impl()->members()) {
member_accesses.push_back(ctx.Clone(member->symbol()));
HoistToOutputVariables(ctx, func, member->type(), member->type(),
diff --git a/src/type/access_control_type_test.cc b/src/type/access_control_type_test.cc
index 2ce6856..b8fd5aa 100644
--- a/src/type/access_control_type_test.cc
+++ b/src/type/access_control_type_test.cc
@@ -44,7 +44,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/alias_type_test.cc b/src/type/alias_type_test.cc
index b9f5c2b..b9a8f89 100644
--- a/src/type/alias_type_test.cc
+++ b/src/type/alias_type_test.cc
@@ -40,7 +40,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/array_type_test.cc b/src/type/array_type_test.cc
index 8986d10..f45f989 100644
--- a/src/type/array_type_test.cc
+++ b/src/type/array_type_test.cc
@@ -54,7 +54,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/bool_type_test.cc b/src/type/bool_type_test.cc
index bd96693..0775657 100644
--- a/src/type/bool_type_test.cc
+++ b/src/type/bool_type_test.cc
@@ -34,7 +34,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/depth_texture_type_test.cc b/src/type/depth_texture_type_test.cc
index 10364c0..eef75d5 100644
--- a/src/type/depth_texture_type_test.cc
+++ b/src/type/depth_texture_type_test.cc
@@ -39,7 +39,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/external_texture_type_test.cc b/src/type/external_texture_type_test.cc
index 1129c92..7c73d62 100644
--- a/src/type/external_texture_type_test.cc
+++ b/src/type/external_texture_type_test.cc
@@ -40,7 +40,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/f32_type_test.cc b/src/type/f32_type_test.cc
index 23686a4..a1b89d4 100644
--- a/src/type/f32_type_test.cc
+++ b/src/type/f32_type_test.cc
@@ -34,7 +34,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/i32_type_test.cc b/src/type/i32_type_test.cc
index 9170155..8def688 100644
--- a/src/type/i32_type_test.cc
+++ b/src/type/i32_type_test.cc
@@ -34,7 +34,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/matrix_type_test.cc b/src/type/matrix_type_test.cc
index 40c7d5c..92c2aaf 100644
--- a/src/type/matrix_type_test.cc
+++ b/src/type/matrix_type_test.cc
@@ -43,7 +43,7 @@
EXPECT_TRUE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/multisampled_texture_type_test.cc b/src/type/multisampled_texture_type_test.cc
index bcafafc..f18c9bf 100644
--- a/src/type/multisampled_texture_type_test.cc
+++ b/src/type/multisampled_texture_type_test.cc
@@ -40,7 +40,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/pointer_type_test.cc b/src/type/pointer_type_test.cc
index 65c5178..ec8d062 100644
--- a/src/type/pointer_type_test.cc
+++ b/src/type/pointer_type_test.cc
@@ -42,7 +42,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_TRUE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/sampled_texture_type_test.cc b/src/type/sampled_texture_type_test.cc
index bfbaff8..f7e2751 100644
--- a/src/type/sampled_texture_type_test.cc
+++ b/src/type/sampled_texture_type_test.cc
@@ -39,7 +39,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/sampler_type_test.cc b/src/type/sampler_type_test.cc
index fb6ccdf..b39f675 100644
--- a/src/type/sampler_type_test.cc
+++ b/src/type/sampler_type_test.cc
@@ -45,7 +45,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_TRUE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc
index 4dee89c..6931059 100644
--- a/src/type/storage_texture_type_test.cc
+++ b/src/type/storage_texture_type_test.cc
@@ -41,7 +41,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_TRUE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/struct_type.cc b/src/type/struct_type.cc
index 37e7885..f35ff86 100644
--- a/src/type/struct_type.cc
+++ b/src/type/struct_type.cc
@@ -18,31 +18,31 @@
#include "src/program_builder.h"
-TINT_INSTANTIATE_TYPEINFO(tint::type::Struct);
+TINT_INSTANTIATE_TYPEINFO(tint::type::StructType);
namespace tint {
namespace type {
-Struct::Struct(const Symbol& sym, ast::Struct* impl)
+StructType::StructType(const Symbol& sym, ast::Struct* impl)
: symbol_(sym), struct_(impl) {}
-Struct::Struct(Struct&&) = default;
+StructType::StructType(StructType&&) = default;
-Struct::~Struct() = default;
+StructType::~StructType() = default;
-std::string Struct::type_name() const {
+std::string StructType::type_name() const {
return "__struct_" + symbol_.to_str();
}
-std::string Struct::FriendlyName(const SymbolTable& symbols) const {
+std::string StructType::FriendlyName(const SymbolTable& symbols) const {
return symbols.NameFor(symbol_);
}
-Struct* Struct::Clone(CloneContext* ctx) const {
+StructType* StructType::Clone(CloneContext* ctx) const {
// Clone arguments outside of create() call to have deterministic ordering
auto sym = ctx->Clone(symbol());
auto* str = ctx->Clone(impl());
- return ctx->dst->create<Struct>(sym, str);
+ return ctx->dst->create<StructType>(sym, str);
}
} // namespace type
diff --git a/src/type/struct_type.h b/src/type/struct_type.h
index 9a94877..4d9d8d2 100644
--- a/src/type/struct_type.h
+++ b/src/type/struct_type.h
@@ -24,15 +24,15 @@
namespace type {
/// A structure type
-class Struct : public Castable<Struct, Type> {
+class StructType : public Castable<StructType, Type> {
public:
/// Constructor
/// @param sym the symbol representing the struct
/// @param impl the struct data
- Struct(const Symbol& sym, ast::Struct* impl);
+ StructType(const Symbol& sym, ast::Struct* impl);
/// Move constructor
- Struct(Struct&&);
- ~Struct() override;
+ StructType(StructType&&);
+ ~StructType() override;
/// @returns the struct symbol
const Symbol& symbol() const { return symbol_; }
@@ -54,7 +54,7 @@
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
/// @param ctx the clone context
/// @return the newly cloned type
- Struct* Clone(CloneContext* ctx) const override;
+ StructType* Clone(CloneContext* ctx) const override;
private:
Symbol const symbol_;
diff --git a/src/type/struct_type_test.cc b/src/type/struct_type_test.cc
index c90bf48..34cafbf 100644
--- a/src/type/struct_type_test.cc
+++ b/src/type/struct_type_test.cc
@@ -44,7 +44,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_TRUE(ty->Is<Struct>());
+ EXPECT_TRUE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/u32_type_test.cc b/src/type/u32_type_test.cc
index af3752d..d2e4597 100644
--- a/src/type/u32_type_test.cc
+++ b/src/type/u32_type_test.cc
@@ -34,7 +34,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_TRUE(ty->Is<U32>());
EXPECT_FALSE(ty->Is<Vector>());
diff --git a/src/type/vector_type_test.cc b/src/type/vector_type_test.cc
index ab0cf3c..8b12cc3 100644
--- a/src/type/vector_type_test.cc
+++ b/src/type/vector_type_test.cc
@@ -42,7 +42,7 @@
EXPECT_FALSE(ty->Is<Matrix>());
EXPECT_FALSE(ty->Is<Pointer>());
EXPECT_FALSE(ty->Is<Sampler>());
- EXPECT_FALSE(ty->Is<Struct>());
+ EXPECT_FALSE(ty->Is<StructType>());
EXPECT_FALSE(ty->Is<Texture>());
EXPECT_FALSE(ty->Is<U32>());
EXPECT_TRUE(ty->Is<Vector>());
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index f4741ce..b3f7de0 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -207,7 +207,7 @@
if (auto* alias = ty->As<type::Alias>()) {
// HLSL typedef is for intrinsic types only. For an alias'd struct,
// generate a secondary struct with the new name.
- if (auto* str = alias->type()->As<type::Struct>()) {
+ if (auto* str = alias->type()->As<type::StructType>()) {
if (!EmitStructType(out, str,
builder_.Symbols().NameFor(alias->symbol()))) {
return false;
@@ -220,7 +220,7 @@
}
out << " " << builder_.Symbols().NameFor(alias->symbol()) << ";"
<< std::endl;
- } else if (auto* str = ty->As<type::Struct>()) {
+ } else if (auto* str = ty->As<type::StructType>()) {
if (!EmitStructType(out, str, builder_.Symbols().NameFor(str->symbol()))) {
return false;
}
@@ -1317,7 +1317,7 @@
bool brackets = expr->type()
->UnwrapAliasIfNeeded()
- ->IsAnyOf<type::ArrayType, type::Struct>();
+ ->IsAnyOf<type::ArrayType, type::StructType>();
if (brackets) {
out << "{";
@@ -1708,7 +1708,7 @@
}
auto* type = var->Type()->UnwrapIfNeeded();
- if (auto* strct = type->As<type::Struct>()) {
+ if (auto* strct = type->As<type::StructType>()) {
out << "ConstantBuffer<" << builder_.Symbols().NameFor(strct->symbol())
<< "> " << builder_.Symbols().NameFor(decl->symbol())
<< RegisterAndSpace('b', binding_point) << ";" << std::endl;
@@ -2030,7 +2030,7 @@
for (auto* var : func->params()) {
auto* sem = builder_.Sem().Get(var);
auto* type = sem->Type();
- if (!type->Is<type::Struct>()) {
+ if (!type->Is<type::StructType>()) {
TINT_ICE(diagnostics_) << "Unsupported non-struct entry point parameter";
}
@@ -2132,7 +2132,7 @@
return false;
}
}
- } else if (auto* str = type->As<type::Struct>()) {
+ } else if (auto* str = type->As<type::StructType>()) {
out << "{";
bool first = true;
for (auto* member : str->impl()->members()) {
@@ -2449,7 +2449,7 @@
out << "Comparison";
}
out << "State";
- } else if (auto* str = type->As<type::Struct>()) {
+ } else if (auto* str = type->As<type::StructType>()) {
out << builder_.Symbols().NameFor(str->symbol());
} else if (auto* tex = type->As<type::Texture>()) {
auto* storage = tex->As<type::StorageTexture>();
@@ -2539,7 +2539,7 @@
}
bool GeneratorImpl::EmitStructType(std::ostream& out,
- const type::Struct* str,
+ const type::StructType* str,
const std::string& name) {
auto* sem_str = builder_.Sem().Get(str);
diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h
index 4c8a186..4e5410a 100644
--- a/src/writer/hlsl/generator_impl.h
+++ b/src/writer/hlsl/generator_impl.h
@@ -299,7 +299,7 @@
/// @param name the struct name
/// @returns true if the struct is emitted
bool EmitStructType(std::ostream& out,
- const type::Struct* ty,
+ const type::StructType* ty,
const std::string& name);
/// Handles a unary op expression
/// @param pre the preamble for the expression stream
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index 30016a5..1c3474b 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -155,7 +155,7 @@
}
out_ << " " << program_->Symbols().NameFor(alias->symbol()) << ";"
<< std::endl;
- } else if (auto* str = ty->As<type::Struct>()) {
+ } else if (auto* str = ty->As<type::StructType>()) {
if (!EmitStructType(str)) {
return false;
}
@@ -886,7 +886,7 @@
}
bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) {
- if (expr->type()->IsAnyOf<type::ArrayType, type::Struct>()) {
+ if (expr->type()->IsAnyOf<type::ArrayType, type::StructType>()) {
out_ << "{";
} else {
if (!EmitType(expr->type(), "")) {
@@ -915,7 +915,7 @@
}
}
- if (expr->type()->IsAnyOf<type::ArrayType, type::Struct>()) {
+ if (expr->type()->IsAnyOf<type::ArrayType, type::StructType>()) {
out_ << "}";
} else {
out_ << ")";
@@ -942,7 +942,7 @@
return false;
}
out_ << "}";
- } else if (type->As<type::Struct>()) {
+ } else if (type->As<type::StructType>()) {
out_ << "{}";
} else {
diagnostics_.add_error("Invalid type for zero emission: " +
@@ -1429,7 +1429,7 @@
out_ << " " << program_->Symbols().NameFor(var->symbol());
- if (type->Is<type::Struct>()) {
+ if (type->Is<type::StructType>()) {
out_ << " [[stage_in]]";
} else {
auto& decos = var->decorations();
@@ -1947,7 +1947,7 @@
out_ << "*";
} else if (type->Is<type::Sampler>()) {
out_ << "sampler";
- } else if (auto* str = type->As<type::Struct>()) {
+ } else if (auto* str = type->As<type::StructType>()) {
// The struct type emits as just the name. The declaration would be emitted
// as part of emitting the constructed types.
out_ << program_->Symbols().NameFor(str->symbol());
@@ -2042,7 +2042,7 @@
return EmitType(type, name);
}
-bool GeneratorImpl::EmitStructType(const type::Struct* str) {
+bool GeneratorImpl::EmitStructType(const type::StructType* str) {
// TODO(dsinclair): Block decoration?
// if (str->impl()->decoration() != ast::Decoration::kNone) {
// }
@@ -2345,7 +2345,7 @@
return SizeAndAlign{el_size_align.size * num_els, el_size_align.align};
}
- if (auto* str = ty->As<type::Struct>()) {
+ if (auto* str = ty->As<type::StructType>()) {
// TODO(crbug.com/tint/650): There's an assumption here that MSL's default
// structure size and alignment matches WGSL's. We need to confirm this.
auto* sem = program_->Sem().Get(str);
diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h
index a9ddb63..c576476 100644
--- a/src/writer/msl/generator_impl.h
+++ b/src/writer/msl/generator_impl.h
@@ -206,7 +206,7 @@
/// Handles generating a struct declaration
/// @param str the struct to generate
/// @returns true if the struct is emitted
- bool EmitStructType(const type::Struct* str);
+ bool EmitStructType(const type::StructType* str);
/// Handles emitting a type constructor
/// @param expr the type constructor expression
/// @returns true if the constructor is emitted
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 3d955f8..a78dad2 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -864,8 +864,8 @@
// If the data_type is a structure we're accessing a member, if it's a
// vector we're accessing a swizzle.
- if (data_type->Is<type::Struct>()) {
- auto* strct = data_type->As<type::Struct>()->impl();
+ if (data_type->Is<type::StructType>()) {
+ auto* strct = data_type->As<type::StructType>()->impl();
auto symbol = expr->member()->symbol();
uint32_t idx = 0;
@@ -1252,7 +1252,7 @@
subtype = mat->type()->UnwrapAll();
} else if (auto* arr = subtype->As<type::ArrayType>()) {
subtype = arr->type()->UnwrapAll();
- } else if (auto* str = subtype->As<type::Struct>()) {
+ } else if (auto* str = subtype->As<type::StructType>()) {
subtype = str->impl()->members()[i]->type()->UnwrapAll();
}
if (subtype != TypeOf(sc)->UnwrapAll()) {
@@ -1329,7 +1329,8 @@
// 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::ArrayType>() || result_type->Is<type::Struct>()) {
+ result_type->Is<type::ArrayType>() ||
+ result_type->Is<type::StructType>()) {
out << "_" << id;
ops.push_back(Operand::Int(id));
@@ -1980,14 +1981,14 @@
params.push_back(Operand::Int(struct_id));
auto* type = TypeOf(accessor->structure())->UnwrapAll();
- if (!type->Is<type::Struct>()) {
+ if (!type->Is<type::StructType>()) {
error_ =
"invalid type (" + type->type_name() + ") for runtime array length";
return 0;
}
// Runtime array must be the last member in the structure
- params.push_back(Operand::Int(
- uint32_t(type->As<type::Struct>()->impl()->members().size() - 1)));
+ params.push_back(Operand::Int(uint32_t(
+ type->As<type::StructType>()->impl()->members().size() - 1)));
if (!push_function_inst(spv::Op::OpArrayLength, params)) {
return 0;
@@ -2934,7 +2935,7 @@
return GenerateTypeIfNeeded(alias->type());
}
if (auto* ac = type->As<type::AccessControl>()) {
- if (!ac->type()->UnwrapIfNeeded()->Is<type::Struct>()) {
+ if (!ac->type()->UnwrapIfNeeded()->Is<type::StructType>()) {
return GenerateTypeIfNeeded(ac->type());
}
}
@@ -2949,8 +2950,8 @@
if (auto* ac = type->As<type::AccessControl>()) {
// The non-struct case was handled above.
auto* subtype = ac->type()->UnwrapIfNeeded();
- if (!GenerateStructType(subtype->As<type::Struct>(), ac->access_control(),
- result)) {
+ if (!GenerateStructType(subtype->As<type::StructType>(),
+ ac->access_control(), result)) {
return 0;
}
} else if (auto* arr = type->As<type::ArrayType>()) {
@@ -2971,7 +2972,7 @@
if (!GeneratePointerType(ptr, result)) {
return 0;
}
- } else if (auto* str = type->As<type::Struct>()) {
+ } else if (auto* str = type->As<type::StructType>()) {
if (!GenerateStructType(str, ast::AccessControl::kReadWrite, result)) {
return 0;
}
@@ -3144,7 +3145,7 @@
return true;
}
-bool Builder::GenerateStructType(type::Struct* struct_type,
+bool Builder::GenerateStructType(type::StructType* struct_type,
ast::AccessControl access_control,
const Operand& result) {
auto struct_id = result.to_i();
diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h
index d70280b..f45918d 100644
--- a/src/writer/spirv/builder.h
+++ b/src/writer/spirv/builder.h
@@ -449,7 +449,7 @@
/// @param access_control the access controls to assign to the struct
/// @param result the result operand
/// @returns true if the vector was successfully generated
- bool GenerateStructType(type::Struct* struct_type,
+ bool GenerateStructType(type::StructType* struct_type,
ast::AccessControl access_control,
const Operand& result);
/// Generates a struct member
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index eeb9fc6..3aeafe4 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -123,7 +123,7 @@
return false;
}
out_ << ";" << std::endl;
- } else if (auto* str = ty->As<type::Struct>()) {
+ } else if (auto* str = ty->As<type::StructType>()) {
if (!EmitStructType(str)) {
return false;
}
@@ -430,7 +430,7 @@
if (sampler->IsComparison()) {
out_ << "_comparison";
}
- } else if (auto* str = type->As<type::Struct>()) {
+ } else if (auto* str = type->As<type::StructType>()) {
// The struct, as a type, is just the name. We should have already emitted
// the declaration through a call to |EmitStructType| earlier.
out_ << program_->Symbols().NameFor(str->symbol());
@@ -511,7 +511,7 @@
return true;
}
-bool GeneratorImpl::EmitStructType(const type::Struct* str) {
+bool GeneratorImpl::EmitStructType(const type::StructType* str) {
auto* impl = str->impl();
for (auto* deco : impl->decorations()) {
out_ << "[[";
diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h
index 785c4cb..984bba3 100644
--- a/src/writer/wgsl/generator_impl.h
+++ b/src/writer/wgsl/generator_impl.h
@@ -176,7 +176,7 @@
/// Handles generating a struct declaration
/// @param str the struct
/// @returns true if the struct is emitted
- bool EmitStructType(const type::Struct* str);
+ bool EmitStructType(const type::StructType* str);
/// Handles emitting an image format
/// @param fmt the format to generate
/// @returns true if the format is emitted