ast: Remove Struct constructors that don't take a Source

And swap the `decorations` and `members` parameters, as decorations come last for other constructors.

Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9b814c1de24b6c987f0fbb9e6f92da7c352caa2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35163
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-12-12 12:52:44 +00:00 committed by Commit Bot service account
parent 4543d1a232
commit bcf37549c8
33 changed files with 390 additions and 286 deletions

View File

@ -23,23 +23,12 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::Struct);
namespace tint { namespace tint {
namespace ast { namespace ast {
Struct::Struct(StructMemberList members)
: Base(), members_(std::move(members)) {}
Struct::Struct(StructDecorationList decorations, StructMemberList members)
: Base(),
decorations_(std::move(decorations)),
members_(std::move(members)) {}
Struct::Struct(const Source& source, StructMemberList members)
: Base(source), members_(std::move(members)) {}
Struct::Struct(const Source& source, Struct::Struct(const Source& source,
StructDecorationList decorations, StructMemberList members,
StructMemberList members) StructDecorationList decorations)
: Base(source), : Base(source),
decorations_(std::move(decorations)), members_(std::move(members)),
members_(std::move(members)) {} decorations_(std::move(decorations)) {}
Struct::Struct(Struct&&) = default; Struct::Struct(Struct&&) = default;
@ -64,8 +53,8 @@ bool Struct::IsBlockDecorated() const {
} }
Struct* Struct::Clone(CloneContext* ctx) const { Struct* Struct::Clone(CloneContext* ctx) const {
return ctx->mod->create<Struct>( return ctx->mod->create<Struct>(ctx->Clone(source()), ctx->Clone(members_),
ctx->Clone(source()), ctx->Clone(decorations_), ctx->Clone(members_)); ctx->Clone(decorations_));
} }
bool Struct::IsValid() const { bool Struct::IsValid() const {

View File

@ -29,24 +29,13 @@ namespace ast {
/// A struct statement. /// A struct statement.
class Struct : public Castable<Struct, Node> { class Struct : public Castable<Struct, Node> {
public: public:
/// Create a new struct statement
/// @param members The struct members
explicit Struct(StructMemberList members);
/// Create a new struct statement
/// @param decorations The struct decorations
/// @param members The struct members
Struct(StructDecorationList decorations, StructMemberList members);
/// Create a new struct statement /// Create a new struct statement
/// @param source The input source for the import statement /// @param source The input source for the import statement
/// @param members The struct members /// @param members The struct members
Struct(const Source& source, StructMemberList members);
/// Create a new struct statement
/// @param source The input source for the import statement
/// @param decorations The struct decorations /// @param decorations The struct decorations
/// @param members The struct members
Struct(const Source& source, Struct(const Source& source,
StructDecorationList decorations, StructMemberList members,
StructMemberList members); StructDecorationList decorations);
/// Move constructor /// Move constructor
Struct(Struct&&); Struct(Struct&&);
@ -85,8 +74,8 @@ class Struct : public Castable<Struct, Node> {
private: private:
Struct(const Struct&) = delete; Struct(const Struct&) = delete;
StructDecorationList decorations_;
StructMemberList members_; StructMemberList members_;
StructDecorationList decorations_;
}; };
} // namespace ast } // namespace ast

View File

@ -35,7 +35,7 @@ TEST_F(StructTest, Creation) {
members.push_back( members.push_back(
create<StructMember>(Source{}, "a", &i32, StructMemberDecorationList())); create<StructMember>(Source{}, "a", &i32, StructMemberDecorationList()));
Struct s{members}; Struct s{Source{}, members, ast::StructDecorationList{}};
EXPECT_EQ(s.members().size(), 1u); EXPECT_EQ(s.members().size(), 1u);
EXPECT_TRUE(s.decorations().empty()); EXPECT_TRUE(s.decorations().empty());
EXPECT_EQ(s.source().range.begin.line, 0u); EXPECT_EQ(s.source().range.begin.line, 0u);
@ -54,7 +54,7 @@ TEST_F(StructTest, Creation_WithDecorations) {
StructDecorationList decos; StructDecorationList decos;
decos.push_back(create<StructBlockDecoration>(Source{})); decos.push_back(create<StructBlockDecoration>(Source{}));
Struct s{decos, members}; Struct s{Source{}, members, decos};
EXPECT_EQ(s.members().size(), 1u); EXPECT_EQ(s.members().size(), 1u);
ASSERT_EQ(s.decorations().size(), 1u); ASSERT_EQ(s.decorations().size(), 1u);
EXPECT_TRUE(s.decorations()[0]->Is<StructBlockDecoration>()); EXPECT_TRUE(s.decorations()[0]->Is<StructBlockDecoration>());
@ -76,7 +76,7 @@ TEST_F(StructTest, CreationWithSourceAndDecorations) {
Struct s{ Struct s{
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}}, Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}},
decos, members}; members, decos};
EXPECT_EQ(s.members().size(), 1u); EXPECT_EQ(s.members().size(), 1u);
ASSERT_EQ(s.decorations().size(), 1u); ASSERT_EQ(s.decorations().size(), 1u);
EXPECT_TRUE(s.decorations()[0]->Is<StructBlockDecoration>()); EXPECT_TRUE(s.decorations()[0]->Is<StructBlockDecoration>());
@ -87,7 +87,7 @@ TEST_F(StructTest, CreationWithSourceAndDecorations) {
} }
TEST_F(StructTest, IsValid) { TEST_F(StructTest, IsValid) {
Struct s({}); Struct s(Source{}, StructMemberList{}, StructDecorationList{});
EXPECT_TRUE(s.IsValid()); EXPECT_TRUE(s.IsValid());
} }
@ -99,7 +99,7 @@ TEST_F(StructTest, IsValid_Null_StructMember) {
create<StructMember>(Source{}, "a", &i32, StructMemberDecorationList())); create<StructMember>(Source{}, "a", &i32, StructMemberDecorationList()));
members.push_back(nullptr); members.push_back(nullptr);
Struct s{members}; Struct s{Source{}, members, ast::StructDecorationList{}};
EXPECT_FALSE(s.IsValid()); EXPECT_FALSE(s.IsValid());
} }
@ -110,7 +110,7 @@ TEST_F(StructTest, IsValid_Invalid_StructMember) {
members.push_back( members.push_back(
create<StructMember>(Source{}, "", &i32, StructMemberDecorationList())); create<StructMember>(Source{}, "", &i32, StructMemberDecorationList()));
Struct s{members}; Struct s{Source{}, members, ast::StructDecorationList{}};
EXPECT_FALSE(s.IsValid()); EXPECT_FALSE(s.IsValid());
} }
@ -124,7 +124,7 @@ TEST_F(StructTest, ToStr) {
StructDecorationList decos; StructDecorationList decos;
decos.push_back(create<StructBlockDecoration>(Source{})); decos.push_back(create<StructBlockDecoration>(Source{}));
Struct s{decos, members}; Struct s{Source{}, members, decos};
std::ostringstream out; std::ostringstream out;
s.to_str(out, 2); s.to_str(out, 2);

View File

@ -134,7 +134,7 @@ TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@ -179,7 +179,7 @@ TEST_F(AccessControlTest, BaseAlignmentStruct) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));

