Add ProgramBuilder::Alias()
Combines the calls to ty.alias() and AST().AddConstructedType() Change-Id: I84eaf6275d37141cf8973db7e04d25d9cb9c6351 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53801 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
3b26717377
commit
6e7d24d36a
|
@ -35,7 +35,7 @@ using AstAliasTest = TestHelper;
|
|||
|
||||
TEST_F(AstAliasTest, Create) {
|
||||
auto* u32 = create<U32>();
|
||||
auto* a = create<Alias>(Sym("a_type"), u32);
|
||||
auto* a = Alias("a_type", u32);
|
||||
EXPECT_EQ(a->symbol(), Symbol(1, ID()));
|
||||
EXPECT_EQ(a->type(), u32);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ TEST_F(AstAliasTest, Create) {
|
|||
TEST_F(AstAliasTest, TypeName_LinearTime) {
|
||||
Type* type = ty.i32();
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
type = create<Alias>(Symbols().New(), type);
|
||||
type = Alias(Symbols().New(), type);
|
||||
}
|
||||
for (int i = 0; i < 16384; i++) {
|
||||
type->type_name();
|
||||
|
@ -54,22 +54,22 @@ TEST_F(AstAliasTest, TypeName_LinearTime) {
|
|||
}
|
||||
|
||||
TEST_F(AstAliasTest, TypeName) {
|
||||
auto* at = create<Alias>(Sym("Particle"), create<I32>());
|
||||
auto* at = Alias("Particle", create<I32>());
|
||||
EXPECT_EQ(at->type_name(), "__alias_$1__i32");
|
||||
}
|
||||
|
||||
TEST_F(AstAliasTest, FriendlyName) {
|
||||
auto* at = create<Alias>(Sym("Particle"), create<I32>());
|
||||
auto* at = Alias("Particle", create<I32>());
|
||||
EXPECT_EQ(at->FriendlyName(Symbols()), "Particle");
|
||||
}
|
||||
|
||||
TEST_F(AstAliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
|
||||
auto* u32 = create<U32>();
|
||||
auto* a = create<Alias>(Sym("a_type"), u32);
|
||||
auto* aa = create<Alias>(Sym("aa_type"), a);
|
||||
auto* a = create<ast::Alias>(Sym("a_type"), u32);
|
||||
auto* aa = create<ast::Alias>(Sym("aa_type"), a);
|
||||
auto* paa = create<Pointer>(aa, StorageClass::kUniform, Access::kUndefined);
|
||||
auto* apaa = create<Alias>(Sym("paa_type"), paa);
|
||||
auto* aapaa = create<Alias>(Sym("aapaa_type"), apaa);
|
||||
auto* apaa = create<ast::Alias>(Sym("paa_type"), paa);
|
||||
auto* aapaa = create<ast::Alias>(Sym("aapaa_type"), apaa);
|
||||
|
||||
EXPECT_EQ(aapaa->symbol(), Symbol(4, ID()));
|
||||
EXPECT_EQ(aapaa->type(), apaa);
|
||||
|
|
|
@ -1620,6 +1620,29 @@ class ProgramBuilder {
|
|||
return create<ast::ReturnStatement>(Expr(std::forward<EXPR>(val)));
|
||||
}
|
||||
|
||||
/// Creates a ast::Alias registering it with the AST().ConstructedTypes().
|
||||
/// @param source the source information
|
||||
/// @param name the alias name
|
||||
/// @param type the alias target type
|
||||
/// @returns the alias type
|
||||
template <typename NAME>
|
||||
ast::Alias* Alias(const Source& source, NAME&& name, ast::Type* type) {
|
||||
auto* out = ty.alias(source, std::forward<NAME>(name), type);
|
||||
AST().AddConstructedType(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Creates a ast::Alias registering it with the AST().ConstructedTypes().
|
||||
/// @param name the alias name
|
||||
/// @param type the alias target type
|
||||
/// @returns the alias type
|
||||
template <typename NAME>
|
||||
ast::Alias* Alias(NAME&& name, ast::Type* type) {
|
||||
auto* out = ty.alias(std::forward<NAME>(name), type);
|
||||
AST().AddConstructedType(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Creates a ast::Struct registering it with the AST().ConstructedTypes().
|
||||
/// @param source the source information
|
||||
/// @param name the struct name
|
||||
|
|
|
@ -111,8 +111,7 @@ TEST_F(ResolverAssignmentValidationTest,
|
|||
// alias myint = i32;
|
||||
// var a : myint = 2;
|
||||
// a = 2
|
||||
auto* myint = ty.alias("myint", ty.i32());
|
||||
AST().AddConstructedType(myint);
|
||||
auto* myint = Alias("myint", ty.i32());
|
||||
auto* var = Var("a", myint, ast::StorageClass::kNone, Expr(2));
|
||||
WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2));
|
||||
|
||||
|
|
|
@ -294,7 +294,7 @@ TEST_F(ResolverControlBlockValidationTest, SwitchCaseAlias_Pass) {
|
|||
// default: {}
|
||||
// }
|
||||
|
||||
auto* my_int = ty.alias("MyInt", ty.u32());
|
||||
auto* my_int = Alias("MyInt", ty.u32());
|
||||
auto* var = Var("a", my_int, ast::StorageClass::kNone, Expr(2u));
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
|
@ -304,7 +304,6 @@ TEST_F(ResolverControlBlockValidationTest, SwitchCaseAlias_Pass) {
|
|||
default_csl, block_default));
|
||||
|
||||
auto* block = Block(Decl(var), create<ast::SwitchStatement>(Expr("a"), body));
|
||||
AST().AddConstructedType(my_int);
|
||||
|
||||
WrapInFunction(block);
|
||||
|
||||
|
|
|
@ -230,8 +230,7 @@ TEST_F(ResolverFunctionValidationTest,
|
|||
FunctionTypeMustMatchReturnStatementTypeF32Alias_pass) {
|
||||
// type myf32 = f32;
|
||||
// fn func -> myf32 { return 2.0; }
|
||||
auto* myf32 = ty.alias("myf32", ty.f32());
|
||||
AST().AddConstructedType(myf32);
|
||||
auto* myf32 = Alias("myf32", ty.f32());
|
||||
Func("func", ast::VariableList{}, myf32,
|
||||
ast::StatementList{
|
||||
Return(Source{Source::Location{12, 34}}, Expr(2.f)),
|
||||
|
@ -245,8 +244,7 @@ TEST_F(ResolverFunctionValidationTest,
|
|||
FunctionTypeMustMatchReturnStatementTypeF32Alias_fail) {
|
||||
// type myf32 = f32;
|
||||
// fn func -> myf32 { return 2; }
|
||||
auto* myf32 = ty.alias("myf32", ty.f32());
|
||||
AST().AddConstructedType(myf32);
|
||||
auto* myf32 = Alias("myf32", ty.f32());
|
||||
Func("func", ast::VariableList{}, myf32,
|
||||
ast::StatementList{
|
||||
Return(Source{Source::Location{12, 34}}, Expr(2u)),
|
||||
|
|
|
@ -66,12 +66,10 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverHostShareableValidationTest, Aliases) {
|
||||
auto* a1 = ty.alias("a1", ty.bool_());
|
||||
AST().AddConstructedType(a1);
|
||||
auto* a1 = Alias("a1", ty.bool_());
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", a1)},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto* a2 = ty.alias("a2", s);
|
||||
AST().AddConstructedType(a2);
|
||||
auto* a2 = Alias("a2", s);
|
||||
Global(Source{{56, 78}}, "g", a2, ast::StorageClass::kStorage,
|
||||
ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
|
@ -122,14 +120,12 @@ TEST_F(ResolverHostShareableValidationTest, NoError) {
|
|||
Member(Source{{2, 1}}, "y1", ty.vec3<f32>()),
|
||||
Member(Source{{3, 1}}, "z1", ty.array<i32, 4>()),
|
||||
});
|
||||
auto* a1 = ty.alias("a1", i1);
|
||||
AST().AddConstructedType(a1);
|
||||
auto* a1 = Alias("a1", i1);
|
||||
auto* i2 = Structure("I2", {
|
||||
Member(Source{{4, 1}}, "x2", ty.mat2x2<f32>()),
|
||||
Member(Source{{5, 1}}, "y2", i1),
|
||||
});
|
||||
auto* a2 = ty.alias("a2", i2);
|
||||
AST().AddConstructedType(a2);
|
||||
auto* a2 = Alias("a2", i2);
|
||||
auto* i3 = Structure("I3", {
|
||||
Member(Source{{4, 1}}, "x3", a1),
|
||||
Member(Source{{5, 1}}, "y3", i2),
|
||||
|
|
|
@ -293,8 +293,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
||||
auto* my_int = ty.alias("MyInt", ty.i32());
|
||||
AST().AddConstructedType(my_int);
|
||||
auto* my_int = Alias("MyInt", ty.i32());
|
||||
auto* var = Var("my_var", my_int, ast::StorageClass::kNone, Expr(2));
|
||||
auto* init = var->constructor();
|
||||
|
||||
|
@ -308,10 +307,8 @@ TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Stmt_VariableDecl_AliasRedeclared) {
|
||||
auto* my_int1 = ty.alias(Source{{12, 34}}, "MyInt", ty.i32());
|
||||
auto* my_int2 = ty.alias(Source{{56, 78}}, "MyInt", ty.i32());
|
||||
AST().AddConstructedType(my_int1);
|
||||
AST().AddConstructedType(my_int2);
|
||||
Alias(Source{{12, 34}}, "MyInt", ty.i32());
|
||||
Alias(Source{{56, 78}}, "MyInt", ty.i32());
|
||||
WrapInFunction();
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -450,8 +447,7 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Array) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_ArrayAccessor_Alias_Array) {
|
||||
auto* aary = ty.alias("myarrty", ty.array<f32, 3>());
|
||||
AST().AddConstructedType(aary);
|
||||
auto* aary = Alias("myarrty", ty.array<f32, 3>());
|
||||
|
||||
Global("my_var", aary, ast::StorageClass::kPrivate);
|
||||
|
||||
|
@ -1124,8 +1120,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct) {
|
|||
TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) {
|
||||
auto* st = Structure("S", {Member("first_member", ty.i32()),
|
||||
Member("second_member", ty.f32())});
|
||||
auto* alias = ty.alias("alias", st);
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("alias", st);
|
||||
Global("my_struct", alias, ast::StorageClass::kInput);
|
||||
|
||||
auto* mem = MemberAccessor("my_struct", "second_member");
|
||||
|
|
|
@ -86,8 +86,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) {
|
|||
TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) {
|
||||
// type a = bool;
|
||||
// var<storage, read> g : a;
|
||||
auto* a = ty.alias("a", ty.bool_());
|
||||
AST().AddConstructedType(a);
|
||||
auto* a = Alias("a", ty.bool_());
|
||||
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
@ -141,10 +140,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
|
|||
// var<storage, read> g : a1;
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto* a1 = ty.alias("a1", s);
|
||||
AST().AddConstructedType(a1);
|
||||
auto* a2 = ty.alias("a2", a1);
|
||||
AST().AddConstructedType(a2);
|
||||
auto* a1 = Alias("a1", s);
|
||||
auto* a2 = Alias("a2", a1);
|
||||
Global(Source{{56, 78}}, "g", a2, ast::StorageClass::kStorage,
|
||||
ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
|
@ -208,8 +205,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) {
|
|||
TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) {
|
||||
// type a = bool;
|
||||
// var<uniform> g : a;
|
||||
auto* a = ty.alias("a", ty.bool_());
|
||||
AST().AddConstructedType(a);
|
||||
auto* a = Alias("a", ty.bool_());
|
||||
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
@ -261,8 +257,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) {
|
|||
// var<uniform> g : a1;
|
||||
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto* a1 = ty.alias("a1", s);
|
||||
AST().AddConstructedType(a1);
|
||||
auto* a1 = Alias("a1", s);
|
||||
Global(Source{{56, 78}}, "g", a1, ast::StorageClass::kUniform,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
|
|
@ -52,10 +52,8 @@ TEST_F(ResolverStructLayoutTest, Scalars) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverStructLayoutTest, Alias) {
|
||||
auto* alias_a = ty.alias("a", ty.f32());
|
||||
AST().AddConstructedType(alias_a);
|
||||
auto* alias_b = ty.alias("b", ty.f32());
|
||||
AST().AddConstructedType(alias_b);
|
||||
auto* alias_a = Alias("a", ty.f32());
|
||||
auto* alias_b = Alias("b", ty.f32());
|
||||
|
||||
auto* s = Structure("S", {
|
||||
Member("a", alias_a),
|
||||
|
|
|
@ -158,8 +158,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedMultipleStages) {
|
|||
|
||||
TEST_F(ResolverPipelineStageUseTest, StructUsedAsShaderParamViaAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
||||
auto* s_alias = ty.alias("S_alias", s);
|
||||
AST().AddConstructedType(s_alias);
|
||||
auto* s_alias = Alias("S_alias", s);
|
||||
|
||||
Func("main", {Param("param", s_alias)}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
@ -174,8 +173,7 @@ TEST_F(ResolverPipelineStageUseTest, StructUsedAsShaderParamViaAlias) {
|
|||
|
||||
TEST_F(ResolverPipelineStageUseTest, StructUsedAsShaderReturnTypeViaAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
|
||||
auto* s_alias = ty.alias("S_alias", s);
|
||||
AST().AddConstructedType(s_alias);
|
||||
auto* s_alias = Alias("S_alias", s);
|
||||
|
||||
Func("main", {}, s_alias, {Return(Construct(s_alias, Expr(0.f)))},
|
||||
{Stage(ast::PipelineStage::kFragment)});
|
||||
|
|
|
@ -78,8 +78,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableFromGlobal) {
|
|||
|
||||
TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||
auto* a = ty.alias("A", s);
|
||||
AST().AddConstructedType(a);
|
||||
auto* a = Alias("A", s);
|
||||
Global("g", a, ast::StorageClass::kPrivate);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -131,8 +130,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableFromLocal) {
|
|||
|
||||
TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalAlias) {
|
||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||
auto* a = ty.alias("A", s);
|
||||
AST().AddConstructedType(a);
|
||||
auto* a = Alias("A", s);
|
||||
WrapInFunction(Var("g", a));
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
|
|
@ -338,9 +338,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsNotLast_Fail) {
|
|||
// a: u32;
|
||||
//}
|
||||
|
||||
auto* alias = ty.alias("RTArr", ty.array<u32>());
|
||||
AST().AddConstructedType(alias);
|
||||
|
||||
auto* alias = Alias("RTArr", ty.array<u32>());
|
||||
Structure("s",
|
||||
{
|
||||
Member(Source{{12, 34}}, "b", alias),
|
||||
|
@ -365,9 +363,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {
|
|||
// b: RTArr;
|
||||
//}
|
||||
|
||||
auto* alias = ty.alias("RTArr", ty.array<u32>());
|
||||
AST().AddConstructedType(alias);
|
||||
|
||||
auto* alias = Alias("RTArr", ty.array<u32>());
|
||||
Structure("s",
|
||||
{
|
||||
Member("a", ty.u32()),
|
||||
|
|
|
@ -1708,8 +1708,7 @@ TEST_F(ResolverValidationTest,
|
|||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Error) {
|
||||
auto* alias = ty.alias("UnsignedInt", ty.u32());
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("UnsignedInt", ty.u32());
|
||||
Global("uint_var", alias, ast::StorageClass::kInput);
|
||||
|
||||
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, "uint_var"));
|
||||
|
@ -1722,10 +1721,8 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Error) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Success) {
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
auto* vec2_alias = ty.alias("VectorFloat2", ty.vec2<f32>());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
AST().AddConstructedType(vec2_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
auto* vec2_alias = Alias("VectorFloat2", ty.vec2<f32>());
|
||||
Global("my_f32", f32_alias, ast::StorageClass::kInput);
|
||||
Global("my_vec2", vec2_alias, ast::StorageClass::kInput);
|
||||
|
||||
|
@ -1735,8 +1732,7 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_Alias_Argument_Success) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) {
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
|
||||
// vec2<Float32>(1.0f, 1u)
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
|
@ -1754,8 +1750,7 @@ TEST_F(ResolverValidationTest, Expr_Constructor_Vector_ElementTypeAlias_Error) {
|
|||
|
||||
TEST_F(ResolverValidationTest,
|
||||
Expr_Constructor_Vector_ElementTypeAlias_Success) {
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
|
||||
// vec2<Float32>(1.0f, 1.0f)
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
|
@ -1768,8 +1763,7 @@ TEST_F(ResolverValidationTest,
|
|||
|
||||
TEST_F(ResolverValidationTest,
|
||||
Expr_Constructor_Vector_ArgumentElementTypeAlias_Error) {
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
|
||||
// vec3<u32>(vec<Float32>(), 1.0f)
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
|
@ -1786,8 +1780,7 @@ TEST_F(ResolverValidationTest,
|
|||
|
||||
TEST_F(ResolverValidationTest,
|
||||
Expr_Constructor_Vector_ArgumentElementTypeAlias_Success) {
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
|
||||
// vec3<f32>(vec<Float32>(), 1.0f)
|
||||
auto* vec_type = ty.vec(f32_alias, 2);
|
||||
|
@ -2017,8 +2010,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Error) {
|
|||
// matNxM<Float32>(vecM<u32>(), ...); with N arguments
|
||||
|
||||
const auto param = GetParam();
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
|
@ -2043,8 +2035,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Success) {
|
|||
// matNxM<Float32>(vecM<f32>(), ...); with N arguments
|
||||
|
||||
const auto param = GetParam();
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
|
@ -2062,8 +2053,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ElementTypeAlias_Success) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverValidationTest, Expr_MatrixConstructor_ArgumentTypeAlias_Error) {
|
||||
auto* alias = ty.alias("VectorUnsigned2", ty.vec2<u32>());
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("VectorUnsigned2", ty.vec2<u32>());
|
||||
auto* tc = mat2x2<f32>(
|
||||
create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.MaybeCreateTypename(alias), ExprList()),
|
||||
|
@ -2080,8 +2070,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) {
|
|||
const auto param = GetParam();
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* vec_type = ty.vec<f32>(param.rows);
|
||||
auto* vec_alias = ty.alias("VectorFloat2", vec_type);
|
||||
AST().AddConstructedType(vec_alias);
|
||||
auto* vec_alias = Alias("VectorFloat2", vec_type);
|
||||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
|
@ -2099,8 +2088,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentTypeAlias_Success) {
|
|||
TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Error) {
|
||||
const auto param = GetParam();
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
auto* f32_alias = ty.alias("UnsignedInt", ty.u32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("UnsignedInt", ty.u32());
|
||||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
|
@ -2123,8 +2111,7 @@ TEST_P(MatrixConstructorTest, Expr_Constructor_ArgumentElementTypeAlias_Error) {
|
|||
TEST_P(MatrixConstructorTest,
|
||||
Expr_Constructor_ArgumentElementTypeAlias_Success) {
|
||||
const auto param = GetParam();
|
||||
auto* f32_alias = ty.alias("Float32", ty.f32());
|
||||
AST().AddConstructedType(f32_alias);
|
||||
auto* f32_alias = Alias("Float32", ty.f32());
|
||||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
|
|
|
@ -39,8 +39,7 @@ TEST_F(ResolverVarLetTest, TypeOfVar) {
|
|||
// }
|
||||
|
||||
auto* S = Structure("S", {Member("i", ty.i32())});
|
||||
auto* A = ty.alias("A", S);
|
||||
AST().AddConstructedType(A);
|
||||
auto* A = Alias("A", S);
|
||||
|
||||
auto* i = Var("i", ty.i32(), ast::StorageClass::kNone);
|
||||
auto* u = Var("u", ty.u32(), ast::StorageClass::kNone);
|
||||
|
@ -91,8 +90,7 @@ TEST_F(ResolverVarLetTest, TypeOfLet) {
|
|||
// }
|
||||
|
||||
auto* S = Structure("S", {Member("i", ty.i32())});
|
||||
auto* A = ty.alias("A", S);
|
||||
AST().AddConstructedType(A);
|
||||
auto* A = Alias("A", S);
|
||||
|
||||
auto* v = Var("v", ty.i32(), ast::StorageClass::kNone);
|
||||
auto* i = Const("i", ty.i32(), Expr(1));
|
||||
|
|
|
@ -80,8 +80,7 @@ TEST_F(ResolverVarLetValidationTest, VarConstructorWrongType) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, LetConstructorWrongTypeViaAlias) {
|
||||
auto* a = ty.alias("I32", ty.i32());
|
||||
AST().AddConstructedType(a);
|
||||
auto* a = Alias("I32", ty.i32());
|
||||
WrapInFunction(Const(Source{{3, 3}}, "v", a, Expr(2u)));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -91,8 +90,7 @@ TEST_F(ResolverVarLetValidationTest, LetConstructorWrongTypeViaAlias) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverVarLetValidationTest, VarConstructorWrongTypeViaAlias) {
|
||||
auto* a = ty.alias("I32", ty.i32());
|
||||
AST().AddConstructedType(a);
|
||||
auto* a = Alias("I32", ty.i32());
|
||||
WrapInFunction(
|
||||
Var(Source{{3, 3}}, "v", a, ast::StorageClass::kNone, Expr(2u)));
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_WorkgroupVar, Aliased) {
|
||||
auto* alias = ty.alias("F32", ty.f32());
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("F32", ty.f32());
|
||||
|
||||
Global("wg", alias, ast::StorageClass::kWorkgroup);
|
||||
|
||||
|
|
|
@ -394,8 +394,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
|
|||
Member("b", ty.f32()),
|
||||
});
|
||||
|
||||
auto* alias = ty.alias("Alias", inner_struct);
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("Alias", inner_struct);
|
||||
auto* s_type = Structure("Outer", {Member("inner", alias)});
|
||||
|
||||
auto* var = Var("ident", s_type);
|
||||
|
|
|
@ -93,8 +93,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithAlias) {
|
|||
// type Int = i32
|
||||
// cast<Int>(2.3f)
|
||||
|
||||
auto* alias = ty.alias("Int", ty.i32());
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("Int", ty.i32());
|
||||
auto* cast = Construct(alias, 2.3f);
|
||||
WrapInFunction(cast);
|
||||
|
||||
|
|
|
@ -441,8 +441,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
|
|||
|
||||
auto* A = Structure("A", {Member("a", ty.i32())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto* B = ty.alias("B", A);
|
||||
AST().AddConstructedType(B);
|
||||
auto* B = Alias("B", A);
|
||||
auto* var = Global("b", B, ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
@ -479,8 +478,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
|
|||
|
||||
auto* A = Structure("A", {Member("a", ty.i32())},
|
||||
{create<ast::StructBlockDecoration>()});
|
||||
auto* B = ty.alias("B", A);
|
||||
AST().AddConstructedType(B);
|
||||
auto* B = Alias("B", A);
|
||||
auto* var = Global("b", B, ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
|
|
@ -22,8 +22,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitAlias_F32) {
|
||||
auto* alias = ty.alias("a", ty.f32());
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("a", ty.f32());
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructedType(alias)) << gen.error();
|
||||
|
@ -37,8 +36,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) {
|
|||
Member("b", ty.i32()),
|
||||
});
|
||||
|
||||
auto* alias = ty.alias("B", s);
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("B", s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -58,8 +56,7 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) {
|
|||
Member("b", ty.i32()),
|
||||
});
|
||||
|
||||
auto* alias = ty.alias("B", s);
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("B", s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Alias) {
|
||||
auto* alias = ty.alias("alias", ty.f32());
|
||||
AST().AddConstructedType(alias);
|
||||
auto* alias = Alias("alias", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -37,7 +36,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Alias) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Array) {
|
||||
auto* arr = ty.array<bool, 4>();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", arr));
|
||||
Alias("make_type_reachable", arr);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -47,7 +46,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
|
||||
auto* a = ty.array(ty.bool_(), 4, 16u);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", a));
|
||||
Alias("make_type_reachable", a);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -57,7 +56,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
|
||||
auto* a = ty.array(ty.bool_(), 0);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", a));
|
||||
Alias("make_type_reachable", a);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -67,7 +66,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Bool) {
|
||||
auto* bool_ = ty.bool_();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", bool_));
|
||||
Alias("make_type_reachable", bool_);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -77,7 +76,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Bool) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_F32) {
|
||||
auto* f32 = ty.f32();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", f32));
|
||||
Alias("make_type_reachable", f32);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -87,7 +86,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_F32) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_I32) {
|
||||
auto* i32 = ty.i32();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", i32));
|
||||
Alias("make_type_reachable", i32);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -97,7 +96,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_I32) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Matrix) {
|
||||
auto* mat2x3 = ty.mat2x3<f32>();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", mat2x3));
|
||||
Alias("make_type_reachable", mat2x3);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -107,7 +106,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Matrix) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
|
||||
auto* p = ty.pointer<f32>(ast::StorageClass::kWorkgroup);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", p));
|
||||
Alias("make_type_reachable", p);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -250,7 +249,7 @@ struct S {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_U32) {
|
||||
auto* u32 = ty.u32();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", u32));
|
||||
Alias("make_type_reachable", u32);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -260,7 +259,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_U32) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Vector) {
|
||||
auto* vec3 = ty.vec3<f32>();
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", vec3));
|
||||
Alias("make_type_reachable", vec3);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -282,7 +281,7 @@ TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) {
|
|||
auto param = GetParam();
|
||||
|
||||
auto* d = ty.depth_texture(param.dim);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", d));
|
||||
Alias("make_type_reachable", d);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -304,7 +303,7 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
|
|||
auto param = GetParam();
|
||||
|
||||
auto* t = ty.sampled_texture(param.dim, ty.f32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
Alias("make_type_reachable", t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -316,7 +315,7 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
|
|||
auto param = GetParam();
|
||||
|
||||
auto* t = ty.sampled_texture(param.dim, ty.i32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
Alias("make_type_reachable", t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -328,7 +327,7 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) {
|
|||
auto param = GetParam();
|
||||
|
||||
auto* t = ty.sampled_texture(param.dim, ty.u32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
Alias("make_type_reachable", t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -351,7 +350,7 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
|||
auto param = GetParam();
|
||||
|
||||
auto* t = ty.multisampled_texture(param.dim, ty.f32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
Alias("make_type_reachable", t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -363,7 +362,7 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
|
|||
auto param = GetParam();
|
||||
|
||||
auto* t = ty.multisampled_texture(param.dim, ty.i32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
Alias("make_type_reachable", t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -375,7 +374,7 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
|
|||
auto param = GetParam();
|
||||
|
||||
auto* t = ty.multisampled_texture(param.dim, ty.u32());
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", t));
|
||||
Alias("make_type_reachable", t);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -503,7 +502,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
||||
auto* sampler = ty.sampler(ast::SamplerKind::kSampler);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
|
||||
Alias("make_type_reachable", sampler);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -513,7 +512,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Sampler) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) {
|
||||
auto* sampler = ty.sampler(ast::SamplerKind::kComparisonSampler);
|
||||
AST().AddConstructedType(ty.alias("make_type_reachable", sampler));
|
||||
Alias("make_type_reachable", sampler);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
Loading…
Reference in New Issue