ast::type: Remove Array::set_decorations

Move to constructor

Bug: tint:390
Change-Id: If6c65b7305db7f9977c0cc9884a8f551e07de050
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35014
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2020-12-07 22:19:27 +00:00 committed by Commit Bot service account
parent dec971328d
commit 8b0ffe9185
32 changed files with 205 additions and 235 deletions

View File

@ -146,7 +146,7 @@ class TypesBuilder {
/// @param n the array size. 0 represents unbounded
/// @return the tint AST type for a array of size `n` of type `T`
type::Array* array(type::Type* subtype, uint32_t n) const {
return mod_->create<type::Array>(subtype, n);
return mod_->create<type::Array>(subtype, n, ArrayDecorationList{});
}
/// @return the tint AST type for an array of size `N` of type `T`

View File

@ -106,20 +106,16 @@ TEST_F(AccessControlTest, MinBufferBindingSizeU32) {
TEST_F(AccessControlTest, MinBufferBindingSizeArray) {
U32 u32;
Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 4,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
U32 u32;
Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 0,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
@ -153,20 +149,16 @@ TEST_F(AccessControlTest, BaseAlignmentU32) {
TEST_F(AccessControlTest, BaseAlignmentArray) {
U32 u32;
Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 4,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
}
TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
U32 u32;
Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 0,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
AccessControl at{ast::AccessControl::kReadOnly, &array};
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
}

View File

@ -169,20 +169,20 @@ TEST_F(AliasTest, MinBufferBindingSizeU32) {
TEST_F(AliasTest, MinBufferBindingSizeArray) {
U32 u32;
Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 4,
ArrayDecorationList{
create<StrideDecoration>(4, Source{}),
});
Alias alias{"alias", &array};
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
U32 u32;
Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 0,
ArrayDecorationList{
create<StrideDecoration>(4, Source{}),
});
Alias alias{"alias", &array};
EXPECT_EQ(4u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
@ -218,20 +218,20 @@ TEST_F(AliasTest, BaseAlignmentU32) {
TEST_F(AliasTest, BaseAlignmentArray) {
U32 u32;
Array array(&u32, 4);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 4,
ArrayDecorationList{
create<StrideDecoration>(4, Source{}),
});
Alias alias{"alias", &array};
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
}
TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
U32 u32;
Array array(&u32);
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
array.set_decorations(decos);
Array array(&u32, 0,
ArrayDecorationList{
create<StrideDecoration>(4, Source{}),
});
Alias alias{"alias", &array};
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
}

View File

@ -28,9 +28,8 @@ namespace tint {
namespace ast {
namespace type {
Array::Array(Type* subtype) : subtype_(subtype) {}
Array::Array(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) {}
Array::Array(Type* subtype, uint32_t size, ArrayDecorationList decorations)
: subtype_(subtype), size_(size), decos_(decorations) {}
Array::Array(Array&&) = default;
@ -98,9 +97,8 @@ std::string Array::type_name() const {
}
Array* Array::Clone(CloneContext* ctx) const {
auto cloned = std::make_unique<Array>(ctx->Clone(subtype_), size_);
cloned->set_decorations(ctx->Clone(decorations()));
return ctx->mod->unique_type(std::move(cloned));
return ctx->mod->create<Array>(ctx->Clone(subtype_), size_,
ctx->Clone(decorations()));
}
} // namespace type

View File

@ -30,13 +30,12 @@ namespace type {
/// An array type. If size is zero then it is a runtime array.
class Array : public Castable<Array, Type> {
public:
/// Constructor for runtime array
/// @param subtype the type of the array elements
explicit Array(Type* subtype);
/// Constructor
/// @param subtype the type of the array elements
/// @param size the number of elements in the array
Array(Type* subtype, uint32_t size);
/// @param size the number of elements in the array. `0` represents a
/// runtime-sized array.
/// @param decorations the array decorations
Array(Type* subtype, uint32_t size, ArrayDecorationList decorations);
/// Move constructor
Array(Array&&);
~Array() override;
@ -55,9 +54,6 @@ class Array : public Castable<Array, Type> {
/// 0 for non-host shareable types.
uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
/// Sets the array decorations
/// @param decos the decorations to set
void set_decorations(ArrayDecorationList decos) { decos_ = std::move(decos); }
/// @returns the array decorations
const ArrayDecorationList& decorations() const { return decos_; }

View File

@ -39,7 +39,7 @@ using ArrayTest = TestHelper;
TEST_F(ArrayTest, CreateSizedArray) {
U32 u32;
Array arr{&u32, 3};
Array arr{&u32, 3, ArrayDecorationList{}};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 3u);
EXPECT_TRUE(arr.Is<Array>());
@ -48,7 +48,7 @@ TEST_F(ArrayTest, CreateSizedArray) {
TEST_F(ArrayTest, CreateRuntimeArray) {
U32 u32;
Array arr{&u32};
Array arr{&u32, 0, ArrayDecorationList{}};
EXPECT_EQ(arr.type(), &u32);
EXPECT_EQ(arr.size(), 0u);
EXPECT_TRUE(arr.Is<Array>());
@ -58,7 +58,7 @@ TEST_F(ArrayTest, CreateRuntimeArray) {
TEST_F(ArrayTest, Is) {
I32 i32;
Array arr{&i32, 3};
Array arr{&i32, 3, ArrayDecorationList{}};
Type* ty = &arr;
EXPECT_FALSE(ty->Is<AccessControl>());
EXPECT_FALSE(ty->Is<Alias>());
@ -77,70 +77,55 @@ TEST_F(ArrayTest, Is) {
TEST_F(ArrayTest, TypeName) {
I32 i32;
Array arr{&i32};
Array arr{&i32, 0, ArrayDecorationList{}};
EXPECT_EQ(arr.type_name(), "__array__i32");
}
TEST_F(ArrayTest, TypeName_RuntimeArray) {
I32 i32;
Array arr{&i32, 3};
Array arr{&i32, 3, ArrayDecorationList{}};
EXPECT_EQ(arr.type_name(), "__array__i32_3");
}
TEST_F(ArrayTest, TypeName_WithStride) {
I32 i32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(16, Source{}));
Array arr{&i32, 3};
arr.set_decorations(decos);
Array arr{&i32, 3,
ArrayDecorationList{create<StrideDecoration>(16, Source{})}};
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
}
TEST_F(ArrayTest, MinBufferBindingSizeNoStride) {
U32 u32;
Array arr(&u32, 4);
Array arr(&u32, 4, ArrayDecorationList{});
EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(ArrayTest, MinBufferBindingSizeArray) {
U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
Array arr(&u32, 4);
arr.set_decorations(decos);
Array arr(&u32, 4,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) {
U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
Array arr(&u32);
arr.set_decorations(decos);
Array arr(&u32, 0,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
}
TEST_F(ArrayTest, BaseAlignmentArray) {
U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
Array arr(&u32, 4);
arr.set_decorations(decos);
Array arr(&u32, 4,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
}
TEST_F(ArrayTest, BaseAlignmentRuntimeArray) {
U32 u32;
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
Array arr(&u32);
arr.set_decorations(decos);
Array arr(&u32, 0,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
}

View File

@ -52,7 +52,7 @@ uint64_t Matrix::MinBufferBindingSize(MemoryLayout mem_layout) const {
uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const {
Vector vec(subtype_, rows_);
Array arr(&vec, columns_);
Array arr(&vec, columns_, ArrayDecorationList{});
return arr.BaseAlignment(mem_layout);
}

View File

@ -99,12 +99,8 @@ TEST_F(StructTest, MinBufferBindingSize) {
TEST_F(StructTest, MinBufferBindingSizeArray) {
U32 u32;
Array arr(&u32, 4);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
arr.set_decorations(decos);
}
Array arr(&u32, 4,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
StructMemberList members;
{
@ -134,12 +130,8 @@ TEST_F(StructTest, MinBufferBindingSizeArray) {
TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) {
U32 u32;
Array arr(&u32);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
arr.set_decorations(decos);
}
Array arr(&u32, 0,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
StructMemberList members;
{
@ -248,12 +240,8 @@ TEST_F(StructTest, BaseAlignment) {
TEST_F(StructTest, BaseAlignmentArray) {
U32 u32;
Array arr(&u32, 4);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
arr.set_decorations(decos);
}
Array arr(&u32, 4,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
StructMemberList members;
{
@ -281,12 +269,8 @@ TEST_F(StructTest, BaseAlignmentArray) {
TEST_F(StructTest, BaseAlignmentRuntimeArray) {
U32 u32;
Array arr(&u32);
{
ArrayDecorationList decos;
decos.push_back(create<StrideDecoration>(4, Source{}));
arr.set_decorations(decos);
}
Array arr(&u32, 0,
ArrayDecorationList{create<StrideDecoration>(4, Source{})});
StructMemberList members;
{

View File

@ -675,13 +675,13 @@ class InspectorHelper {
ast::type::U32* u32_type() { return &u32_type_; }
ast::type::Array* u32_array_type(uint32_t count) {
if (array_type_memo_.find(count) == array_type_memo_.end()) {
array_type_memo_[count] =
std::make_unique<ast::type::Array>(u32_type(), count);
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(4, Source{}));
array_type_memo_[count]->set_decorations(decos);
array_type_memo_[count] = create<ast::type::Array>(
u32_type(), count,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(4, Source{}),
});
}
return array_type_memo_[count].get();
return array_type_memo_[count];
}
ast::type::Vector* vec_type(ast::type::Type* type, uint32_t count) {
if (vector_type_memo_.find(std::tie(type, count)) ==
@ -718,7 +718,7 @@ class InspectorHelper {
ast::type::Void void_type_;
ast::type::Sampler sampler_type_;
ast::type::Sampler comparison_sampler_type_;
std::map<uint32_t, std::unique_ptr<ast::type::Array>> array_type_memo_;
std::map<uint32_t, ast::type::Array*> array_type_memo_;
std::map<std::tuple<ast::type::Type*, uint32_t>,
std::unique_ptr<ast::type::Vector>>
vector_type_memo_;

View File

@ -710,11 +710,11 @@ ast::type::Type* ParserImpl::ConvertType(
if (ast_elem_ty == nullptr) {
return nullptr;
}
auto ast_type = std::make_unique<ast::type::Array>(ast_elem_ty);
if (!ApplyArrayDecorations(rtarr_ty, ast_type.get())) {
ast::ArrayDecorationList decorations;
if (!ParseArrayDecorations(rtarr_ty, &decorations)) {
return nullptr;
}
return ast_module_.unique_type(std::move(ast_type));
return create<ast::type::Array>(ast_elem_ty, 0, std::move(decorations));
}
ast::type::Type* ParserImpl::ConvertType(
@ -751,20 +751,22 @@ ast::type::Type* ParserImpl::ConvertType(
<< num_elem;
return nullptr;
}
auto ast_type = std::make_unique<ast::type::Array>(
ast_elem_ty, static_cast<uint32_t>(num_elem));
if (!ApplyArrayDecorations(arr_ty, ast_type.get())) {
ast::ArrayDecorationList decorations;
if (!ParseArrayDecorations(arr_ty, &decorations)) {
return nullptr;
}
if (remap_buffer_block_type_.count(elem_type_id)) {
remap_buffer_block_type_.insert(type_mgr_->GetId(arr_ty));
}
return ast_module_.unique_type(std::move(ast_type));
return create<ast::type::Array>(ast_elem_ty, static_cast<uint32_t>(num_elem),
std::move(decorations));
}
bool ParserImpl::ApplyArrayDecorations(
bool ParserImpl::ParseArrayDecorations(
const spvtools::opt::analysis::Type* spv_type,
ast::type::Array* ast_type) {
ast::ArrayDecorationList* decorations) {
bool has_array_stride = false;
const auto type_id = type_mgr_->GetId(spv_type);
for (auto& decoration : this->GetDecorationsFor(type_id)) {
if (decoration.size() == 2 && decoration[0] == SpvDecorationArrayStride) {
@ -773,13 +775,12 @@ bool ParserImpl::ApplyArrayDecorations(
return Fail() << "invalid array type ID " << type_id
<< ": ArrayStride can't be 0";
}
if (ast_type->has_array_stride()) {
if (has_array_stride) {
return Fail() << "invalid array type ID " << type_id
<< ": multiple ArrayStride decorations";
}
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(stride, Source{}));
ast_type->set_decorations(std::move(decos));
has_array_stride = true;
decorations->push_back(create<ast::StrideDecoration>(stride, Source{}));
} else {
return Fail() << "invalid array type ID " << type_id
<< ": unknown decoration "

View File

@ -492,12 +492,12 @@ class ParserImpl : Reader {
ast::type::Type* ConvertType(uint32_t type_id,
const spvtools::opt::analysis::Pointer* ptr_ty);
/// Applies SPIR-V decorations to the given array or runtime-array type.
/// @param spv_type the SPIR-V aray or runtime-array type.
/// @param ast_type non-null; the AST type to apply decorations to
/// Parses the array or runtime-array decorations.
/// @param spv_type the SPIR-V array or runtime-array type.
/// @param decorations the populated decoration list
/// @returns true on success.
bool ApplyArrayDecorations(const spvtools::opt::analysis::Type* spv_type,
ast::type::Array* ast_type);
bool ParseArrayDecorations(const spvtools::opt::analysis::Type* spv_type,
ast::ArrayDecorationList* decorations);
/// Creates a new `ast::Node` owned by the Module. When the Module is
/// destructed, the `ast::Node` will also be destructed.

View File

@ -1099,9 +1099,7 @@ Expect<ast::type::Type*> ParserImpl::expect_type_decl_array(
size = val.value;
}
auto ty = std::make_unique<ast::type::Array>(subtype.value, size);
ty->set_decorations(std::move(decos));
return module_.unique_type(std::move(ty));
return create<ast::type::Array>(subtype.value, size, std::move(decos));
});
}

View File

@ -239,12 +239,11 @@ void VertexPulling::State::ConvertVertexInputVariablesToPrivate() {
void VertexPulling::State::AddVertexStorageBuffers() {
// TODO(idanr): Make this readonly https://github.com/gpuweb/gpuweb/issues/935
// The array inside the struct definition
auto internal_array = std::make_unique<ast::type::Array>(GetU32Type());
ast::ArrayDecorationList ary_decos;
ary_decos.push_back(mod->create<ast::StrideDecoration>(4u, Source{}));
internal_array->set_decorations(std::move(ary_decos));
auto* internal_array_type = mod->unique_type(std::move(internal_array));
auto* internal_array_type = mod->create<ast::type::Array>(
GetU32Type(), 0,
ast::ArrayDecorationList{
mod->create<ast::StrideDecoration>(4u, Source{}),
});
// Creating the struct type
ast::StructMemberList members;

View File

@ -579,7 +579,7 @@ TEST_F(VertexPullingTest, TwoAttributesSameBuffer) {
ast::type::F32 f32;
AddVertexInputVariable(0, "var_a", &f32);
ast::type::Array vec4_f32{&f32, 4u};
ast::type::Array vec4_f32{&f32, 4u, ast::ArrayDecorationList{}};
AddVertexInputVariable(1, "var_b", &vec4_f32);
InitTransform(
@ -759,13 +759,13 @@ TEST_F(VertexPullingTest, FloatVectorAttributes) {
InitBasicModule();
ast::type::F32 f32;
ast::type::Array vec2_f32{&f32, 2u};
ast::type::Array vec2_f32{&f32, 2u, ast::ArrayDecorationList{}};
AddVertexInputVariable(0, "var_a", &vec2_f32);
ast::type::Array vec3_f32{&f32, 3u};
ast::type::Array vec3_f32{&f32, 3u, ast::ArrayDecorationList{}};
AddVertexInputVariable(1, "var_b", &vec3_f32);
ast::type::Array vec4_f32{&f32, 4u};
ast::type::Array vec4_f32{&f32, 4u, ast::ArrayDecorationList{}};
AddVertexInputVariable(2, "var_c", &vec4_f32);
InitTransform(

View File

@ -428,7 +428,7 @@ TEST_F(TypeDeterminerTest, Expr_Error_Unknown) {
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) {
ast::type::I32 i32;
ast::type::F32 f32;
ast::type::Array ary(&f32, 3);
ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{});
auto* idx = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
@ -452,7 +452,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) {
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) {
ast::type::I32 i32;
ast::type::F32 f32;
ast::type::Array ary(&f32, 3);
ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{});
ast::type::Alias aary("myarrty", &ary);
auto* idx = create<ast::ScalarConstructorExpression>(
@ -477,7 +477,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) {
TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) {
ast::type::I32 i32;
ast::type::F32 f32;
ast::type::Array ary(&f32, 3);
ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{});
auto* idx = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));

View File

@ -43,7 +43,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) {
// };
ast::type::F32 f32;
ast::type::Array arr(&f32);
ast::type::Array arr(&f32, 0, ast::ArrayDecorationList{});
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@ -70,7 +70,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
// };
ast::type::F32 f32;
ast::type::Array arr(&f32);
ast::type::Array arr(&f32, 0, ast::ArrayDecorationList{});
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@ -100,7 +100,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {
// };
ast::type::F32 f32;
ast::type::Array arr(&f32);
ast::type::Array arr(&f32, 0, ast::ArrayDecorationList{});
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@ -132,7 +132,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) {
//}
ast::type::F32 u32;
ast::type::Array array(&u32);
ast::type::Array array(&u32, 0, ast::ArrayDecorationList{});
ast::type::Alias alias{"RTArr", &array};
ast::StructMemberList members;
@ -166,7 +166,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
//}
ast::type::F32 u32;
ast::type::Array array(&u32);
ast::type::Array array(&u32, 0, ast::ArrayDecorationList{});
ast::type::Alias alias{"RTArr", &array};
ast::StructMemberList members;
@ -191,7 +191,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
/// [[stage(vertex)]]
// fn func -> void { var a : array<i32>; }
ast::type::I32 i32;
ast::type::Array array(&i32);
ast::type::Array array(&i32, 0, ast::ArrayDecorationList{});
auto* var =
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &array);

View File

@ -193,7 +193,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
ast::type::F32 f32;
ast::type::Vector vec(&f32, 3);
ast::type::Array ary(&vec, 3);
ast::type::Array ary(&vec, 3, ast::ArrayDecorationList{});
ast::ExpressionList ary_values;

View File

@ -1037,7 +1037,7 @@ void main() {
TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
ast::type::F32 f32;
ast::type::Array ary(&f32, 5);
ast::type::Array ary(&f32, 5, ast::ArrayDecorationList{});
ast::VariableList params;
params.push_back(

View File

@ -477,8 +477,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
// -> asint(data.Load((2 * 4));
ast::type::F32 f32;
ast::type::I32 i32;
ast::type::Array ary(&i32, 5);
ary.set_decorations({create<ast::StrideDecoration>(4, Source{})});
ast::type::Array ary(&i32, 5,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(4, Source{}),
});
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@ -521,8 +523,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
// -> asint(data.Load((4 * ((2 + 4) - 3)));
ast::type::F32 f32;
ast::type::I32 i32;
ast::type::Array ary(&i32, 5);
ary.set_decorations({create<ast::StrideDecoration>(4, Source{})});
ast::type::Array ary(&i32, 5,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(4, Source{}),
});
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@ -623,8 +627,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::F32 f32;
ast::type::I32 i32;
ast::type::Array ary(&i32, 5);
ary.set_decorations({create<ast::StrideDecoration>(4, Source{})});
ast::type::Array ary(&i32, 5,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(4, Source{}),
});
ast::StructMemberList members;
ast::StructMemberDecorationList a_deco;
@ -848,8 +854,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Struct data("Data", data_str);
ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
ast::type::Array ary(&data, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(32, Source{}),
});
auto* pre_str = create<ast::Struct>(ast::StructMemberList{
create<ast::StructMember>(
@ -919,8 +927,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Struct data("Data", data_str);
ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
ast::type::Array ary(
&data, 4,
ast::ArrayDecorationList{create<ast::StrideDecoration>(32, Source{})});
auto* pre_str =
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>(
@ -989,8 +998,10 @@ TEST_F(
ast::type::Struct data("Data", data_str);
ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
ast::type::Array ary(&data, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(32, Source{}),
});
auto* pre_str =
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>(
@ -1058,8 +1069,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Struct data("Data", data_str);
ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
ast::type::Array ary(&data, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(32, Source{}),
});
auto* pre_str =
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>(
@ -1128,8 +1141,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Struct data("Data", data_str);
ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
ast::type::Array ary(&data, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(32, Source{}),
});
auto* pre_str =
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>(
@ -1209,8 +1224,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
ast::type::Struct data("Data", data_str);
ast::type::Array ary(&data, 4);
ary.set_decorations({create<ast::StrideDecoration>(32, Source{})});
ast::type::Array ary(&data, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(32, Source{}),
});
auto* pre_str =
create<ast::Struct>(ast::StructMemberList{create<ast::StructMember>(

View File

@ -35,7 +35,7 @@ using HlslGeneratorImplTest_ModuleConstant = TestHelper;
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
ast::type::F32 f32;
ast::type::Array ary(&f32, 3);
ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{});
ast::ExpressionList exprs;
exprs.push_back(create<ast::ScalarConstructorExpression>(

View File

@ -61,7 +61,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias_NameCollision) {
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &a, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[4]");
@ -69,8 +69,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array c(&a, 5);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ast::type::Array c(&a, 5, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &c, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[5][4]");
@ -80,9 +80,9 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
TEST_F(HlslGeneratorImplTest_Type,
DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array c(&a, 5);
ast::type::Array d(&c);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ast::type::Array c(&a, 5, ast::ArrayDecorationList{});
ast::type::Array d(&c, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &c, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[5][4][1]");
@ -90,9 +90,9 @@ TEST_F(HlslGeneratorImplTest_Type,
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array c(&a, 5);
ast::type::Array d(&c, 6);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ast::type::Array c(&a, 5, ast::ArrayDecorationList{});
ast::type::Array d(&c, 6, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &d, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[6][5][4]");
@ -100,7 +100,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_NameCollision) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &a, "bool")) << gen.error();
EXPECT_EQ(result(), "bool bool_tint_0[4]");
@ -108,7 +108,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_NameCollision) {
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &a, "")) << gen.error();
EXPECT_EQ(result(), "bool[4]");
@ -116,7 +116,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray) {
ast::type::Bool b;
ast::type::Array a(&b);
ast::type::Array a(&b, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &a, "ary")) << gen.error();
EXPECT_EQ(result(), "bool ary[]");
@ -125,7 +125,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray) {
TEST_F(HlslGeneratorImplTest_Type,
DISABLED_EmitType_RuntimeArray_NameCollision) {
ast::type::Bool b;
ast::type::Array a(&b);
ast::type::Array a(&b, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(out, &a, "double")) << gen.error();
EXPECT_EQ(result(), "bool double_tint_0[]");

View File

@ -59,7 +59,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
ast::type::F32 f32;
ast::type::Array ary(&f32, 5);
ast::type::Array ary(&f32, 5, ast::ArrayDecorationList{});
auto* var =
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &ary);

View File

@ -194,7 +194,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) {
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) {
ast::type::F32 f32;
ast::type::Vector vec(&f32, 3);
ast::type::Array ary(&vec, 3);
ast::type::Array ary(&vec, 3, ast::ArrayDecorationList{});
ast::ExpressionList ary_values;

View File

@ -1011,7 +1011,7 @@ kernel void main_tint_0() {
TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) {
ast::type::F32 f32;
ast::type::Array ary(&f32, 5);
ast::type::Array ary(&f32, 5, ast::ArrayDecorationList{});
ast::VariableList params;
params.push_back(

View File

@ -37,7 +37,7 @@ using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
ast::type::F32 f32;
ast::type::Array ary(&f32, 3);
ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{});
ast::ExpressionList exprs;
exprs.push_back(create<ast::ScalarConstructorExpression>(

View File

@ -123,7 +123,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_alias) {
TEST_F(MslGeneratorImplTest, calculate_alignment_size_array) {
ast::type::F32 f32;
ast::type::Array ary(&f32, 4);
ast::type::Array ary(&f32, 4, ast::ArrayDecorationList{});
EXPECT_EQ(4u * 4u, gen.calculate_alignment_size(&ary));
}

View File

@ -64,7 +64,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Alias_NameCollision) {
TEST_F(MslGeneratorImplTest, EmitType_Array) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[4]");
@ -72,8 +72,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Array) {
TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array c(&a, 5);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ast::type::Array c(&a, 5, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[5][4]");
@ -82,9 +82,9 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) {
// TODO(dsinclair): Is this possible? What order should it output in?
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array c(&a, 5);
ast::type::Array d(&c);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ast::type::Array c(&a, 5, ast::ArrayDecorationList{});
ast::type::Array d(&c, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[5][4][1]");
@ -92,9 +92,9 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array c(&a, 5);
ast::type::Array d(&c, 6);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ast::type::Array c(&a, 5, ast::ArrayDecorationList{});
ast::type::Array d(&c, 6, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&d, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[6][5][4]");
@ -102,7 +102,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
TEST_F(MslGeneratorImplTest, EmitType_Array_NameCollision) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a, "bool")) << gen.error();
EXPECT_EQ(gen.result(), "bool bool_tint_0[4]");
@ -110,7 +110,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array_NameCollision) {
TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a, "")) << gen.error();
EXPECT_EQ(gen.result(), "bool[4]");
@ -118,7 +118,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
ast::type::Bool b;
ast::type::Array a(&b);
ast::type::Array a(&b, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error();
EXPECT_EQ(gen.result(), "bool ary[1]");
@ -126,7 +126,7 @@ TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray_NameCollision) {
ast::type::Bool b;
ast::type::Array a(&b);
ast::type::Array a(&b, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a, "discard_fragment")) << gen.error();
EXPECT_EQ(gen.result(), "bool discard_fragment_tint_0[1]");

View File

@ -69,7 +69,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) {
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
ast::type::F32 f32;
ast::type::Array ary(&f32, 5);
ast::type::Array ary(&f32, 5, ast::ArrayDecorationList{});
auto* var =
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &ary);

View File

@ -181,7 +181,7 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) {
ast::type::I32 i32;
ast::type::F32 f32;
ast::type::Vector vec3(&f32, 3);
ast::type::Array ary4(&vec3, 4);
ast::type::Array ary4(&vec3, 4, ast::ArrayDecorationList{});
// ary = array<vec3<f32>, 4>
// ary[3][2];
@ -228,7 +228,7 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) {
ast::type::I32 i32;
ast::type::F32 f32;
ast::type::Vector vec3(&f32, 3);
ast::type::Array ary4(&vec3, 4);
ast::type::Array ary4(&vec3, 4, ast::ArrayDecorationList{});
// var a : array<vec3<f32>, 4>;
// a[2].xy;
@ -784,13 +784,13 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
ast::StructMemberList{create<ast::StructMember>("bar", &c_type, decos)});
ast::type::Struct b_type("B", s);
ast::type::Array b_ary_type(&b_type, 3);
ast::type::Array b_ary_type(&b_type, 3, ast::ArrayDecorationList{});
s = create<ast::Struct>(ast::StructMemberList{
create<ast::StructMember>("foo", &b_ary_type, decos)});
ast::type::Struct a_type("A", s);
ast::type::Array a_ary_type(&a_type, 2);
ast::type::Array a_ary_type(&a_type, 2, ast::ArrayDecorationList{});
ast::Variable var(Source{}, "index", ast::StorageClass::kFunction,
&a_ary_type);
@ -858,7 +858,7 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) {
ast::type::F32 f32;
ast::type::U32 u32;
ast::type::Vector vec(&f32, 2);
ast::type::Array arr(&vec, 3);
ast::type::Array arr(&vec, 3, ast::ArrayDecorationList{});
ast::ExpressionList ary_params;
ary_params.push_back(create<ast::TypeConstructorExpression>(

View File

@ -81,7 +81,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedAlias) {
TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
ast::type::I32 i32;
ast::type::Array ary(&i32);
ast::type::Array ary(&i32, 0, ast::ArrayDecorationList{});
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
@ -94,7 +94,7 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
ast::type::I32 i32;
ast::type::Array ary(&i32);
ast::type::Array ary(&i32, 0, ast::ArrayDecorationList{});
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
@ -107,7 +107,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
TEST_F(BuilderTest_Type, GenerateArray) {
ast::type::I32 i32;
ast::type::Array ary(&i32, 4);
ast::type::Array ary(&i32, 4, ast::ArrayDecorationList{});
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
@ -123,11 +123,10 @@ TEST_F(BuilderTest_Type, GenerateArray) {
TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
ast::type::I32 i32;
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(16u, Source{}));
ast::type::Array ary(&i32, 4);
ary.set_decorations(decos);
ast::type::Array ary(&i32, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(16u, Source{}),
});
auto id = b.GenerateTypeIfNeeded(&ary);
ASSERT_FALSE(b.has_error()) << b.error();
@ -145,7 +144,7 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
TEST_F(BuilderTest_Type, ReturnsGeneratedArray) {
ast::type::I32 i32;
ast::type::Array ary(&i32, 4);
ast::type::Array ary(&i32, 4, ast::ArrayDecorationList{});
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u);
@ -471,14 +470,17 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) {
ast::type::F32 f32;
ast::type::Matrix glsl_mat2x2(&f32, 2, 2);
ast::type::Array arr_mat2x2(&glsl_mat2x2, 1); // Singly nested array
ast::type::Array arr_mat2x2(
&glsl_mat2x2, 1, ast::ArrayDecorationList{}); // Singly nested array
ast::type::Matrix glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows
ast::type::Array arr_mat2x3(&glsl_mat2x3, 1);
ast::type::Array arr_arr_mat2x2(&arr_mat2x3, 1); // Doubly nested array
ast::type::Array arr_mat2x3(&glsl_mat2x3, 1, ast::ArrayDecorationList{});
ast::type::Array arr_arr_mat2x2(
&arr_mat2x3, 1, ast::ArrayDecorationList{}); // Doubly nested array
ast::type::Matrix glsl_mat4x4(&f32, 4, 4);
ast::type::Array rtarr_mat4x4(&glsl_mat4x4); // Runtime array
ast::type::Array rtarr_mat4x4(&glsl_mat4x4, 0,
ast::ArrayDecorationList{}); // Runtime array
ast::StructMemberDecorationList a_decos;
a_decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));

View File

@ -174,7 +174,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) {
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) {
ast::type::F32 f32;
ast::type::Vector vec(&f32, 3);
ast::type::Array ary(&vec, 3);
ast::type::Array ary(&vec, 3, ast::ArrayDecorationList{});
ast::ExpressionList ary_values;

View File

@ -57,7 +57,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Alias) {
TEST_F(WgslGeneratorImplTest, EmitType_Array) {
ast::type::Bool b;
ast::type::Array a(&b, 4);
ast::type::Array a(&b, 4, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "array<bool, 4>");
@ -105,11 +105,10 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) {
TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
ast::type::Bool b;
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(16u, Source{}));
ast::type::Array a(&b, 4);
a.set_decorations(decos);
ast::type::Array a(&b, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(16u, Source{}),
});
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[stride(16)]] array<bool, 4>");
@ -117,12 +116,11 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
ast::type::Bool b;
ast::ArrayDecorationList decos;
decos.push_back(create<ast::StrideDecoration>(16u, Source{}));
decos.push_back(create<ast::StrideDecoration>(32u, Source{}));
ast::type::Array a(&b, 4);
a.set_decorations(decos);
ast::type::Array a(&b, 4,
ast::ArrayDecorationList{
create<ast::StrideDecoration>(16u, Source{}),
create<ast::StrideDecoration>(32u, Source{}),
});
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "[[stride(16)]] [[stride(32)]] array<bool, 4>");
@ -130,7 +128,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
ast::type::Bool b;
ast::type::Array a(&b);
ast::type::Array a(&b, 0, ast::ArrayDecorationList{});
ASSERT_TRUE(gen.EmitType(&a)) << gen.error();
EXPECT_EQ(gen.result(), "array<bool>");