View File

@ -207,7 +207,7 @@ TEST_F(AliasTest, MinBufferBindingSizeStruct) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type}; Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type};
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@ -256,7 +256,7 @@ TEST_F(AliasTest, BaseAlignmentStruct) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type}; Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type};
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));

View File

@ -41,7 +41,8 @@ using StructTest = TestHelper;
TEST_F(StructTest, Creation) { TEST_F(StructTest, Creation) {
StructMemberList members; StructMemberList members;
auto* impl = create<ast::Struct>(members); auto* impl =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
auto* ptr = impl; auto* ptr = impl;
Struct s{"S", impl}; Struct s{"S", impl};
EXPECT_EQ(s.impl(), ptr); EXPECT_EQ(s.impl(), ptr);
@ -49,7 +50,8 @@ TEST_F(StructTest, Creation) {
TEST_F(StructTest, Is) { TEST_F(StructTest, Is) {
StructMemberList members; StructMemberList members;
auto* impl = create<ast::Struct>(members); auto* impl =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
Struct s{"S", impl}; Struct s{"S", impl};
Type* ty = &s; Type* ty = &s;
EXPECT_FALSE(ty->Is<AccessControl>()); EXPECT_FALSE(ty->Is<AccessControl>());
@ -69,7 +71,8 @@ TEST_F(StructTest, Is) {
TEST_F(StructTest, TypeName) { TEST_F(StructTest, TypeName) {
StructMemberList members; StructMemberList members;
auto* impl = create<ast::Struct>(members); auto* impl =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
Struct s{"my_struct", impl}; Struct s{"my_struct", impl};
EXPECT_EQ(s.type_name(), "__struct_my_struct"); EXPECT_EQ(s.type_name(), "__struct_my_struct");
} }
@ -90,7 +93,7 @@ TEST_F(StructTest, MinBufferBindingSize) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@ -120,7 +123,7 @@ TEST_F(StructTest, MinBufferBindingSizeArray) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(32u, EXPECT_EQ(32u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@ -151,7 +154,7 @@ TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(12u, EXPECT_EQ(12u,
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
@ -169,7 +172,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec2) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@ -188,7 +191,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec3) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@ -208,7 +211,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec4) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, EXPECT_EQ(16u,
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
@ -232,7 +235,7 @@ TEST_F(StructTest, BaseAlignment) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
@ -261,7 +264,7 @@ TEST_F(StructTest, BaseAlignmentArray) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
@ -290,7 +293,7 @@ TEST_F(StructTest, BaseAlignmentRuntimeArray) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
} }
@ -307,7 +310,7 @@ TEST_F(StructTest, BaseAlignmentVec2) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
@ -325,7 +328,7 @@ TEST_F(StructTest, BaseAlignmentVec3) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
@ -343,7 +346,7 @@ TEST_F(StructTest, BaseAlignmentVec4) {
} }
StructDecorationList decos; StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
Struct struct_type("struct_type", str); Struct struct_type("struct_type", str);
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));

View File

@ -308,7 +308,7 @@ class InspectorHelper {
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
} }
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
return std::make_unique<ast::type::Struct>(name, str); return std::make_unique<ast::type::Struct>(name, str);
} }
@ -1454,7 +1454,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
auto foo_type = std::make_unique<ast::type::Struct>("foo_type", str); auto foo_type = std::make_unique<ast::type::Struct>("foo_type", str);
AddUniformBuffer("foo_ub", foo_type.get(), 0, 0); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);

View File

@ -947,8 +947,8 @@ ast::type::Type* ParserImpl::ConvertType(
} }
// Now make the struct. // Now make the struct.
auto* ast_struct = create<ast::Struct>(std::move(ast_struct_decorations), auto* ast_struct = create<ast::Struct>(Source{}, std::move(ast_members),
std::move(ast_members)); std::move(ast_struct_decorations));
namer_.SuggestSanitizedName(type_id, "S"); namer_.SuggestSanitizedName(type_id, "S");

