tint: Reduce repetition for ty.type_name()

Rename the type_name() method with  operator().

`ty.type_name("blah")` becomes `ty("blah")`

Change-Id: Ia0b2bc304e7bb208c2e40a469332044b394535d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118401
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton 2023-02-03 14:01:43 +00:00 committed by Dawn LUCI CQ
parent 6bd233fe54
commit 2117f80f8b
40 changed files with 296 additions and 310 deletions

View File

@ -23,13 +23,13 @@ using namespace tint::number_suffixes; // NOLINT
using TypeNameTest = TestHelper;
TEST_F(TypeNameTest, Creation_NonTemplated) {
auto* t = ty.type_name("ty");
auto* t = ty("ty");
ASSERT_NE(t->name, nullptr);
EXPECT_EQ(t->name->symbol, Symbols().Get("ty"));
}
TEST_F(TypeNameTest, Creation_Templated) {
auto* t = ty.type_name("ty", 1_a, 2._a, false);
auto* t = ty("ty", 1_a, 2._a, false);
auto* name = As<ast::TemplatedIdentifier>(t->name);
ASSERT_NE(name, nullptr);
EXPECT_EQ(name->symbol, Symbols().Get("ty"));
@ -40,7 +40,7 @@ TEST_F(TypeNameTest, Creation_Templated) {
}
TEST_F(TypeNameTest, Creation_WithSource) {
auto* t = ty.type_name(Source{{20, 2}}, "ty");
auto* t = ty(Source{{20, 2}}, "ty");
ASSERT_NE(t->name, nullptr);
EXPECT_EQ(t->name->symbol, Symbols().Get("ty"));
@ -53,7 +53,7 @@ TEST_F(TypeNameTest, Assert_InvalidSymbol) {
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
b.ty.type_name("");
b.ty("");
},
"internal compiler error");
}
@ -63,7 +63,7 @@ TEST_F(TypeNameTest, Assert_DifferentProgramID_Symbol) {
{
ProgramBuilder b1;
ProgramBuilder b2;
b1.ty.type_name(b2.Sym("b2"));
b1.ty(b2.Sym("b2"));
},
"internal compiler error");
}

View File

@ -885,7 +885,7 @@ TEST_F(InspectorGetEntryPointTest, OverrideReferencedByArraySizeViaAlias) {
Alias("MyArray", ty.array(ty.f32(), Mul(2_a, Expr("bar"))));
Override("zoo", ty.u32());
Alias("MyArrayUnused", ty.array(ty.f32(), Mul(2_a, Expr("zoo"))));
GlobalVar("v", type::AddressSpace::kWorkgroup, ty.type_name("MyArray"));
GlobalVar("v", type::AddressSpace::kWorkgroup, ty("MyArray"));
Func("ep", utils::Empty, ty.void_(),
utils::Vector{
Assign(Phony(), IndexAccessor("v", 0_a)),
@ -1076,7 +1076,7 @@ TEST_F(InspectorGetEntryPointTest, InputSampleMaskStructReferenced) {
Func("ep_func",
utils::Vector{
Param("in_var", ty.type_name("in_struct"), utils::Empty),
Param("in_var", ty("in_struct"), utils::Empty),
},
ty.void_(),
utils::Vector{
@ -1124,9 +1124,9 @@ TEST_F(InspectorGetEntryPointTest, OutputSampleMaskStructReferenced) {
utils::Vector{Builtin(ast::BuiltinValue::kSampleMask)}),
});
Func("ep_func", utils::Empty, ty.type_name("out_struct"),
Func("ep_func", utils::Empty, ty("out_struct"),
utils::Vector{
Decl(Var("out_var", ty.type_name("out_struct"))),
Decl(Var("out_var", ty("out_struct"))),
Return("out_var"),
},
utils::Vector{
@ -1170,7 +1170,7 @@ TEST_F(InspectorGetEntryPointTest, InputPositionStructReferenced) {
Func("ep_func",
utils::Vector{
Param("in_var", ty.type_name("in_struct"), utils::Empty),
Param("in_var", ty("in_struct"), utils::Empty),
},
ty.void_(),
utils::Vector{
@ -1217,7 +1217,7 @@ TEST_F(InspectorGetEntryPointTest, FrontFacingStructReferenced) {
Func("ep_func",
utils::Vector{
Param("in_var", ty.type_name("in_struct"), utils::Empty),
Param("in_var", ty("in_struct"), utils::Empty),
},
ty.void_(),
utils::Vector{
@ -1264,7 +1264,7 @@ TEST_F(InspectorGetEntryPointTest, SampleIndexStructReferenced) {
Func("ep_func",
utils::Vector{
Param("in_var", ty.type_name("in_struct"), utils::Empty),
Param("in_var", ty("in_struct"), utils::Empty),
},
ty.void_(),
utils::Vector{
@ -1310,7 +1310,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) {
Func("ep_func",
utils::Vector{
Param("in_var", ty.type_name("in_struct"), utils::Empty),
Param("in_var", ty("in_struct"), utils::Empty),
},
ty.void_(),
utils::Vector{
@ -1352,9 +1352,9 @@ TEST_F(InspectorGetEntryPointTest, FragDepthStructReferenced) {
utils::Vector{Builtin(ast::BuiltinValue::kFragDepth)}),
});
Func("ep_func", utils::Empty, ty.type_name("out_struct"),
Func("ep_func", utils::Empty, ty("out_struct"),
utils::Vector{
Decl(Var("out_var", ty.type_name("out_struct"))),
Decl(Var("out_var", ty("out_struct"))),
Return("out_var"),
},
utils::Vector{
@ -1376,7 +1376,7 @@ TEST_F(InspectorGetEntryPointTest, ImplicitInterpolate) {
Func("ep_func",
utils::Vector{
Param("in_var", ty.type_name("in_struct"), utils::Empty),
Param("in_var", ty("in_struct"), utils::Empty),
},
ty.void_(),
utils::Vector{
@ -1407,7 +1407,7 @@ TEST_P(InspectorGetEntryPointInterpolateTest, Test) {
Func("ep_func",
utils::Vector{
Param("in_var", ty.type_name("in_struct"), utils::Empty),
Param("in_var", ty("in_struct"), utils::Empty),
},
ty.void_(),
utils::Vector{

View File

@ -119,7 +119,7 @@ std::function<const ast::TypeName*()> InspectorBuilder::MakeStorageBufferTypes(
const std::string& name,
utils::VectorRef<const ast::Type*> member_types) {
MakeStructType(name, member_types);
return [this, name] { return ty.type_name(name); };
return [this, name] { return ty(name); };
}
void InspectorBuilder::AddUniformBuffer(const std::string& name,

View File

@ -128,7 +128,7 @@ std::string ProgramBuilder::FriendlyName(std::nullptr_t) const {
}
const ast::TypeName* ProgramBuilder::TypesBuilder::Of(const ast::TypeDecl* decl) const {
return type_name(decl->name);
return (*this)(decl->name);
}
ProgramBuilder::TypesBuilder::TypesBuilder(ProgramBuilder* pb) : builder(pb) {}

View File

@ -904,7 +904,7 @@ class ProgramBuilder {
/// @param args the optional template arguments
/// @returns the type name
template <typename NAME, typename... ARGS, typename _ = DisableIfSource<NAME>>
const ast::TypeName* type_name(NAME&& name, ARGS&&... args) const {
const ast::TypeName* operator()(NAME&& name, ARGS&&... args) const {
return builder->create<ast::TypeName>(
builder->Ident(std::forward<NAME>(name), std::forward<ARGS>(args)...));
}
@ -915,7 +915,7 @@ class ProgramBuilder {
/// @param args the optional template arguments
/// @returns the type name
template <typename NAME, typename... ARGS>
const ast::TypeName* type_name(const Source& source, NAME&& name, ARGS&&... args) const {
const ast::TypeName* operator()(const Source& source, NAME&& name, ARGS&&... args) const {
return builder->create<ast::TypeName>(
source, builder->Ident(std::forward<NAME>(name), std::forward<ARGS>(args)...));
}

View File

@ -271,7 +271,7 @@ Alias::Alias(Symbol n, const Type* ty) : Base(n), type(ty) {}
Alias::Alias(const Alias&) = default;
const ast::Type* Alias::Build(ProgramBuilder& b) const {
return b.ty.type_name(name);
return b.ty(name);
}
Struct::Struct(Symbol n, TypeList m) : Base(n), members(std::move(m)) {}
@ -279,7 +279,7 @@ Struct::Struct(const Struct&) = default;
Struct::~Struct() = default;
const ast::Type* Struct::Build(ProgramBuilder& b) const {
return b.ty.type_name(name);
return b.ty(name);
}
/// The PIMPL state of the Types object.

View File

@ -1213,7 +1213,7 @@ Maybe<const ast::Type*> ParserImpl::type_specifier() {
auto& t = peek();
Source source;
if (match(Token::Type::kIdentifier, &source)) {
return builder_.ty.type_name(source, t.to_str());
return builder_.ty(source, t.to_str());
}
return type_specifier_without_ident();

View File

@ -39,7 +39,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, StorageBuffer_UnalignedMember)
Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(1_i)}),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), type::AddressSpace::kStorage, Group(0_a),
GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kStorage, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
@ -69,7 +69,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, StorageBuffer_UnalignedMember_S
Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(4_i)}),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), type::AddressSpace::kStorage, Group(0_a),
GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kStorage, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -97,11 +97,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_S
Structure(Source{{34, 56}}, "Outer",
utils::Vector{
Member("scalar", ty.f32()),
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{56, 78}}, "inner", ty("Inner")),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -141,12 +141,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest,
Structure(Source{{34, 56}}, "Outer",
utils::Vector{
Member("scalar", ty.f32()),
Member(Source{{56, 78}}, "inner", ty.type_name("Inner"),
utils::Vector{MemberAlign(16_i)}),
Member(Source{{56, 78}}, "inner", ty("Inner"), utils::Vector{MemberAlign(16_i)}),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -167,11 +166,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_A
Structure(Source{{12, 34}}, "Outer",
utils::Vector{
Member("scalar", ty.f32()),
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{56, 78}}, "inner", ty("Inner")),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -200,12 +199,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_A
Structure(Source{{12, 34}}, "Outer",
utils::Vector{
Member("scalar", ty.f32()),
Member(Source{{34, 56}}, "inner", ty.type_name("Inner"),
utils::Vector{MemberAlign(16_i)}),
Member(Source{{34, 56}}, "inner", ty("Inner"), utils::Vector{MemberAlign(16_i)}),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -232,12 +230,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_MembersOffsetNotM
Structure(Source{{34, 56}}, "Outer",
utils::Vector{
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{56, 78}}, "inner", ty("Inner")),
Member(Source{{78, 90}}, "scalar", ty.i32()),
});
GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{22, 24}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -284,12 +282,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest,
Structure(Source{{34, 56}}, "Outer",
utils::Vector{
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{56, 78}}, "inner", ty("Inner")),
Member(Source{{78, 90}}, "scalar", ty.i32()),
});
GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{22, 24}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -332,12 +330,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest,
Structure(Source{{34, 56}}, "Outer",
utils::Vector{
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
Member(Source{{56, 78}}, "inner", ty("Inner")),
Member(Source{{78, 90}}, "scalar", ty.i32(), utils::Vector{MemberAlign(16_i)}),
});
GlobalVar(Source{{22, 34}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{22, 34}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -357,8 +355,8 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_Vec3MemberOffset_
Member("s", ty.f32()),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"),
type::AddressSpace::kUniform, Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -380,8 +378,8 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_Vec3F16MemberOffs
Member("s", ty.f16()),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"),
type::AddressSpace::kUniform, Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -402,12 +400,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Structure(Source{{12, 34}}, "Outer",
utils::Vector{
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("inner", ty(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -436,12 +434,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Structure(Source{{12, 34}}, "Outer",
utils::Vector{
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("inner", ty(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -479,12 +477,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Structure(Source{{12, 34}}, "Outer",
utils::Vector{
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("inner", ty(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -523,8 +521,8 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4_u), 4_u)),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -552,12 +550,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Structure(Source{{12, 34}}, "Outer",
utils::Vector{
Member("inner", ty.type_name(Source{{34, 56}}, "Inner")),
Member("inner", ty(Source{{34, 56}}, "Inner")),
Member("scalar", ty.i32()),
});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform,
Group(0_a), Binding(0_a));
GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a),
Binding(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -575,7 +573,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, PushConstant_UnalignedMember) {
Source{{12, 34}}, "S",
utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(5_a)}),
Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(1_i)})});
GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), type::AddressSpace::kPushConstant);
GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kPushConstant);
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -600,7 +598,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, PushConstant_Aligned) {
Enable(ast::Extension::kChromiumExperimentalPushConstant);
Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(5_a)}),
Member("b", ty.f32(), utils::Vector{MemberAlign(4_i)})});
GlobalVar("a", ty.type_name("S"), type::AddressSpace::kPushConstant);
GlobalVar("a", ty("S"), type::AddressSpace::kPushConstant);
ASSERT_TRUE(r()->Resolve()) << r()->error();
}

View File

@ -79,7 +79,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Private_RuntimeArrayIn
// struct S { m : array<i32> };
// var<private> v : S;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))});
GlobalVar(Source{{56, 78}}, "v", ty.type_name("S"), type::AddressSpace::kPrivate);
GlobalVar(Source{{56, 78}}, "v", ty("S"), type::AddressSpace::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -92,7 +92,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Private_RuntimeArrayInSt
// struct S { m : array<i32> };
// type t = ptr<private, S>;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))});
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kPrivate));
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kPrivate));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -126,7 +126,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Workgroup_RuntimeArray
// struct S { m : array<i32> };
// var<workgroup> v : S;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))});
GlobalVar(Source{{56, 78}}, "v", ty.type_name("S"), type::AddressSpace::kWorkgroup);
GlobalVar(Source{{56, 78}}, "v", ty("S"), type::AddressSpace::kWorkgroup);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -139,7 +139,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Workgroup_RuntimeArrayIn
// struct S { m : array<i32> };
// type t = ptr<workgroup, S>;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))});
Alias(Source{{56, 78}}, "t", ty.pointer(ty.type_name("S"), type::AddressSpace::kWorkgroup));
Alias(Source{{56, 78}}, "t", ty.pointer(ty("S"), type::AddressSpace::kWorkgroup));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -178,8 +178,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_BoolAlias) {
// type a = bool;
// @binding(0) @group(0) var<storage, read> g : a;
Alias("a", ty.bool_());
GlobalVar(Source{{56, 78}}, "g", ty.type_name(Source{{12, 34}}, "a"),
type::AddressSpace::kStorage, Binding(0_a), Group(0_a));
GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), type::AddressSpace::kStorage,
Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@ -194,7 +194,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_BoolAlias) {
// type t = ptr<storage, a>;
Alias("a", ty.bool_());
Alias(Source{{56, 78}}, "t",
ty.pointer(ty.type_name(Source{{12, 34}}, "a"), type::AddressSpace::kStorage));
ty.pointer(ty(Source{{12, 34}}, "a"), type::AddressSpace::kStorage));
ASSERT_FALSE(r()->Resolve());
@ -273,7 +273,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_F16Alias) {
Enable(ast::Extension::kF16);
Alias("a", ty.f16());
GlobalVar("g", ty.type_name("a"), type::AddressSpace::kStorage, Binding(0_a), Group(0_a));
GlobalVar("g", ty("a"), type::AddressSpace::kStorage, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -285,7 +285,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_F16Alias) {
Enable(ast::Extension::kF16);
Alias("a", ty.f16());
Alias("t", ty.pointer(ty.type_name("a"), type::AddressSpace::kStorage));
Alias("t", ty.pointer(ty("a"), type::AddressSpace::kStorage));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -324,8 +324,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF32) {
// struct S{ a : f32 };
// var<storage, read> g : array<S, 3u>;
Structure("S", utils::Vector{Member("a", ty.f32())});
GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage,
type::Access::kRead, Binding(0_a), Group(0_a));
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -334,7 +334,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF32) {
// struct S{ a : f32 };
// type t = ptr<storage, array<S, 3u>>;
Structure("S", utils::Vector{Member("a", ty.f32())});
Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage));
Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -346,8 +346,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF16) {
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("a", ty.f16())});
GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage,
type::Access::kRead, Binding(0_a), Group(0_a));
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -359,8 +359,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) {
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("a", ty.f16())});
Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage,
type::Access::kRead));
Alias("t",
ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -369,8 +369,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32) {
// struct S { x : i32 };
// var<storage, read> g : S;
Structure("S", utils::Vector{Member("x", ty.i32())});
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
GlobalVar("g", ty("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -379,7 +379,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32) {
// struct S { x : i32 };
// type t = ptr<storage, read, S>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -389,10 +389,10 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32Alias
// type a1 = S;
// var<storage, read> g : a1;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -402,9 +402,9 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases
// type a1 = S;
// type t = ptr<storage, read, a1>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
Alias("t", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
Alias("t", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -415,8 +415,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16) {
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
GlobalVar("g", ty("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -427,7 +427,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) {
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -439,10 +439,10 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16Alias
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a),
Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -454,9 +454,9 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty.type_name("S"));
Alias("a2", ty.type_name("a1"));
Alias("g", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead));
Alias("a1", ty("S"));
Alias("a2", ty("a1"));
Alias("g", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -543,8 +543,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBuffer_Struct_R
Structure("S",
utils::Vector{Member(Source{{56, 78}}, "m", ty.array(Source{{12, 34}}, ty.i32()))});
GlobalVar(Source{{90, 12}}, "svar", ty.type_name("S"), type::AddressSpace::kUniform,
Binding(0_a), Group(0_a));
GlobalVar(Source{{90, 12}}, "svar", ty("S"), type::AddressSpace::kUniform, Binding(0_a),
Group(0_a));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -560,7 +560,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBuffer_Struct_Run
Structure("S",
utils::Vector{Member(Source{{56, 78}}, "m", ty.array(Source{{12, 34}}, ty.i32()))});
Alias("t", ty.pointer(Source{{90, 12}}, ty.type_name("S"), type::AddressSpace::kUniform));
Alias("t", ty.pointer(Source{{90, 12}}, ty("S"), type::AddressSpace::kUniform));
ASSERT_FALSE(r()->Resolve());
EXPECT_EQ(
@ -603,8 +603,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferBoolAlias
// type a = bool;
// var<uniform> g : a;
Alias("a", ty.bool_());
GlobalVar(Source{{56, 78}}, "g", ty.type_name(Source{{12, 34}}, "a"),
type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), type::AddressSpace::kUniform,
Binding(0_a), Group(0_a));
ASSERT_FALSE(r()->Resolve());
@ -618,8 +618,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferBoolAlias)
// type a = bool;
// type t = ptr<uniform, a>;
Alias("a", ty.bool_());
Alias("t", ty.pointer(Source{{56, 78}}, ty.type_name(Source{{12, 34}}, "a"),
type::AddressSpace::kUniform));
Alias("t",
ty.pointer(Source{{56, 78}}, ty(Source{{12, 34}}, "a"), type::AddressSpace::kUniform));
ASSERT_FALSE(r()->Resolve());
@ -732,8 +732,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferArrayF32)
// }
// var<uniform> g : array<S, 3u>;
Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16_a)})});
GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a),
Group(0_a));
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -744,7 +743,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferArrayF32) {
// }
// type t = ptr<uniform, array<S, 3u>>;
Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16_a)})});
Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform));
Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kUniform));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -758,8 +757,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferArrayF16)
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("a", ty.f16(), utils::Vector{MemberSize(16_a)})});
GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a),
Group(0_a));
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -773,7 +771,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferArrayF16) {
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("a", ty.f16(), utils::Vector{MemberSize(16_a)})});
Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform));
Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kUniform));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -782,7 +780,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructI32
// struct S { x : i32 };
// var<uniform> g : S;
Structure("S", utils::Vector{Member("x", ty.i32())});
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
GlobalVar("g", ty("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -791,7 +789,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructI32)
// struct S { x : i32 };
// type t = ptr<uniform, S>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kUniform));
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kUniform));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -801,8 +799,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructI32
// type a1 = S;
// var<uniform> g : a1;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty.type_name("S"));
GlobalVar("g", ty.type_name("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
Alias("a1", ty("S"));
GlobalVar("g", ty("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -812,8 +810,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructI32Al
// type a1 = S;
// type t = ptr<uniform, a1>;
Structure("S", utils::Vector{Member("x", ty.i32())});
Alias("a1", ty.type_name("S"));
Alias("t", ty.pointer(ty.type_name("a1"), type::AddressSpace::kUniform));
Alias("a1", ty("S"));
Alias("t", ty.pointer(ty("a1"), type::AddressSpace::kUniform));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -825,7 +823,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructF16
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
GlobalVar("g", ty.type_name("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
GlobalVar("g", ty("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -837,7 +835,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructF16)
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kUniform));
Alias("t", ty.pointer(ty("S"), type::AddressSpace::kUniform));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -850,8 +848,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructF16
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty.type_name("S"));
GlobalVar("g", ty.type_name("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
Alias("a1", ty("S"));
GlobalVar("g", ty("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -864,8 +862,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructF16Al
Enable(ast::Extension::kF16);
Structure("S", utils::Vector{Member("x", ty.f16())});
Alias("a1", ty.type_name("S"));
Alias("t", ty.pointer(ty.type_name("a1"), type::AddressSpace::kUniform));
Alias("a1", ty("S"));
Alias("t", ty.pointer(ty("a1"), type::AddressSpace::kUniform));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -995,7 +993,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantArrayF32)
// var<push_constant> g : array<S, 3u>;
Enable(ast::Extension::kChromiumExperimentalPushConstant);
Structure("S", utils::Vector{Member("a", ty.f32())});
GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kPushConstant);
GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kPushConstant);
ASSERT_TRUE(r()->Resolve()) << r()->error();
}
@ -1006,7 +1004,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantArrayF32) {
// type t = ptr<push_constant, array<S, 3u>>;
Enable(ast::Extension::kChromiumExperimentalPushConstant);
Structure("S", utils::Vector{Member("a", ty.f32())});
Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kPushConstant));
Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kPushConstant));
ASSERT_TRUE(r()->Resolve()) << r()->error();
}