View File

@ -1192,8 +1192,8 @@ Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
return Failure::kErrored; return Failure::kErrored;
return std::make_unique<ast::type::Struct>( return std::make_unique<ast::type::Struct>(
name.value, create<ast::Struct>(source, std::move(struct_decos.value), name.value, create<ast::Struct>(source, std::move(body.value),
std::move(body.value))); std::move(struct_decos.value)));
} }
// struct_body_decl // struct_body_decl

View File

@ -93,7 +93,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(&block_deco); decos.push_back(&block_deco);
ast::Struct str(decos, members); ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str); ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]] S"); auto p = parser("my_var : [[access(read)]] S");
@ -119,7 +119,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(&block_deco); decos.push_back(&block_deco);
ast::Struct str(decos, members); ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str); ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read_write)]] S"); auto p = parser("my_var : [[access(read_write)]] S");
@ -145,7 +145,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(&block_deco); decos.push_back(&block_deco);
ast::Struct str(decos, members); ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str); ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read), access(read_write)]] S"); auto p = parser("my_var : [[access(read), access(read_write)]] S");
@ -168,7 +168,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(&block_deco); decos.push_back(&block_deco);
ast::Struct str(decos, members); ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str); ast::type::Struct s("S", &str);
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S"); auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
@ -207,7 +207,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(&block_deco); decos.push_back(&block_deco);
ast::Struct str(decos, members); ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str); ast::type::Struct s("S", &str);
auto p = parser("my_var : [[stride(1)]] S"); auto p = parser("my_var : [[stride(1)]] S");

View File

@ -225,7 +225,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
auto* struct_type = mod->create<ast::type::Struct>( auto* struct_type = mod->create<ast::type::Struct>(
kStructName, kStructName,
mod->create<ast::Struct>(std::move(decos), std::move(members))); mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
auto* idx_var = mod->create<ast::Variable>( auto* idx_var = mod->create<ast::Variable>(
Source{}, // source Source{}, // source

View File

@ -265,7 +265,7 @@ void VertexPulling::State::AddVertexStorageBuffers() {
auto* struct_type = mod->create<ast::type::Struct>( auto* struct_type = mod->create<ast::type::Struct>(
kStructName, kStructName,
mod->create<ast::Struct>(std::move(decos), std::move(members))); mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) { for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
// The decorated variable with struct type // The decorated variable with struct type

View File

@ -1215,7 +1215,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "second_member", &f32, decos)); create<ast::StructMember>(Source{}, "second_member", &f32, decos));
auto* strct = create<ast::Struct>(members); auto* strct =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct st("S", strct); ast::type::Struct st("S", strct);
@ -1258,7 +1259,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "second_member", &f32, decos)); create<ast::StructMember>(Source{}, "second_member", &f32, decos));
auto* strct = create<ast::Struct>(members); auto* strct =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
auto st = std::make_unique<ast::type::Struct>("alias", strct); auto st = std::make_unique<ast::type::Struct>("alias", strct);
ast::type::Alias alias(mod->RegisterSymbol("alias"), "alias", st.get()); ast::type::Alias alias(mod->RegisterSymbol("alias"), "alias", st.get());
@ -1387,7 +1389,8 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) {
ast::StructMemberList b_members; ast::StructMemberList b_members;
b_members.push_back(create<ast::StructMember>(Source{}, "foo", &vec4, decos)); b_members.push_back(create<ast::StructMember>(Source{}, "foo", &vec4, decos));
auto* strctB = create<ast::Struct>(b_members); auto* strctB =
create<ast::Struct>(Source{}, b_members, ast::StructDecorationList{});
ast::type::Struct stB("B", strctB); ast::type::Struct stB("B", strctB);
ast::type::Vector vecB(&stB, 3); ast::type::Vector vecB(&stB, 3);
@ -1395,7 +1398,8 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) {
ast::StructMemberList a_members; ast::StructMemberList a_members;
a_members.push_back(create<ast::StructMember>(Source{}, "mem", &vecB, decos)); a_members.push_back(create<ast::StructMember>(Source{}, "mem", &vecB, decos));
auto* strctA = create<ast::Struct>(a_members); auto* strctA =
create<ast::Struct>(Source{}, a_members, ast::StructDecorationList{});
ast::type::Struct stA("A", strctA); ast::type::Struct stA("A", strctA);

View File

@ -56,7 +56,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) {
} }
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members); auto* st = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct struct_type("Foo", st); ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type); mod()->AddConstructedType(&struct_type);
@ -82,7 +82,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
Source{Source::Location{12, 34}}, "rt", &arr, deco)); Source{Source::Location{12, 34}}, "rt", &arr, deco));
} }
ast::StructDecorationList decos; ast::StructDecorationList decos;
auto* st = create<ast::Struct>(decos, members); auto* st = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct struct_type("Foo", st); ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type); mod()->AddConstructedType(&struct_type);
@ -113,7 +113,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {
} }
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members); auto* st = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct struct_type("Foo", st); ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type); mod()->AddConstructedType(&struct_type);
@ -148,7 +148,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members); auto* st = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct struct_type("s", st); ast::type::Struct struct_type("s", st);
mod()->AddConstructedType(&struct_type); mod()->AddConstructedType(&struct_type);
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
@ -181,7 +181,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
} }
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members); auto* st = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct struct_type("s", st); ast::type::Struct struct_type("s", st);
mod()->AddConstructedType(&struct_type); mod()->AddConstructedType(&struct_type);
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types())); EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));