View File

@ -724,8 +724,8 @@ TEST_F(ResolverAliasAnalysisTest, NoAccess_MemberAccessor) {
Structure("S", utils::Vector{Member("a", ty.i32())});
Func("f2",
utils::Vector{
Param("p1", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)),
Param("p2", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)),
Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)),
Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@ -734,7 +734,7 @@ TEST_F(ResolverAliasAnalysisTest, NoAccess_MemberAccessor) {
});
Func("f1", utils::Empty, ty.void_(),
utils::Vector{
Decl(Var("v", ty.type_name("S"))),
Decl(Var("v", ty("S"))),
CallStmt(Call("f2", AddressOf("v"), AddressOf("v"))),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -753,17 +753,17 @@ TEST_F(ResolverAliasAnalysisTest, Read_MemberAccessor) {
Structure("S", utils::Vector{Member("a", ty.i32())});
Func("f2",
utils::Vector{
Param("p1", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)),
Param("p2", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)),
Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)),
Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
Assign(Phony(), MemberAccessor(Deref("p2"), "a")),
Assign(Deref("p1"), Construct(ty.type_name("S"))),
Assign(Deref("p1"), Construct(ty("S"))),
});
Func("f1", utils::Empty, ty.void_(),
utils::Vector{
Decl(Var("v", ty.type_name("S"))),
Decl(Var("v", ty("S"))),
CallStmt(
Call("f2", AddressOf(Source{{12, 34}}, "v"), AddressOf(Source{{56, 76}}, "v"))),
});
@ -785,8 +785,8 @@ TEST_F(ResolverAliasAnalysisTest, Write_MemberAccessor) {
Structure("S", utils::Vector{Member("a", ty.i32())});
Func("f2",
utils::Vector{
Param("p1", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)),
Param("p2", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)),
Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)),
Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)),
},
ty.void_(),
utils::Vector{
@ -795,7 +795,7 @@ TEST_F(ResolverAliasAnalysisTest, Write_MemberAccessor) {
});
Func("f1", utils::Empty, ty.void_(),
utils::Vector{
Decl(Var("v", ty.type_name("S"))),
Decl(Var("v", ty("S"))),
CallStmt(
Call("f2", AddressOf(Source{{12, 34}}, "v"), AddressOf(Source{{56, 76}}, "v"))),
});

View File

@ -148,7 +148,7 @@ TEST_P(ResolverBitcastValidationTestInvalidDstTy, Test) {
// Use an alias so we can put a Source on the bitcast type
Alias("T", dst.ast(*this));
WrapInFunction(Bitcast(ty.type_name(Source{{12, 34}}, "T"), src.expr(*this, 0)));
WrapInFunction(Bitcast(ty(Source{{12, 34}}, "T"), src.expr(*this, 0)));
auto expected =
"12:34 error: cannot bitcast to '" + dst.sem(*this)->FriendlyName(Symbols()) + "'";

View File

@ -123,7 +123,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsFunctionUsedAsType) {
utils::Vector{
Return(1_i),
});
WrapInFunction(Construct(ty.type_name(Source{{56, 78}}, "mix")));
WrapInFunction(Construct(ty(Source{{56, 78}}, "mix")));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), R"(56:78 error: cannot use function 'mix' as type
@ -152,7 +152,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConstUsedAsVariab
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConstUsedAsType) {
GlobalConst(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i));
WrapInFunction(Construct(ty.type_name(Source{{56, 78}}, "mix")));
WrapInFunction(Construct(ty(Source{{56, 78}}, "mix")));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), R"(56:78 error: cannot use variable 'mix' as type
@ -182,7 +182,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVarUsedAsVariable
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVarUsedAsType) {
GlobalVar(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), type::AddressSpace::kPrivate);
WrapInFunction(Construct(ty.type_name(Source{{56, 78}}, "mix")));
WrapInFunction(Construct(ty(Source{{56, 78}}, "mix")));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), R"(56:78 error: cannot use variable 'mix' as type
@ -215,7 +215,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsAliasUsedAsVariable) {
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsAliasUsedAsType) {
auto* mix = Alias(Source{{12, 34}}, "mix", ty.i32());
auto* use = Construct(ty.type_name("mix"));
auto* use = Construct(ty("mix"));
WrapInFunction(use);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -249,7 +249,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsStructUsedAsType) {
auto* mix = Structure("mix", utils::Vector{
Member("m", ty.i32()),
});
auto* use = Construct(ty.type_name("mix"));
auto* use = Construct(ty("mix"));
WrapInFunction(use);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -695,9 +695,8 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_AtomicInStruct) {
// workgroupUniformLoad(&v);
// }
Structure("Inner", utils::Vector{Member("a", ty.array(ty.atomic<i32>(), 4_a))});
Structure("S", utils::Vector{Member("i", ty.type_name("Inner"))});
GlobalVar(Source{{12, 34}}, "v", ty.array(ty.type_name("S"), 4_a),
type::AddressSpace::kWorkgroup);
Structure("S", utils::Vector{Member("i", ty("Inner"))});
GlobalVar(Source{{12, 34}}, "v", ty.array(ty("S"), 4_a), type::AddressSpace::kWorkgroup);
WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf("v"))));
EXPECT_FALSE(r()->Resolve());

View File

@ -221,7 +221,7 @@ TEST_F(ResolverBuiltinsValidationTest, StructBuiltinInsideEntryPoint_Ignored) {
}),
});
Func("fragShader", utils::Empty, ty.void_(), utils::Vector{Decl(Var("s", ty.type_name("S")))},
Func("fragShader", utils::Empty, ty.void_(), utils::Vector{Decl(Var("s", ty("S")))},
utils::Vector{
Stage(ast::PipelineStage::kFragment),
});

View File

@ -1954,8 +1954,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_And_Error_StructInit) {
GlobalConst("one", Expr(1_a));
auto* lhs = Equal("one", 0_a);
auto* rhs = Equal(
MemberAccessor(Construct(ty.type_name("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"),
0_a);
MemberAccessor(Construct(ty("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"), 0_a);
GlobalConst("result", LogicalAnd(lhs, rhs));
EXPECT_FALSE(r()->Resolve());
@ -1975,8 +1974,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_Or_Error_StructInit) {
GlobalConst("one", Expr(1_a));
auto* lhs = Equal("one", 1_a);
auto* rhs = Equal(
MemberAccessor(Construct(ty.type_name("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"),
0_a);
MemberAccessor(Construct(ty("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"), 0_a);
GlobalConst("result", LogicalOr(lhs, rhs));
EXPECT_FALSE(r()->Resolve());
@ -2148,7 +2146,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_And_Error_MemberAccess) {
// const one = 1;
// const result = (one == 0) && (s.c == 0);
Structure("S", utils::Vector{Member("a", ty.i32()), Member("b", ty.f32())});
GlobalConst("s", Construct(ty.type_name("S"), Expr(1_a), Expr(2.0_a)));
GlobalConst("s", Construct(ty("S"), Expr(1_a), Expr(2.0_a)));
GlobalConst("one", Expr(1_a));
auto* lhs = Equal("one", 0_a);
auto* rhs = Equal(MemberAccessor(Source{{12, 34}}, "s", "c"), 0_a);
@ -2167,7 +2165,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_Or_Error_MemberAccess) {
// const one = 1;
// const result = (one == 1) || (s.c == 0);
Structure("S", utils::Vector{Member("a", ty.i32()), Member("b", ty.f32())});
GlobalConst("s", Construct(ty.type_name("S"), Expr(1_a), Expr(2.0_a)));
GlobalConst("s", Construct(ty("S"), Expr(1_a), Expr(2.0_a)));
GlobalConst("one", Expr(1_a));
auto* lhs = Equal("one", 1_a);
auto* rhs = Equal(MemberAccessor(Source{{12, 34}}, "s", "c"), 0_a);

View File

@ -1618,7 +1618,7 @@ TEST_F(ResolverConstEvalTest, Array_Struct_f32_Zero) {
Member("m1", ty.f32()),
Member("m2", ty.f32()),
});
auto* expr = Construct(ty.array(ty.type_name("S"), 2_u));
auto* expr = Construct(ty.array(ty("S"), 2_u));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1853,9 +1853,9 @@ TEST_F(ResolverConstEvalTest, Array_Struct_f32_Elements) {
Member("m1", ty.f32()),
Member("m2", ty.f32()),
});
auto* expr = Construct(ty.array(ty.type_name("S"), 2_u), //
Construct(ty.type_name("S"), 1_f, 2_f), //
Construct(ty.type_name("S"), 3_f, 4_f));
auto* expr = Construct(ty.array(ty("S"), 2_u), //
Construct(ty("S"), 1_f, 2_f), //
Construct(ty("S"), 3_f, 4_f));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1992,7 +1992,7 @@ TEST_F(ResolverConstEvalTest, Struct_Nested_ZeroInit) {
TEST_F(ResolverConstEvalTest, Struct_I32s_ZeroInit) {
Structure(
"S", utils::Vector{Member("m1", ty.i32()), Member("m2", ty.i32()), Member("m3", ty.i32())});
auto* expr = Construct(ty.type_name("S"));
auto* expr = Construct(ty("S"));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2037,7 +2037,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_ZeroInit) {
Member("m4", ty.f16()),
Member("m5", ty.bool_()),
});
auto* expr = Construct(ty.type_name("S"));
auto* expr = Construct(ty("S"));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2090,7 +2090,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) {
Member("m2", ty.vec3<f32>()),
Member("m3", ty.vec3<f32>()),
});
auto* expr = Construct(ty.type_name("S"));
auto* expr = Construct(ty("S"));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2147,7 +2147,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) {
Member("m4", ty.vec3<f16>()),
Member("m5", ty.vec2<bool>()),
});
auto* expr = Construct(ty.type_name("S"));
auto* expr = Construct(ty("S"));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2221,10 +2221,10 @@ TEST_F(ResolverConstEvalTest, Struct_Struct_ZeroInit) {
});
Structure("Outer", utils::Vector{
Member("m1", ty.type_name("Inner")),
Member("m2", ty.type_name("Inner")),
Member("m1", ty("Inner")),
Member("m2", ty("Inner")),
});
auto* expr = Construct(ty.type_name("Outer"));
auto* expr = Construct(ty("Outer"));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2267,7 +2267,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_Construct) {
Member("m4", ty.f16()),
Member("m5", ty.bool_()),
});
auto* expr = Construct(ty.type_name("S"), 1_i, 2_u, 3_f, 4_h, false);
auto* expr = Construct(ty("S"), 1_i, 2_u, 3_f, 4_h, false);
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2324,8 +2324,8 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) {
Member("m4", ty.vec3<f16>()),
Member("m5", ty.vec2<bool>()),
});
auto* expr = Construct(ty.type_name("S"), vec2<i32>(1_i), vec3<u32>(2_u), vec4<f32>(3_f),
vec3<f16>(4_h), vec2<bool>(false));
auto* expr = Construct(ty("S"), vec2<i32>(1_i), vec3<u32>(2_u), vec4<f32>(3_f), vec3<f16>(4_h),
vec2<bool>(false));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2399,12 +2399,12 @@ TEST_F(ResolverConstEvalTest, Struct_Struct_Construct) {
});
Structure("Outer", utils::Vector{
Member("m1", ty.type_name("Inner")),
Member("m2", ty.type_name("Inner")),
Member("m1", ty("Inner")),
Member("m2", ty("Inner")),
});
auto* expr = Construct(ty.type_name("Outer"), //
Construct(ty.type_name("Inner"), 1_i, 2_u, 3_f),
Construct(ty.type_name("Inner"), 4_i, 0_u, 6_f));
auto* expr =
Construct(ty("Outer"), //
Construct(ty("Inner"), 1_i, 2_u, 3_f), Construct(ty("Inner"), 4_i, 0_u, 6_f));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -2442,7 +2442,7 @@ TEST_F(ResolverConstEvalTest, Struct_Array_Construct) {
Member("m1", ty.array<i32, 2>()),
Member("m2", ty.array<f32, 3>()),
});
auto* expr = Construct(ty.type_name("S"), //
auto* expr = Construct(ty("S"), //
Construct(ty.array<i32, 2>(), 1_i, 2_i),
Construct(ty.array<f32, 3>(), 1_f, 2_f, 3_f));
WrapInFunction(expr);

View File

@ -28,12 +28,12 @@ TEST_F(ResolverConstEvalTest, StructMemberAccess) {
});
Structure("Outer", utils::Vector{
Member("o1", ty.type_name("Inner")),
Member("o2", ty.type_name("Inner")),
Member("o1", ty("Inner")),
Member("o2", ty("Inner")),
});
auto* outer_expr = Construct(ty.type_name("Outer"), //
Construct(ty.type_name("Inner"), 1_i, 2_u, 3_f, true),
Construct(ty.type_name("Inner")));
auto* outer_expr =
Construct(ty("Outer"), //
Construct(ty("Inner"), 1_i, 2_u, 3_f, true), Construct(ty("Inner")));
auto* o1_expr = MemberAccessor(outer_expr, "o1");
auto* i2_expr = MemberAccessor(o1_expr, "i2");
WrapInFunction(i2_expr);

View File