View File

@ -50,14 +50,17 @@ TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) {
ast::type::I32 i32; ast::type::I32 i32;
ast::type::F32 f32; ast::type::F32 f32;
auto* str = create<ast::Struct>(ast::StructMemberList{ auto* str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>(Source{}, "a", &f32, create<ast::StructMember>(Source{}, "a", &f32,
ast::StructMemberDecorationList{}), ast::StructMemberDecorationList{}),
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "b", &i32, Source{}, "b", &i32,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(4, Source{})}), create<ast::StructMemberOffsetDecoration>(4, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct s("A", str); ast::type::Struct s("A", str);
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);

View File

@ -355,7 +355,8 @@ TEST_F(HlslGeneratorImplTest_Function,
members.push_back(create<ast::StructMember>( members.push_back(create<ast::StructMember>(
Source{}, "coord", &vec4, ast::StructMemberDecorationList{})); Source{}, "coord", &vec4, ast::StructMemberDecorationList{}));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Uniforms", str); ast::type::Struct s("Uniforms", str);
@ -439,7 +440,8 @@ TEST_F(HlslGeneratorImplTest_Function,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
@ -514,7 +516,8 @@ TEST_F(HlslGeneratorImplTest_Function,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
@ -589,7 +592,8 @@ TEST_F(HlslGeneratorImplTest_Function,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
@ -1365,7 +1369,7 @@ TEST_F(HlslGeneratorImplTest_Function,
ast::StructDecorationList s_decos; ast::StructDecorationList s_decos;
s_decos.push_back(create<ast::StructBlockDecoration>(Source{})); s_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(s_decos, members); auto* str = create<ast::Struct>(Source{}, members, s_decos);
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);

View File

@ -53,7 +53,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{})); deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "mem", &f32, deco)); members.push_back(create<ast::StructMember>(Source{}, "mem", &f32, deco));
auto* strct = create<ast::Struct>(members); auto* strct =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Str", strct); ast::type::Struct s("Str", strct);
@ -104,7 +105,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -157,7 +159,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -204,7 +207,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::I32 i32; ast::type::I32 i32;
ast::type::Matrix mat(&f32, 3, 2); ast::type::Matrix mat(&f32, 3, 2);
auto* str = create<ast::Struct>(ast::StructMemberList{ auto* str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "z", &i32, Source{}, "z", &i32,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -213,7 +218,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
Source{}, "a", &mat, Source{}, "a", &mat,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(4, Source{})}), create<ast::StructMemberOffsetDecoration>(4, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -289,7 +295,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -353,7 +360,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -413,7 +421,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -465,7 +474,8 @@ TEST_F(
deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{})); deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &mat, deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &mat, deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -521,7 +531,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(16, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(16, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &mat, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -581,7 +592,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
a_deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{})); a_deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &ary, a_deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &ary, a_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -637,7 +649,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
a_deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{})); a_deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &ary, a_deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &ary, a_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -703,7 +716,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -760,7 +774,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
a_deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{})); a_deco.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "a", &ary, a_deco)); members.push_back(create<ast::StructMember>(Source{}, "a", &ary, a_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -822,7 +837,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -882,7 +898,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(16, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(16, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &fvec3, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &fvec3, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -938,7 +955,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(16, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(16, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &fvec3, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &fvec3, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
@ -1002,7 +1020,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Vector ivec3(&i32, 3); ast::type::Vector ivec3(&i32, 3);
ast::type::Vector fvec3(&f32, 3); ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>(ast::StructMemberList{ auto* data_str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "a", &ivec3, Source{}, "a", &ivec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -1011,7 +1031,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
Source{}, "b", &fvec3, Source{}, "b", &fvec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(16, Source{})}), create<ast::StructMemberOffsetDecoration>(16, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct data("Data", data_str); ast::type::Struct data("Data", data_str);
@ -1020,12 +1041,15 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
create<ast::StrideDecoration>(32, Source{}), create<ast::StrideDecoration>(32, Source{}),
}); });
auto* pre_str = create<ast::Struct>(ast::StructMemberList{ auto* pre_str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "c", &ary, Source{}, "c", &ary,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})}), create<ast::StructMemberOffsetDecoration>(0, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct pre_struct("Pre", pre_str); ast::type::Struct pre_struct("Pre", pre_str);
@ -1087,7 +1111,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::StructMemberList members; ast::StructMemberList members;
ast::StructMemberDecorationList deco; ast::StructMemberDecorationList deco;
auto* data_str = create<ast::Struct>(ast::StructMemberList{ auto* data_str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "a", &ivec3, Source{}, "a", &ivec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -1096,7 +1122,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
Source{}, "b", &fvec3, Source{}, "b", &fvec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(16, Source{})}), create<ast::StructMemberOffsetDecoration>(16, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct data("Data", data_str); ast::type::Struct data("Data", data_str);
@ -1104,11 +1131,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
&data, 4, &data, 4,
ast::ArrayDecorationList{create<ast::StrideDecoration>(32, Source{})}); ast::ArrayDecorationList{create<ast::StrideDecoration>(32, Source{})});
auto* pre_str = auto* pre_str = create<ast::Struct>(
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>( Source{},
ast::StructMemberList{create<ast::StructMember>(
Source{}, "c", &ary, Source{}, "c", &ary,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})}); create<ast::StructMemberOffsetDecoration>(0, Source{})})},
ast::StructDecorationList{});
ast::type::Struct pre_struct("Pre", pre_str); ast::type::Struct pre_struct("Pre", pre_str);
@ -1172,7 +1201,9 @@ TEST_F(
ast::type::Vector ivec3(&i32, 3); ast::type::Vector ivec3(&i32, 3);
ast::type::Vector fvec3(&f32, 3); ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>(ast::StructMemberList{ auto* data_str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "a", &ivec3, Source{}, "a", &ivec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -1181,7 +1212,8 @@ TEST_F(
Source{}, "b", &fvec3, Source{}, "b", &fvec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(16, Source{})}), create<ast::StructMemberOffsetDecoration>(16, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct data("Data", data_str); ast::type::Struct data("Data", data_str);
@ -1190,11 +1222,13 @@ TEST_F(
create<ast::StrideDecoration>(32, Source{}), create<ast::StrideDecoration>(32, Source{}),
}); });
auto* pre_str = auto* pre_str = create<ast::Struct>(
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>( Source{},
ast::StructMemberList{create<ast::StructMember>(
Source{}, "c", &ary, Source{}, "c", &ary,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})}); create<ast::StructMemberOffsetDecoration>(0, Source{})})},
ast::StructDecorationList{});
ast::type::Struct pre_struct("Pre", pre_str); ast::type::Struct pre_struct("Pre", pre_str);
@ -1257,7 +1291,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Vector ivec3(&i32, 3); ast::type::Vector ivec3(&i32, 3);
ast::type::Vector fvec3(&f32, 3); ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>(ast::StructMemberList{ auto* data_str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "a", &ivec3, Source{}, "a", &ivec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -1266,7 +1302,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
Source{}, "b", &fvec3, Source{}, "b", &fvec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(16, Source{})}), create<ast::StructMemberOffsetDecoration>(16, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct data("Data", data_str); ast::type::Struct data("Data", data_str);
@ -1275,11 +1312,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
create<ast::StrideDecoration>(32, Source{}), create<ast::StrideDecoration>(32, Source{}),
}); });
auto* pre_str = auto* pre_str = create<ast::Struct>(
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>( Source{},
ast::StructMemberList{create<ast::StructMember>(
Source{}, "c", &ary, Source{}, "c", &ary,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})}); create<ast::StructMemberOffsetDecoration>(0, Source{})})},
ast::StructDecorationList{});
ast::type::Struct pre_struct("Pre", pre_str); ast::type::Struct pre_struct("Pre", pre_str);
@ -1342,7 +1381,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Vector ivec3(&i32, 3); ast::type::Vector ivec3(&i32, 3);
ast::type::Vector fvec3(&f32, 3); ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>(ast::StructMemberList{ auto* data_str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "a", &ivec3, Source{}, "a", &ivec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -1351,7 +1392,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
Source{}, "b", &fvec3, Source{}, "b", &fvec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(16, Source{})}), create<ast::StructMemberOffsetDecoration>(16, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct data("Data", data_str); ast::type::Struct data("Data", data_str);
@ -1360,11 +1402,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
create<ast::StrideDecoration>(32, Source{}), create<ast::StrideDecoration>(32, Source{}),
}); });
auto* pre_str = auto* pre_str = create<ast::Struct>(
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>( Source{},
ast::StructMemberList{create<ast::StructMember>(
Source{}, "c", &ary, Source{}, "c", &ary,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})}); create<ast::StructMemberOffsetDecoration>(0, Source{})})},
ast::StructDecorationList{});
ast::type::Struct pre_struct("Pre", pre_str); ast::type::Struct pre_struct("Pre", pre_str);
@ -1437,7 +1481,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Vector ivec3(&i32, 3); ast::type::Vector ivec3(&i32, 3);
ast::type::Vector fvec3(&f32, 3); ast::type::Vector fvec3(&f32, 3);
auto* data_str = create<ast::Struct>(ast::StructMemberList{ auto* data_str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "a", &ivec3, Source{}, "a", &ivec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -1446,7 +1492,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
Source{}, "b", &fvec3, Source{}, "b", &fvec3,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(16, Source{})}), create<ast::StructMemberOffsetDecoration>(16, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct data("Data", data_str); ast::type::Struct data("Data", data_str);
@ -1455,11 +1502,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
create<ast::StrideDecoration>(32, Source{}), create<ast::StrideDecoration>(32, Source{}),
}); });
auto* pre_str = auto* pre_str = create<ast::Struct>(
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>( Source{},
ast::StructMemberList{create<ast::StructMember>(
Source{}, "c", &ary, Source{}, "c", &ary,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(0, Source{})})}); create<ast::StructMemberOffsetDecoration>(0, Source{})})},
ast::StructDecorationList{});
ast::type::Struct pre_struct("Pre", pre_str); ast::type::Struct pre_struct("Pre", pre_str);

View File

@ -181,7 +181,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -205,7 +206,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -229,7 +231,8 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) {
decos.push_back(create<ast::StructMemberOffsetDecoration>(128, Source{})); decos.push_back(create<ast::StructMemberOffsetDecoration>(128, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "c", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "c", &f32, decos));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -255,7 +258,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
ast::StructMemberDecorationList b_deco; ast::StructMemberDecorationList b_deco;
members.push_back(create<ast::StructMember>(Source{}, "float", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "float", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -283,7 +287,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct s("S", str); ast::type::Struct s("S", str);

View File

@ -61,7 +61,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("a", str); ast::type::Struct s("a", str);
@ -85,7 +86,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("b", str); ast::type::Struct s("b", str);
ast::type::Alias alias(mod.RegisterSymbol("a"), "a", &s); ast::type::Alias alias(mod.RegisterSymbol("a"), "a", &s);

View File

@ -371,7 +371,8 @@ TEST_F(MslGeneratorImplTest,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
@ -455,7 +456,8 @@ TEST_F(MslGeneratorImplTest,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
@ -968,7 +970,8 @@ TEST_F(MslGeneratorImplTest,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
@ -1082,7 +1085,8 @@ TEST_F(MslGeneratorImplTest,
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
@ -1341,7 +1345,7 @@ TEST_F(MslGeneratorImplTest,
ast::StructDecorationList s_decos; ast::StructDecorationList s_decos;
s_decos.push_back(create<ast::StructBlockDecoration>(Source{})); s_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(s_decos, members); auto* str = create<ast::Struct>(Source{}, members, s_decos);
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);

View File

@ -171,7 +171,8 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) {
decos.push_back(create<ast::StructMemberOffsetDecoration>(128, Source{})); decos.push_back(create<ast::StructMemberOffsetDecoration>(128, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "c", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "c", &f32, decos));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -195,7 +196,8 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) {
decos.push_back(create<ast::StructMemberOffsetDecoration>(32, Source{})); decos.push_back(create<ast::StructMemberOffsetDecoration>(32, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "c", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "c", &f32, decos));
auto* inner_str = create<ast::Struct>(members); auto* inner_str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct inner_s("Inner", inner_str); ast::type::Struct inner_s("Inner", inner_str);
@ -208,7 +210,8 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) {
decos.push_back(create<ast::StructMemberOffsetDecoration>(64, Source{})); decos.push_back(create<ast::StructMemberOffsetDecoration>(64, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "f", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "f", &f32, decos));
auto* outer_str = create<ast::Struct>(members); auto* outer_str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct outer_s("Outer", outer_str); ast::type::Struct outer_s("Outer", outer_str);

View File

@ -182,7 +182,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -202,7 +203,8 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -218,7 +220,9 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) {
ast::type::I32 i32; ast::type::I32 i32;
ast::type::F32 f32; ast::type::F32 f32;
auto* str = create<ast::Struct>(ast::StructMemberList{ auto* str = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>( create<ast::StructMember>(
Source{}, "a", &i32, Source{}, "a", &i32,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
@ -231,7 +235,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) {
Source{}, "c", &f32, Source{}, "c", &f32,
ast::StructMemberDecorationList{ ast::StructMemberDecorationList{
create<ast::StructMemberOffsetDecoration>(128, Source{})}), create<ast::StructMemberOffsetDecoration>(128, Source{})}),
}); },
ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -258,7 +263,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) {
ast::StructMemberDecorationList b_deco; ast::StructMemberDecorationList b_deco;
members.push_back(create<ast::StructMember>(Source{}, "float", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "float", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -285,7 +291,7 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct s("S", str); ast::type::Struct s("S", str);

View File

@ -110,7 +110,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);

View File

@ -304,7 +304,7 @@ TEST_F(BuilderTest, MemberAccessor) {
members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
@ -360,13 +360,17 @@ TEST_F(BuilderTest, MemberAccessor_Nested) {
inner_members.push_back( inner_members.push_back(
create<ast::StructMember>(Source{}, "b", &f32, decos)); create<ast::StructMember>(Source{}, "b", &f32, decos));
ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members)); ast::type::Struct inner_struct(
"Inner", create<ast::Struct>(Source{}, inner_members,
ast::StructDecorationList{}));
ast::StructMemberList outer_members; ast::StructMemberList outer_members;
outer_members.push_back( outer_members.push_back(
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos)); create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members)); ast::type::Struct s_type("my_struct",
create<ast::Struct>(Source{}, outer_members,
ast::StructDecorationList{}));
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
false, nullptr, ast::VariableDecorationList{}); false, nullptr, ast::VariableDecorationList{});
@ -427,7 +431,9 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
inner_members.push_back( inner_members.push_back(
create<ast::StructMember>(Source{}, "b", &f32, decos)); create<ast::StructMember>(Source{}, "b", &f32, decos));
ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members)); ast::type::Struct inner_struct(
"Inner", create<ast::Struct>(Source{}, inner_members,
ast::StructDecorationList{}));
ast::type::Alias alias(mod->RegisterSymbol("Inner"), "Inner", &inner_struct); ast::type::Alias alias(mod->RegisterSymbol("Inner"), "Inner", &inner_struct);
@ -435,7 +441,9 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
outer_members.push_back( outer_members.push_back(
create<ast::StructMember>(Source{}, "inner", &alias, decos)); create<ast::StructMember>(Source{}, "inner", &alias, decos));
ast::type::Struct s_type("Outer", create<ast::Struct>(outer_members)); ast::type::Struct s_type("Outer",
create<ast::Struct>(Source{}, outer_members,
ast::StructDecorationList{}));
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
false, nullptr, ast::VariableDecorationList{}); false, nullptr, ast::VariableDecorationList{});
@ -496,13 +504,17 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) {
inner_members.push_back( inner_members.push_back(
create<ast::StructMember>(Source{}, "b", &f32, decos)); create<ast::StructMember>(Source{}, "b", &f32, decos));
ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members)); ast::type::Struct inner_struct(
"Inner", create<ast::Struct>(Source{}, inner_members,
ast::StructDecorationList{}));
ast::StructMemberList outer_members; ast::StructMemberList outer_members;
outer_members.push_back( outer_members.push_back(
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos)); create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members)); ast::type::Struct s_type("my_struct",
create<ast::Struct>(Source{}, outer_members,
ast::StructDecorationList{}));
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
false, nullptr, ast::VariableDecorationList{}); false, nullptr, ast::VariableDecorationList{});
@ -570,13 +582,17 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) {
inner_members.push_back( inner_members.push_back(
create<ast::StructMember>(Source{}, "b", &f32, decos)); create<ast::StructMember>(Source{}, "b", &f32, decos));
ast::type::Struct inner_struct("Inner", create<ast::Struct>(inner_members)); ast::type::Struct inner_struct(
"Inner", create<ast::Struct>(Source{}, inner_members,
ast::StructDecorationList{}));
ast::StructMemberList outer_members; ast::StructMemberList outer_members;
outer_members.push_back( outer_members.push_back(
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos)); create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members)); ast::type::Struct s_type("my_struct",
create<ast::Struct>(Source{}, outer_members,
ast::StructDecorationList{}));
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
false, nullptr, ast::VariableDecorationList{}); false, nullptr, ast::VariableDecorationList{});
@ -861,18 +877,24 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
ast::StructMemberDecorationList decos; ast::StructMemberDecorationList decos;
auto* s = create<ast::Struct>(ast::StructMemberList{ auto* s = create<ast::Struct>(Source{},
create<ast::StructMember>(Source{}, "baz", &vec3, decos)}); ast::StructMemberList{create<ast::StructMember>(
Source{}, "baz", &vec3, decos)},
ast::StructDecorationList{});
ast::type::Struct c_type("C", s); ast::type::Struct c_type("C", s);
s = create<ast::Struct>(ast::StructMemberList{ s = create<ast::Struct>(Source{},
create<ast::StructMember>(Source{}, "bar", &c_type, decos)}); ast::StructMemberList{create<ast::StructMember>(
Source{}, "bar", &c_type, decos)},
ast::StructDecorationList{});
ast::type::Struct b_type("B", s); ast::type::Struct b_type("B", s);
ast::type::Array b_ary_type(&b_type, 3, ast::ArrayDecorationList{}); ast::type::Array b_ary_type(&b_type, 3, ast::ArrayDecorationList{});
s = create<ast::Struct>(ast::StructMemberList{ s = create<ast::Struct>(Source{},
create<ast::StructMember>(Source{}, "foo", &b_ary_type, decos)}); ast::StructMemberList{create<ast::StructMember>(
Source{}, "foo", &b_ary_type, decos)},
ast::StructDecorationList{});
ast::type::Struct a_type("A", s); ast::type::Struct a_type("A", s);
ast::type::Array a_ary_type(&a_type, 2, ast::ArrayDecorationList{}); ast::type::Array a_ary_type(&a_type, 2, ast::ArrayDecorationList{});