@ -468,12 +468,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
auto& b = *builder;
switch (kind) {
case SymbolUseKind::GlobalVarType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalVar(b.Sym(), node, type::AddressSpace::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarArrayElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalVar(b.Sym(), b.ty.array(node, 4_i), type::AddressSpace::kPrivate);
return node;
}
@ -483,22 +483,22 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::GlobalVarVectorElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalVar(b.Sym(), b.ty.vec3(node), type::AddressSpace::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarMatrixElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalVar(b.Sym(), b.ty.mat3x4(node), type::AddressSpace::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarSampledTexElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalVar(b.Sym(), b.ty.sampled_texture(type::TextureDimension::k2d, node));
return node;
}
case SymbolUseKind::GlobalVarMultisampledTexElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalVar(b.Sym(), b.ty.multisampled_texture(type::TextureDimension::k2d, node));
return node;
}
@ -508,12 +508,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::GlobalConstType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalConst(b.Sym(), node, b.Expr(1_i));
return node;
}
case SymbolUseKind::GlobalConstArrayElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalConst(b.Sym(), b.ty.array(node, 4_i), b.Expr(1_i));
return node;
}
@ -523,12 +523,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::GlobalConstVectorElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalConst(b.Sym(), b.ty.vec3(node), b.Expr(1_i));
return node;
}
case SymbolUseKind::GlobalConstMatrixElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.GlobalConst(b.Sym(), b.ty.mat3x4(node), b.Expr(1_i));
return node;
}
@ -538,12 +538,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::AliasType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.Alias(b.Sym(), node);
return node;
}
case SymbolUseKind::StructMemberType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
b.Structure(b.Sym(), utils::Vector{b.Member("m", node)});
return node;
}
@ -553,17 +553,17 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::ParameterType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
parameters.Push(b.Param(b.Sym(), node));
return node;
}
case SymbolUseKind::LocalVarType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
statements.Push(b.Decl(b.Var(b.Sym(), node)));
return node;
}
case SymbolUseKind::LocalVarArrayElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
statements.Push(b.Decl(b.Var(b.Sym(), b.ty.array(node, 4_u), b.Expr(1_i))));
return node;
}
@ -573,12 +573,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::LocalVarVectorElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
statements.Push(b.Decl(b.Var(b.Sym(), b.ty.vec3(node))));
return node;
}
case SymbolUseKind::LocalVarMatrixElemType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
statements.Push(b.Decl(b.Var(b.Sym(), b.ty.mat3x4(node))));
return node;
}
@ -588,7 +588,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::LocalLetType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
statements.Push(b.Decl(b.Let(b.Sym(), node, b.Expr(1_i))));
return node;
}
@ -598,7 +598,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::NestedLocalVarType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
nested_statements.Push(b.Decl(b.Var(b.Sym(), node)));
return node;
}
@ -608,7 +608,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
return node;
}
case SymbolUseKind::NestedLocalLetType: {
auto* node = b.ty.type_name(source, symbol);
auto* node = b.ty(source, symbol);
nested_statements.Push(b.Decl(b.Let(b.Sym(), node, b.Expr(1_i))));
return node;
}
@ -665,7 +665,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeConstructed) {
// type T = i32;
Func("F", utils::Empty, ty.void_(),
utils::Vector{Block(Ignore(Construct(ty.type_name(Source{{12, 34}}, "T"))))});
utils::Vector{Block(Ignore(Construct(ty(Source{{12, 34}}, "T"))))});
Alias(Source{{56, 78}}, "T", ty.i32());
Build();
@ -678,7 +678,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeUsedByLocal) {
// type T = i32;
Func("F", utils::Empty, ty.void_(),
utils::Vector{Block(Decl(Var("v", ty.type_name(Source{{12, 34}}, "T"))))});
utils::Vector{Block(Decl(Var("v", ty(Source{{12, 34}}, "T"))))});
Alias(Source{{56, 78}}, "T", ty.i32());
Build();
@ -688,8 +688,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeUsedByParam) {
// fn F(p : T) {}
// type T = i32;
Func("F", utils::Vector{Param("p", ty.type_name(Source{{12, 34}}, "T"))}, ty.void_(),
utils::Empty);
Func("F", utils::Vector{Param("p", ty(Source{{12, 34}}, "T"))}, ty.void_(), utils::Empty);
Alias(Source{{56, 78}}, "T", ty.i32());
Build();
@ -699,7 +698,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeUsedAsReturnType) {
// fn F() -> T {}
// type T = i32;
Func("F", utils::Empty, ty.type_name(Source{{12, 34}}, "T"), utils::Empty);
Func("F", utils::Empty, ty(Source{{12, 34}}, "T"), utils::Empty);
Alias(Source{{56, 78}}, "T", ty.i32());
Build();
@ -709,7 +708,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeByStructMember) {
// struct S { m : T };
// type T = i32;
Structure("S", utils::Vector{Member("m", ty.type_name(Source{{12, 34}}, "T"))});
Structure("S", utils::Vector{Member("m", ty(Source{{12, 34}}, "T"))});
Alias(Source{{56, 78}}, "T", ty.i32());
Build();
@ -848,7 +847,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, IndirectCall) {
TEST_F(ResolverDependencyGraphCyclicRefTest, Alias_Direct) {
// type T = T;
Alias(Source{{12, 34}}, "T", ty.type_name(Source{{56, 78}}, "T"));
Alias(Source{{12, 34}}, "T", ty(Source{{56, 78}}, "T"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -861,9 +860,9 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Alias_Indirect) {
// 2: type X = Y;
// 3: type Z = X;
Alias(Source{{1, 1}}, "Y", ty.type_name(Source{{1, 10}}, "Z"));
Alias(Source{{2, 1}}, "X", ty.type_name(Source{{2, 10}}, "Y"));
Alias(Source{{3, 1}}, "Z", ty.type_name(Source{{3, 10}}, "X"));
Alias(Source{{1, 1}}, "Y", ty(Source{{1, 10}}, "Z"));
Alias(Source{{2, 1}}, "X", ty(Source{{2, 10}}, "Y"));
Alias(Source{{3, 1}}, "Z", ty(Source{{3, 10}}, "X"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -878,8 +877,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Struct_Direct) {
// a: S;
// };
Structure(Source{{12, 34}}, "S",
utils::Vector{Member("a", ty.type_name(Source{{56, 78}}, "S"))});
Structure(Source{{12, 34}}, "S", utils::Vector{Member("a", ty(Source{{56, 78}}, "S"))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -892,9 +890,9 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Struct_Indirect) {
// 2: struct X { y: Y; };
// 3: struct Z { x: X; };
Structure(Source{{1, 1}}, "Y", utils::Vector{Member("z", ty.type_name(Source{{1, 10}}, "Z"))});
Structure(Source{{2, 1}}, "X", utils::Vector{Member("y", ty.type_name(Source{{2, 10}}, "Y"))});
Structure(Source{{3, 1}}, "Z", utils::Vector{Member("x", ty.type_name(Source{{3, 10}}, "X"))});
Structure(Source{{1, 1}}, "Y", utils::Vector{Member("z", ty(Source{{1, 10}}, "Z"))});
Structure(Source{{2, 1}}, "X", utils::Vector{Member("y", ty(Source{{2, 10}}, "Y"))});
Structure(Source{{3, 1}}, "Z", utils::Vector{Member("x", ty(Source{{3, 10}}, "X"))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -968,13 +966,13 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Mixed_RecursiveDependencies) {
// 5: type R = A;
// 6: const L : S = Z;
Func(Source{{1, 1}}, "F", utils::Empty, ty.type_name(Source{{1, 5}}, "R"),
Func(Source{{1, 1}}, "F", utils::Empty, ty(Source{{1, 5}}, "R"),
utils::Vector{Return(Expr(Source{{1, 10}}, "Z"))});
Alias(Source{{2, 1}}, "A", ty.type_name(Source{{2, 10}}, "S"));
Structure(Source{{3, 1}}, "S", utils::Vector{Member("a", ty.type_name(Source{{3, 10}}, "A"))});
Alias(Source{{2, 1}}, "A", ty(Source{{2, 10}}, "S"));
Structure(Source{{3, 1}}, "S", utils::Vector{Member("a", ty(Source{{3, 10}}, "A"))});
GlobalVar(Source{{4, 1}}, "Z", Expr(Source{{4, 10}}, "L"));
Alias(Source{{5, 1}}, "R", ty.type_name(Source{{5, 10}}, "A"));
GlobalConst(Source{{6, 1}}, "L", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z"));
Alias(Source{{5, 1}}, "R", ty(Source{{5, 10}}, "A"));
GlobalConst(Source{{6, 1}}, "L", ty(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -1232,7 +1230,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
return use;
};
#define V add_use(value_decl, Expr(value_sym), __LINE__, "V()")
#define T add_use(type_decl, ty.type_name(type_sym), __LINE__, "T()")
#define T add_use(type_decl, ty(type_sym), __LINE__, "T()")
#define F add_use(func_decl, Ident(func_sym), __LINE__, "F()")
Alias(Sym(), T);
@ -1334,9 +1332,9 @@ TEST_F(ResolverDependencyGraphTraversalTest, InferredType) {
TEST_F(ResolverDependencyGraphTraversalTest, chromium_1273451) {
Structure("A", utils::Vector{Member("a", ty.i32())});
Structure("B", utils::Vector{Member("b", ty.i32())});
Func("f", utils::Vector{Param("a", ty.type_name("A"))}, ty.type_name("B"),
Func("f", utils::Vector{Param("a", ty("A"))}, ty("B"),
utils::Vector{
Return(Construct(ty.type_name("B"))),
Return(Construct(ty("B"))),
});
Build();
}

View File

@ -270,7 +270,7 @@ TEST_F(ResolverEvaluationStageTest, MemberAccessor_Const) {
// const str = S();
// str.m
Structure("S", utils::Vector{Member("m", ty.i32())});
auto* str = Const("str", Construct(ty.type_name("S")));
auto* str = Const("str", Construct(ty("S")));
auto* expr = MemberAccessor(str, "m");
WrapInFunction(str, expr);
@ -284,7 +284,7 @@ TEST_F(ResolverEvaluationStageTest, MemberAccessor_Runtime) {
// var str = S();
// str.m
Structure("S", utils::Vector{Member("m", ty.i32())});
auto* str = Var("str", Construct(ty.type_name("S")));
auto* str = Var("str", Construct(ty("S")));
auto* expr = MemberAccessor(str, "m");
WrapInFunction(str, expr);

View File

@ -123,14 +123,14 @@ TEST_P(ResolverF16ExtensionShortNameTest, Vec2hTypeUsedWithExtension) {
// var<private> v : vec2h;
Enable(ast::Extension::kF16);
GlobalVar("v", ty.type_name(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate);
GlobalVar("v", ty(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_P(ResolverF16ExtensionShortNameTest, Vec2hTypeUsedWithoutExtension) {
// var<private> v : vec2h;
GlobalVar("v", ty.type_name(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate);
GlobalVar("v", ty(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled");

View File

@ -963,7 +963,7 @@ TEST_F(ResolverFunctionValidationTest, ReturnIsConstructible_StructOfAtomic) {
Structure("S", utils::Vector{
Member("m", ty.atomic(ty.i32())),
});
auto* ret_type = ty.type_name(Source{{12, 34}}, "S");
auto* ret_type = ty(Source{{12, 34}}, "S");
Func("f", utils::Empty, ret_type, utils::Empty);
EXPECT_FALSE(r()->Resolve());
@ -982,7 +982,7 @@ TEST_F(ResolverFunctionValidationTest, ParameterStoreType_NonAtomicFree) {
Structure("S", utils::Vector{
Member("m", ty.atomic(ty.i32())),
});
auto* ret_type = ty.type_name(Source{{12, 34}}, "S");
auto* ret_type = ty(Source{{12, 34}}, "S");
auto* bar = Param("bar", ret_type);
Func("f", utils::Vector{bar}, ty.void_(), utils::Empty);
@ -994,7 +994,7 @@ TEST_F(ResolverFunctionValidationTest, ParameterSotreType_AtomicFree) {
Structure("S", utils::Vector{
Member("m", ty.i32()),
});
auto* ret_type = ty.type_name(Source{{12, 34}}, "S");
auto* ret_type = ty(Source{{12, 34}}, "S");
auto* bar = Param(Source{{12, 34}}, "bar", ret_type);
Func("f", utils::Vector{bar}, ty.void_(), utils::Empty);

View File

@ -59,8 +59,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
TEST_F(ResolverHostShareableValidationTest, Aliases) {
Alias("a1", ty.bool_());
auto* s = Structure(
"S", utils::Vector{Member(Source{{56, 78}}, "x", ty.type_name(Source{{12, 34}}, "a1"))});
auto* s =
Structure("S", utils::Vector{Member(Source{{56, 78}}, "x", ty(Source{{12, 34}}, "a1"))});
auto* a2 = Alias("a2", ty.Of(s));
GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, type::Access::kRead,
Binding(0_a), Group(0_a));

View File

@ -350,7 +350,7 @@ TEST_P(MaterializeAbstractNumericToConcreteType, Test) {
break;
case Method::kStruct:
Structure("S", utils::Vector{Member("v", target_ty())});
WrapInFunction(Construct(ty.type_name("S"), abstract_expr));
WrapInFunction(Construct(ty("S"), abstract_expr));
break;
case Method::kBinaryOp: {
// Add 0 to ensure no overflow with max float values
@ -1218,7 +1218,7 @@ using MaterializeAbstractNumericToUnrelatedType = resolver::ResolverTest;
TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructVarInit) {
Structure("S", utils::Vector{Member("a", ty.i32())});
WrapInFunction(Decl(Var("v", ty.type_name("S"), Expr(Source{{12, 34}}, 1_a))));
WrapInFunction(Decl(Var("v", ty("S"), Expr(Source{{12, 34}}, 1_a))));
EXPECT_FALSE(r()->Resolve());
EXPECT_THAT(
r()->error(),
@ -1227,7 +1227,7 @@ TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructVarInit) {
TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructLetInit) {
Structure("S", utils::Vector{Member("a", ty.i32())});
WrapInFunction(Decl(Let("v", ty.type_name("S"), Expr(Source{{12, 34}}, 1_a))));
WrapInFunction(Decl(Let("v", ty("S"), Expr(Source{{12, 34}}, 1_a))));
EXPECT_FALSE(r()->Resolve());
EXPECT_THAT(
r()->error(),

View File

@ -249,7 +249,7 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_ViaArraySize_Alias) {
auto* a = Override("a", ty.i32());
auto* b = Override("b", ty.i32(), Mul(2_a, "a"));
auto* arr_ty = Alias("arr_ty", ty.array(ty.i32(), Mul(2_a, "b")));
auto* arr = GlobalVar("arr", type::AddressSpace::kWorkgroup, ty.type_name("arr_ty"));
auto* arr = GlobalVar("arr", type::AddressSpace::kWorkgroup, ty("arr_ty"));
Override("unused", ty.i32(), Expr(1_a));
auto* func = Func("foo", utils::Empty, ty.void_(),
utils::Vector{
@ -294,8 +294,8 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_MultipleEntryPoints) {
auto* d = Override("d", ty.i32());
Alias("arr_ty1", ty.array(ty.i32(), Mul("b1", "c1")));
Alias("arr_ty2", ty.array(ty.i32(), Mul("b2", "c2")));
auto* arr1 = GlobalVar("arr1", type::AddressSpace::kWorkgroup, ty.type_name("arr_ty1"));
auto* arr2 = GlobalVar("arr2", type::AddressSpace::kWorkgroup, ty.type_name("arr_ty2"));
auto* arr1 = GlobalVar("arr1", type::AddressSpace::kWorkgroup, ty("arr_ty1"));
auto* arr2 = GlobalVar("arr2", type::AddressSpace::kWorkgroup, ty("arr_ty2"));
Override("unused", ty.i32(), Expr(1_a));
auto* func1 = Func("foo1", utils::Empty, ty.void_(),
utils::Vector{

View File

@ -565,7 +565,7 @@ struct DataType<alias<T, ID>> {
auto* type = DataType<T>::AST(b);
b.AST().AddTypeDecl(b.ty.alias(name, type));
}
return b.ty.type_name(name);
return b.ty(name);
}
/// @param b the ProgramBuilder
/// @return the semantic aliased type

View File

@ -362,7 +362,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_NestedStorageBufferLargeArray) {
// var<storage> a : S;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "a",
ty.array(Source{{12, 20}}, ty.f32(), 65536_a))});
GlobalVar("a", ty.type_name(Source{{12, 30}}, "S"), type::AddressSpace::kStorage,
GlobalVar("a", ty(Source{{12, 30}}, "S"), type::AddressSpace::kStorage,
utils::Vector{Binding(0_u), Group(0_u)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -374,7 +374,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {
// var<private> a : array<S, 65535>;
Structure("S", utils::Vector{Member(Source{{12, 34}}, "a", ty.f32(),
utils::Vector{MemberOffset(800000_a)})});
GlobalVar("a", ty.array(ty.type_name(Source{{12, 30}}, "S"), Expr(Source{{12, 34}}, 65535_a)),
GlobalVar("a", ty.array(ty(Source{{12, 30}}, "S"), Expr(Source{{12, 34}}, 65535_a)),
type::AddressSpace::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -640,11 +640,11 @@ TEST_F(ResolverTypeValidationTest, Struct_TooBig) {
// }
Structure(Source{{10, 34}}, "Bar", utils::Vector{Member("a", ty.array<f32, 10000>())});
Structure(Source{{12, 34}}, "Foo",
utils::Vector{Member("a", ty.array(ty.type_name(Source{{12, 30}}, "Bar"),
Expr(Source{{12, 34}}, 65535_a))),
Member("b", ty.array(ty.type_name(Source{{12, 30}}, "Bar"),
Expr(Source{{12, 34}}, 65535_a)))});
Structure(
Source{{12, 34}}, "Foo",
utils::Vector{
Member("a", ty.array(ty(Source{{12, 30}}, "Bar"), Expr(Source{{12, 34}}, 65535_a))),
Member("b", ty.array(ty(Source{{12, 30}}, "Bar"), Expr(Source{{12, 34}}, 65535_a)))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -705,8 +705,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInArray) {
// var<private> a : array<Foo, 4>;
Structure("Foo", utils::Vector{Member("rt", ty.array<f32>())});
GlobalVar("v", ty.array(ty.type_name(Source{{12, 34}}, "Foo"), 4_u),
type::AddressSpace::kPrivate);
GlobalVar("v", ty.array(ty(Source{{12, 34}}, "Foo"), 4_u), type::AddressSpace::kPrivate);
EXPECT_FALSE(r()->Resolve()) << r()->error();
EXPECT_EQ(r()->error(),
@ -886,7 +885,7 @@ TEST_F(ResolverTypeValidationTest, VariableAsType) {
// var<private> a : i32;
// var<private> b : a;
GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate);
GlobalVar("b", ty.type_name("a"), type::AddressSpace::kPrivate);
GlobalVar("b", ty("a"), type::AddressSpace::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -898,7 +897,7 @@ TEST_F(ResolverTypeValidationTest, FunctionAsType) {
// fn f() {}
// var<private> v : f;
Func("f", utils::Empty, ty.void_(), {});
GlobalVar("v", ty.type_name("f"), type::AddressSpace::kPrivate);
GlobalVar("v", ty("f"), type::AddressSpace::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -908,7 +907,7 @@ note: 'f' declared here)");
TEST_F(ResolverTypeValidationTest, BuiltinAsType) {
// var<private> v : max;
GlobalVar("v", ty.type_name("max"), type::AddressSpace::kPrivate);
GlobalVar("v", ty("max"), type::AddressSpace::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "error: cannot use builtin 'max' as type");
@ -1426,7 +1425,7 @@ TEST_P(BuiltinTypeAliasTest, CheckEquivalent) {
Enable(ast::Extension::kF16);
WrapInFunction(Decl(Var("aliased", ty.type_name(params.alias))),
WrapInFunction(Decl(Var("aliased", ty(params.alias))),
Decl(Var("explicit", params.type(*this))), //
Assign("explicit", "aliased"));
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1438,7 +1437,7 @@ TEST_P(BuiltinTypeAliasTest, Construct) {
Enable(ast::Extension::kF16);
WrapInFunction(Decl(Var("v", params.type(*this), Construct(ty.type_name(params.alias)))));
WrapInFunction(Decl(Var("v", params.type(*this), Construct(ty(params.alias)))));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,

View File

@ -902,7 +902,7 @@ TEST_F(ResolverVariableTest, LocalConst_ExplicitType_Decls) {
auto* c_vu32 = Const("e", ty.vec3<u32>(), vec3<u32>());
auto* c_vf32 = Const("f", ty.vec3<f32>(), vec3<f32>());
auto* c_mf32 = Const("g", ty.mat3x3<f32>(), mat3x3<f32>());
auto* c_s = Const("h", ty.type_name("S"), Construct(ty.type_name("S")));
auto* c_s = Const("h", ty("S"), Construct(ty("S")));
WrapInFunction(c_i32, c_u32, c_f32, c_vi32, c_vu32, c_vf32, c_mf32, c_s);
@ -954,7 +954,7 @@ TEST_F(ResolverVariableTest, LocalConst_ImplicitType_Decls) {
Construct(ty.vec(nullptr, 3), Expr(0._a)),
Construct(ty.vec(nullptr, 3), Expr(0._a)),
Construct(ty.vec(nullptr, 3), Expr(0._a))));
auto* c_s = Const("m", Construct(ty.type_name("S")));
auto* c_s = Const("m", Construct(ty("S")));
WrapInFunction(c_i32, c_u32, c_f32, c_ai, c_af, c_vi32, c_vu32, c_vf32, c_vai, c_vaf, c_mf32,
c_maf32, c_s);
@ -1265,7 +1265,7 @@ TEST_F(ResolverVariableTest, Param_ShadowsAlias) {
// }
auto* a = Alias("a", ty.i32());
auto* p = Param("a", ty.type_name("a"));
auto* p = Param("a", ty("a"));
Func("F", utils::Vector{p}, ty.void_(), utils::Empty);
ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -459,7 +459,7 @@ struct CanonicalizeEntryPointIO::State {
ctx.InsertBefore(ctx.src->AST().GlobalDeclarations(), func_ast, in_struct);
// Create a new function parameter using this struct type.
auto* param = ctx.dst->Param(InputStructSymbol(), ctx.dst->ty.type_name(struct_name));
auto* param = ctx.dst->Param(InputStructSymbol(), ctx.dst->ty(struct_name));
wrapper_ep_parameters.Push(param);
}
@ -503,7 +503,7 @@ struct CanonicalizeEntryPointIO::State {
ctx.InsertBefore(ctx.src->AST().GlobalDeclarations(), func_ast, out_struct);
// Create the output struct object, assign its members, and return it.
auto* result_object = ctx.dst->Var(wrapper_result, ctx.dst->ty.type_name(out_struct->name));
auto* result_object = ctx.dst->Var(wrapper_result, ctx.dst->ty(out_struct->name));
wrapper_body.Push(ctx.dst->Decl(result_object));
for (auto* assignment : assignments) {
wrapper_body.Push(assignment);
@ -633,9 +633,7 @@ struct CanonicalizeEntryPointIO::State {
CreateGlobalOutputVariables();
} else {
auto* output_struct = CreateOutputStruct();
wrapper_ret_type = [&, output_struct] {
return ctx.dst->ty.type_name(output_struct->name);
};
wrapper_ret_type = [&, output_struct] { return ctx.dst->ty(output_struct->name); };
}
}

View File

@ -124,7 +124,7 @@ Transform::ApplyResult ClampFragDepth::Apply(const Program* src, const DataMap&,
utils::Vector{b.Member("min", b.ty.f32()), b.Member("max", b.ty.f32())});
auto args_sym = b.Symbols().New("frag_depth_clamp_args");
b.GlobalVar(args_sym, b.ty.type_name("FragDepthClampArgs"), type::AddressSpace::kPushConstant);
b.GlobalVar(args_sym, b.ty("FragDepthClampArgs"), type::AddressSpace::kPushConstant);
auto base_fn_sym = b.Symbols().New("clamp_frag_depth");
b.Func(base_fn_sym, utils::Vector{b.Param("v", b.ty.f32())}, b.ty.f32(),

View File

@ -87,7 +87,7 @@ Transform::ApplyResult DecomposeStridedArray::Apply(const Program* src,
return name;
});
auto* count = ctx.Clone(ast->count);
return b.ty.array(b.ty.type_name(el_ty), count);
return b.ty.array(b.ty(el_ty), count);
}
if (ast::GetAttribute<ast::StrideAttribute>(ast->attributes)) {
// Strip the @stride attribute

View File

@ -510,16 +510,15 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
// }
ProgramBuilder b;
b.Alias("ARR", b.ty.array<f32, 4u>(32));
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR"))});
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR"))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
b.Decl(b.Let("a", b.ty.type_name("ARR"), b.MemberAccessor("s", "a"))),
b.Decl(b.Let("a", b.ty("ARR"), b.MemberAccessor("s", "a"))),
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR"))),
b.Assign(b.MemberAccessor("s", "a"),
b.Construct(b.ty.type_name("ARR"), 1_f, 2_f, 3_f, 4_f)),
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR"))),
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR"), 1_f, 2_f, 3_f, 4_f)),
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
},
utils::Vector{
@ -578,19 +577,19 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
b.Alias("ARR_A", b.ty.array<f32, 2>(8));
b.Alias("ARR_B",
b.ty.array( //
b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), //
b.ty.array(b.ty("ARR_A"), 3_u, 16), //
4_u, 128));
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR_B"))});
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR_B"))});
b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite,
b.Group(0_a), b.Binding(0_a));
b.Func("f", utils::Empty, b.ty.void_(),
utils::Vector{
b.Decl(b.Let("a", b.ty.type_name("ARR_B"), b.MemberAccessor("s", "a"))),
b.Decl(b.Let("b", b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16),
b.Decl(b.Let("a", b.ty("ARR_B"), b.MemberAccessor("s", "a"))),
b.Decl(b.Let("b", b.ty.array(b.ty("ARR_A"), 3_u, 16),
b.IndexAccessor( //
b.MemberAccessor("s", "a"), //
3_i))),
b.Decl(b.Let("c", b.ty.type_name("ARR_A"),
b.Decl(b.Let("c", b.ty("ARR_A"),
b.IndexAccessor( //
b.IndexAccessor( //
b.MemberAccessor("s", "a"), //
@ -604,7 +603,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
3_i),
2_i),
1_i))),
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR_B"))),
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR_B"))),
b.Assign(b.IndexAccessor( //
b.IndexAccessor( //
b.IndexAccessor( //

View File

@ -187,7 +187,7 @@ Transform::ApplyResult DemoteToHelper::Apply(const Program* src, const DataMap&,
// Declare a struct to hold the result values.
auto* result_struct = sem_call->Type()->As<sem::Struct>();
auto* atomic_ty = result_struct->Members()[0]->Type();
result_ty = b.ty.type_name(
result_ty = b.ty(
utils::GetOrCreate(atomic_cmpxchg_result_types, atomic_ty, [&]() {
auto name = b.Sym();
b.Structure(

View File

@ -1075,7 +1075,7 @@ struct DirectVariableAccess::State {
b.Alias(symbol, b.ty.array(b.ty.u32(), u32(num_dyn_indices)));
return symbol;
});
return name.IsValid() ? b.ty.type_name(name) : nullptr;
return name.IsValid() ? b.ty(name) : nullptr;
}
/// @returns a name describing the given shape

View File

@ -144,9 +144,8 @@ struct MultiplanarExternalTexture::State {
b.GlobalVar(syms.plane_1, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()),
b.Group(AInt(bps.plane_1.group)), b.Binding(AInt(bps.plane_1.binding)));
syms.params = b.Symbols().New("ext_tex_params");
b.GlobalVar(syms.params, b.ty.type_name("ExternalTextureParams"),
type::AddressSpace::kUniform, b.Group(AInt(bps.params.group)),
b.Binding(AInt(bps.params.binding)));
b.GlobalVar(syms.params, b.ty("ExternalTextureParams"), type::AddressSpace::kUniform,
b.Group(AInt(bps.params.group)), b.Binding(AInt(bps.params.binding)));
// Replace the original texture_external binding with a texture_2d<f32> binding.
auto cloned_attributes = ctx.Clone(global->attributes);
@ -184,7 +183,7 @@ struct MultiplanarExternalTexture::State {
ctx.Replace(param, b.Param(syms.plane_0, tex2d_f32()));
ctx.InsertAfter(fn->params, param, b.Param(syms.plane_1, tex2d_f32()));
ctx.InsertAfter(fn->params, param,
b.Param(syms.params, b.ty.type_name(params_struct_sym)));
b.Param(syms.params, b.ty(params_struct_sym)));
}
}
}
@ -261,8 +260,8 @@ struct MultiplanarExternalTexture::State {
b.Member("numPlanes", b.ty.u32()),
b.Member("doYuvToRgbConversionOnly", b.ty.u32()),
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4<f32>()),
b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
b.Member("gammaDecodeParams", b.ty("GammaTransferParams")),
b.Member("gammaEncodeParams", b.ty("GammaTransferParams")),
b.Member("gamutConversionMatrix", b.ty.mat3x3<f32>()),
b.Member("coordTransformationMatrix", b.ty.mat3x2<f32>())};
@ -280,7 +279,7 @@ struct MultiplanarExternalTexture::State {
gamma_correction_sym,
utils::Vector{
b.Param("v", b.ty.vec3<f32>()),
b.Param("params", b.ty.type_name(gamma_transfer_struct_sym)),
b.Param("params", b.ty(gamma_transfer_struct_sym)),
},
b.ty.vec3<f32>(),
utils::Vector{
@ -428,7 +427,7 @@ struct MultiplanarExternalTexture::State {
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
b.Param("smp", b.ty.sampler(type::SamplerKind::kSampler)),
b.Param("coord", b.ty.vec2(b.ty.f32())),
b.Param("params", b.ty.type_name(params_struct_sym)),
b.Param("params", b.ty(params_struct_sym)),
},
b.ty.vec4(b.ty.f32()),
buildTextureBuiltinBody(sem::BuiltinType::kTextureSampleBaseClampToEdge));
@ -475,7 +474,7 @@ struct MultiplanarExternalTexture::State {
b.Param("plane1",
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
b.Param("coord", CreateASTTypeFor(ctx, coord_ty)),
b.Param("params", b.ty.type_name(params_struct_sym)),
b.Param("params", b.ty(params_struct_sym)),
},
b.ty.vec4(b.ty.f32()), //
buildTextureBuiltinBody(sem::BuiltinType::kTextureLoad));

View File

@ -197,7 +197,7 @@ struct SpirvAtomic::State {
ty, //
[&](const type::I32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); },
[&](const type::U32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); },
[&](const sem::Struct* str) { return b.ty.type_name(Fork(str->Declaration()).name); },
[&](const sem::Struct* str) { return b.ty(Fork(str->Declaration()).name); },
[&](const type::Array* arr) -> const ast::Type* {
if (arr->Count()->Is<type::RuntimeArrayCount>()) {
return b.ty.array(AtomicTypeFor(arr->ElemType()));

View File

@ -405,7 +405,7 @@ struct Std140::State {
ty, //
[&](const sem::Struct* str) -> const ast::Type* {
if (auto std140 = std140_structs.Find(str)) {
return b.ty.type_name(*std140);
return b.ty(*std140);
}
return nullptr;
},
@ -423,7 +423,7 @@ struct Std140::State {
utils::Transform(members, [&](auto* member) { return member->symbol; }),
};
});
return b.ty.type_name(std140_mat.name);
return b.ty(std140_mat.name);
}
return nullptr;
},

View File

@ -122,7 +122,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type
if (auto* alias = type_decl->As<ast::Alias>()) {
if (ty == ctx.src->Sem().Get(alias)) {
// Alias found. Use the alias name to ensure types compare equal.
return ctx.dst->ty.type_name(ctx.Clone(alias->name));
return ctx.dst->ty(ctx.Clone(alias->name));
}
}
}
@ -138,7 +138,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type
return ctx.dst->ty.array(el, u32(count.value()), std::move(attrs));
}
if (auto* s = ty->As<sem::Struct>()) {
return ctx.dst->ty.type_name(ctx.Clone(s->Declaration()->name));
return ctx.dst->ty(ctx.Clone(s->Declaration()->name));
}
if (auto* s = ty->As<type::Reference>()) {
return CreateASTTypeFor(ctx, s->StoreType());

View File

@ -139,15 +139,15 @@ Transform::ApplyResult TruncateInterstageVariables::Apply(const Program* src,
// Create the mapping function to truncate the shader io.
auto mapping_fn_sym = b.Symbols().New("truncate_shader_output");
b.Func(mapping_fn_sym,
utils::Vector{b.Param("io", ctx.Clone(func_ast->return_type))},
b.ty.type_name(new_struct_sym),
utils::Vector{b.Return(b.Construct(b.ty.type_name(new_struct_sym),
std::move(initializer_exprs)))});
b.Func(
mapping_fn_sym, utils::Vector{b.Param("io", ctx.Clone(func_ast->return_type))},
b.ty(new_struct_sym),
utils::Vector{
b.Return(b.Construct(b.ty(new_struct_sym), std::move(initializer_exprs)))});
return TruncatedStructAndConverter{new_struct_sym, mapping_fn_sym};
});
ctx.Replace(func_ast->return_type, b.ty.type_name(entry.truncated_struct));
ctx.Replace(func_ast->return_type, b.ty(entry.truncated_struct));
entry_point_functions_to_truncate_functions.Add(func_sem, entry.truncate_fn);
}

View File

@ -60,7 +60,7 @@ TEST_F(TypeStructTest, Layout) {
});
auto* outer_st = Structure("Outer", utils::Vector{
Member("inner", ty.type_name("Inner")),
Member("inner", ty("Inner")),
Member("a", ty.i32()),
});
@ -118,13 +118,13 @@ TEST_F(TypeStructTest, IsConstructable) {
});
auto* outer = Structure("Outer", utils::Vector{
Member("inner", ty.type_name("Inner")),
Member("inner", ty("Inner")),
Member("a", ty.i32()),
});
auto* outer_runtime_sized_array =
Structure("OuterRuntimeSizedArray", utils::Vector{
Member("inner", ty.type_name("Inner")),
Member("inner", ty("Inner")),
Member("a", ty.i32()),
Member("runtime_sized_array", ty.array<i32>()),
});
@ -152,12 +152,12 @@ TEST_F(TypeStructTest, HasCreationFixedFootprint) {
});
auto* outer = Structure("Outer", utils::Vector{
Member("inner", ty.type_name("Inner")),
Member("inner", ty("Inner")),
});
auto* outer_with_runtime_sized_array =
Structure("OuterRuntimeSizedArray", utils::Vector{
Member("inner", ty.type_name("Inner")),
Member("inner", ty("Inner")),
Member("runtime_sized_array", ty.array<i32>()),
});
@ -185,12 +185,12 @@ TEST_F(TypeStructTest, HasFixedFootprint) {
});
auto* outer = Structure("Outer", utils::Vector{
Member("inner", ty.type_name("Inner")),
Member("inner", ty("Inner")),
});
auto* outer_with_runtime_sized_array =
Structure("OuterRuntimeSizedArray", utils::Vector{
Member("inner", ty.type_name("Inner")),
Member("inner", ty("Inner")),
Member("runtime_sized_array", ty.array<i32>()),
});

View File

@ -411,7 +411,7 @@ void f() {
TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_struct_zero) {
Structure("S", utils::Vector{Member("a", ty.i32()), Member("b", ty.f32())});
auto* C = Const("C", Construct(ty.array(ty.type_name("S"), 2_i)));
auto* C = Const("C", Construct(ty.array(ty("S"), 2_i)));
Func("f", utils::Empty, ty.void_(),
utils::Vector{
Decl(C),

View File

@ -262,9 +262,9 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrixInStruct) {
Member("m2", ty.mat4x4<f32>()),
});
Structure("S2", utils::Vector{
Member("s", ty.type_name("S1")),
Member("s", ty("S1")),
});
GlobalVar("s", ty.type_name("S2"), type::AddressSpace::kWorkgroup);
GlobalVar("s", ty("S2"), type::AddressSpace::kWorkgroup);
Func("comp_main", utils::Empty, ty.void_(), utils::Vector{Decl(Let("x", Expr("s")))},
utils::Vector{
Stage(ast::PipelineStage::kCompute),