View File

@ -234,7 +234,7 @@ TEST_F(BuilderTest, Assign_StructMember) {
members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type, ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type,

View File

@ -942,10 +942,13 @@ TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3) {
TEST_F(SpvBuilderConstructorTest, Type_Struct) { TEST_F(SpvBuilderConstructorTest, Type_Struct) {
ast::StructMemberDecorationList decos; ast::StructMemberDecorationList decos;
auto* s = create<ast::Struct>(ast::StructMemberList{ auto* s = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>(Source{}, "a", ty.f32, decos), create<ast::StructMember>(Source{}, "a", ty.f32, decos),
create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos), create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos),
}); },
ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto* t = Construct(&s_type, 2.0f, vec3<f32>(2.0f, 2.0f, 2.0f)); auto* t = Construct(&s_type, 2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
@ -1079,9 +1082,12 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Array) {
TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) { TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) {
ast::StructMemberDecorationList decos; ast::StructMemberDecorationList decos;
auto* s = create<ast::Struct>(ast::StructMemberList{ auto* s = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>(Source{}, "a", ty.f32, decos), create<ast::StructMember>(Source{}, "a", ty.f32, decos),
}); },
ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto* t = Construct(&s_type); auto* t = Construct(&s_type);
@ -1491,10 +1497,13 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_BitCastScalars) {
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) { TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) {
ast::StructMemberDecorationList decos; ast::StructMemberDecorationList decos;
auto* s = create<ast::Struct>(ast::StructMemberList{ auto* s = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>(Source{}, "a", ty.f32, decos), create<ast::StructMember>(Source{}, "a", ty.f32, decos),
create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos), create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos),
}); },
ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto* t = Construct(&s_type, 2.f, vec3<f32>(2.f, 2.f, 2.f)); auto* t = Construct(&s_type, 2.f, vec3<f32>(2.f, 2.f, 2.f));
@ -1508,10 +1517,13 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) {
TEST_F(SpvBuilderConstructorTest, TEST_F(SpvBuilderConstructorTest,
IsConstructorConst_Struct_WithIdentSubExpression) { IsConstructorConst_Struct_WithIdentSubExpression) {
ast::StructMemberDecorationList decos; ast::StructMemberDecorationList decos;
auto* s = create<ast::Struct>(ast::StructMemberList{ auto* s = create<ast::Struct>(
Source{},
ast::StructMemberList{
create<ast::StructMember>(Source{}, "a", ty.f32, decos), create<ast::StructMember>(Source{}, "a", ty.f32, decos),
create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos), create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos),
}); },
ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);

View File

@ -269,7 +269,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
ast::StructDecorationList s_decos; ast::StructDecorationList s_decos;
s_decos.push_back(create<ast::StructBlockDecoration>(Source{})); s_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(s_decos, members); auto* str = create<ast::Struct>(Source{}, members, s_decos);
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);

View File

@ -533,7 +533,8 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
members.push_back(create<ast::StructMember>(Source{}, "b", &i32, decos)); members.push_back(create<ast::StructMember>(Source{}, "b", &i32, decos));
ast::type::Struct A("A", create<ast::Struct>(members)); ast::type::Struct A(
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac, ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac,
@ -569,7 +570,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
ast::type::Struct A("A", create<ast::Struct>(members)); ast::type::Struct A(
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
ast::type::Alias B(mod->RegisterSymbol("B"), "B", &A); ast::type::Alias B(mod->RegisterSymbol("B"), "B", &A);
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B}; ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B};
@ -604,7 +606,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
ast::type::Struct A("A", create<ast::Struct>(members)); ast::type::Struct A(
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
ast::type::Alias B(mod->RegisterSymbol("B"), "B", &ac); ast::type::Alias B(mod->RegisterSymbol("B"), "B", &ac);
@ -639,7 +642,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
ast::type::Struct A("A", create<ast::Struct>(members)); ast::type::Struct A(
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A}; ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A};
ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A}; ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A};

View File

@ -1311,7 +1311,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos)); create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
@ -1353,7 +1353,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos)); create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
@ -1397,7 +1397,7 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos)); create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);

View File

@ -278,7 +278,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
} }
TEST_F(BuilderTest_Type, GenerateStruct_Empty) { TEST_F(BuilderTest_Type, GenerateStruct_Empty) {
auto* s = create<ast::Struct>(ast::StructMemberList{}); auto* s = create<ast::Struct>(Source{}, ast::StructMemberList{},
ast::StructDecorationList{});
ast::type::Struct s_type("S", s); ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type); auto id = b.GenerateTypeIfNeeded(&s_type);
@ -299,7 +300,7 @@ TEST_F(BuilderTest_Type, GenerateStruct) {
ast::StructMemberList members; ast::StructMemberList members;
members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto id = b.GenerateTypeIfNeeded(&s_type); auto id = b.GenerateTypeIfNeeded(&s_type);
@ -324,7 +325,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) {
ast::StructDecorationList struct_decos; ast::StructDecorationList struct_decos;
struct_decos.push_back(create<ast::StructBlockDecoration>(Source{})); struct_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* s = create<ast::Struct>(struct_decos, members); auto* s = create<ast::Struct>(Source{}, members, struct_decos);
ast::type::Struct s_type("my_struct", s); ast::type::Struct s_type("my_struct", s);
auto id = b.GenerateTypeIfNeeded(&s_type); auto id = b.GenerateTypeIfNeeded(&s_type);
@ -353,7 +354,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) {
members.push_back(create<ast::StructMember>(Source{}, "a", &f32, a_decos)); members.push_back(create<ast::StructMember>(Source{}, "a", &f32, a_decos));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_decos)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("S", s); ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type); auto id = b.GenerateTypeIfNeeded(&s_type);
@ -390,7 +391,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, empty_c)); create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, empty_c));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("S", s); ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type); auto id = b.GenerateTypeIfNeeded(&s_type);
@ -436,7 +437,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos)); create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("S", s); ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type); auto id = b.GenerateTypeIfNeeded(&s_type);
@ -503,7 +504,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) {
members.push_back( members.push_back(
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos)); create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos));
auto* s = create<ast::Struct>(members); auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s_type("S", s); ast::type::Struct s_type("S", s);
auto id = b.GenerateTypeIfNeeded(&s_type); auto id = b.GenerateTypeIfNeeded(&s_type);

View File

@ -51,7 +51,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("A", str); ast::type::Struct s("A", str);
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);
@ -79,7 +80,8 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &i32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("A", str); ast::type::Struct s("A", str);
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);

View File

@ -198,7 +198,7 @@ TEST_F(WgslGeneratorImplTest,
ast::StructDecorationList s_decos; ast::StructDecorationList s_decos;
s_decos.push_back(create<ast::StructBlockDecoration>(Source{})); s_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(s_decos, members); auto* str = create<ast::Struct>(Source{}, members, s_decos);
ast::type::Struct s("Data", str); ast::type::Struct s("Data", str);
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);

View File

@ -74,7 +74,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(&block_deco); decos.push_back(&block_deco);
ast::Struct str(decos, members); ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str); ast::type::Struct s("S", &str);
ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s); ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s);
@ -94,7 +94,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(&block_deco); decos.push_back(&block_deco);
ast::Struct str(decos, members); ast::Struct str(Source{}, members, decos);
ast::type::Struct s("S", &str); ast::type::Struct s("S", &str);
ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s); ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s);
@ -183,7 +183,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -203,7 +204,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) {
b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{})); b_deco.push_back(create<ast::StructMemberOffsetDecoration>(4, Source{}));
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco)); members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_deco));
auto* str = create<ast::Struct>(members); auto* str =
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
ast::type::Struct s("S", str); ast::type::Struct s("S", str);
@ -231,7 +233,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) {
ast::StructDecorationList decos; ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{})); decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* str = create<ast::Struct>(decos, members); auto* str = create<ast::Struct>(Source{}, members, decos);
ast::type::Struct s("S", str); ast::type::Struct s("S", str);