diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc index b9f1fd7610..0d3403d575 100644 --- a/src/ast/else_statement_test.cc +++ b/src/ast/else_statement_test.cc @@ -28,9 +28,7 @@ namespace { using ElseStatementTest = TestHelper; TEST_F(ElseStatementTest, Creation) { - type::Bool bool_type; - auto* cond = create( - create(&bool_type, true)); + auto* cond = Expr(true); auto* body = create(StatementList{ create(), }); @@ -57,9 +55,7 @@ TEST_F(ElseStatementTest, IsElse) { } TEST_F(ElseStatementTest, HasCondition) { - type::Bool bool_type; - auto* cond = create( - create(&bool_type, true)); + auto* cond = Expr(true); auto* e = create(cond, create(StatementList{})); EXPECT_TRUE(e->HasCondition()); @@ -113,9 +109,7 @@ TEST_F(ElseStatementTest, IsValid_InvalidBodyStatement) { } TEST_F(ElseStatementTest, ToStr) { - type::Bool bool_type; - auto* cond = create( - create(&bool_type, true)); + auto* cond = Expr(true); auto* body = create(StatementList{ create(), }); diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc index 14fbd96674..25fdbd2bfa 100644 --- a/src/ast/scalar_constructor_expression_test.cc +++ b/src/ast/scalar_constructor_expression_test.cc @@ -25,26 +25,20 @@ namespace { using ScalarConstructorExpressionTest = TestHelper; TEST_F(ScalarConstructorExpressionTest, Creation) { - type::Bool bool_type; - auto* b = create(&bool_type, true); + auto* b = create(ty.bool_, true); auto* c = create(b); EXPECT_EQ(c->literal(), b); } TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) { - type::Bool bool_type; - auto* b = create(&bool_type, true); - auto* c = - create(Source{Source::Location{20, 2}}, b); - auto src = c->source(); + SetSource(Source{Source::Location{20, 2}}); + auto src = Expr(true)->source(); EXPECT_EQ(src.range.begin.line, 20u); EXPECT_EQ(src.range.begin.column, 2u); } TEST_F(ScalarConstructorExpressionTest, IsValid) { - type::Bool bool_type; - auto* b = create(&bool_type, true); - auto* c = create(b); + auto* c = Expr(true); EXPECT_TRUE(c->IsValid()); } @@ -54,9 +48,7 @@ TEST_F(ScalarConstructorExpressionTest, IsValid_MissingLiteral) { } TEST_F(ScalarConstructorExpressionTest, ToStr) { - type::Bool bool_type; - auto* b = create(&bool_type, true); - auto* c = create(b); + auto* c = Expr(true); std::ostringstream out; c->to_str(out, 2); EXPECT_EQ(out.str(), R"( ScalarConstructor[not set]{true} diff --git a/src/reader/wgsl/parser_impl_test.cc b/src/reader/wgsl/parser_impl_test.cc index 44afe10934..54dde10d57 100644 --- a/src/reader/wgsl/parser_impl_test.cc +++ b/src/reader/wgsl/parser_impl_test.cc @@ -57,12 +57,11 @@ fn main() -> { # missing return type TEST_F(ParserImplTest, GetRegisteredType) { auto p = parser(""); - ast::type::I32 i32; - p->register_constructed("my_alias", &i32); + p->register_constructed("my_alias", ty.i32); auto* alias = p->get_constructed("my_alias"); ASSERT_NE(alias, nullptr); - ASSERT_EQ(alias, &i32); + ASSERT_EQ(alias, ty.i32); } TEST_F(ParserImplTest, GetUnregisteredType) { diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc index c27724b20d..6c11ba1cbe 100644 --- a/src/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/reader/wgsl/parser_impl_type_decl_test.cc @@ -755,9 +755,8 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) { auto p = parser("texture_sampled_cube"); auto& mod = p->get_module(); - ast::type::F32 f32; auto* type = mod.create( - ast::type::TextureDimension::kCube, &f32); + ast::type::TextureDimension::kCube, ty.f32); auto t = p->type_decl(); EXPECT_TRUE(t.matched); @@ -772,10 +771,9 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) { TEST_F(ParserImplTest, TypeDecl_Texture) { auto p = parser("texture_cube"); - ast::type::F32 f32; auto& mod = p->get_module(); auto* type = mod.create( - ast::type::TextureDimension::kCube, &f32); + ast::type::TextureDimension::kCube, ty.f32); auto t = p->type_decl(); EXPECT_TRUE(t.matched); diff --git a/src/transform/vertex_pulling_test.cc b/src/transform/vertex_pulling_test.cc index 6bbb55e334..129a4f9bc2 100644 --- a/src/transform/vertex_pulling_test.cc +++ b/src/transform/vertex_pulling_test.cc @@ -139,8 +139,7 @@ TEST_F(VertexPullingTest, BasicModule) { TEST_F(VertexPullingTest, OneAttribute) { InitBasicModule(); - ast::type::F32 f32; - AddVertexInputVariable(0, "var_a", &f32); + AddVertexInputVariable(0, "var_a", ty.f32); InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}}); @@ -225,8 +224,7 @@ TEST_F(VertexPullingTest, OneAttribute) { TEST_F(VertexPullingTest, OneInstancedAttribute) { InitBasicModule(); - ast::type::F32 f32; - AddVertexInputVariable(0, "var_a", &f32); + AddVertexInputVariable(0, "var_a", ty.f32); InitTransform( {{{4, InputStepMode::kInstance, {{VertexFormat::kF32, 0, 0}}}}}); @@ -312,8 +310,7 @@ TEST_F(VertexPullingTest, OneInstancedAttribute) { TEST_F(VertexPullingTest, OneAttributeDifferentOutputSet) { InitBasicModule(); - ast::type::F32 f32; - AddVertexInputVariable(0, "var_a", &f32); + AddVertexInputVariable(0, "var_a", ty.f32); InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}}); transform()->SetPullingBufferBindingSet(5); @@ -550,11 +547,8 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) { TEST_F(VertexPullingTest, TwoAttributesSameBuffer) { InitBasicModule(); - ast::type::F32 f32; - AddVertexInputVariable(0, "var_a", &f32); - - ast::type::Array vec4_f32{&f32, 4u, ast::ArrayDecorationList{}}; - AddVertexInputVariable(1, "var_b", &vec4_f32); + AddVertexInputVariable(0, "var_a", ty.f32); + AddVertexInputVariable(1, "var_b", ty.array()); InitTransform( {{{16, @@ -732,16 +726,9 @@ TEST_F(VertexPullingTest, TwoAttributesSameBuffer) { TEST_F(VertexPullingTest, FloatVectorAttributes) { InitBasicModule(); - - ast::type::F32 f32; - ast::type::Array vec2_f32{&f32, 2u, ast::ArrayDecorationList{}}; - AddVertexInputVariable(0, "var_a", &vec2_f32); - - ast::type::Array vec3_f32{&f32, 3u, ast::ArrayDecorationList{}}; - AddVertexInputVariable(1, "var_b", &vec3_f32); - - ast::type::Array vec4_f32{&f32, 4u, ast::ArrayDecorationList{}}; - AddVertexInputVariable(2, "var_c", &vec4_f32); + AddVertexInputVariable(0, "var_a", ty.array()); + AddVertexInputVariable(1, "var_b", ty.array()); + AddVertexInputVariable(2, "var_c", ty.array()); InitTransform( {{{8, InputStepMode::kVertex, {{VertexFormat::kVec2F32, 0, 0}}}, diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index e451160066..21006f518b 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -365,10 +365,8 @@ TEST_F(TypeDeterminerTest, Expr_Error_Unknown) { } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { - ast::type::Array ary(ty.f32, 3, ast::ArrayDecorationList{}); - auto* idx = Expr(2); - auto* var = Var("my_var", ast::StorageClass::kFunction, &ary); + auto* var = Var("my_var", ast::StorageClass::kFunction, ty.array()); mod->AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -383,8 +381,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { - ast::type::Array ary(ty.f32, 3, ast::ArrayDecorationList{}); - auto* aary = ty.alias("myarrty", &ary); + auto* aary = ty.alias("myarrty", ty.array()); mod->AddGlobalVariable(Var("my_var", ast::StorageClass::kFunction, aary)); @@ -400,9 +397,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { - ast::type::Array ary(ty.f32, 3, ast::ArrayDecorationList{}); - - auto* var = Const("my_var", ast::StorageClass::kFunction, &ary); + auto* var = Const("my_var", ast::StorageClass::kFunction, ty.array()); mod->AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -415,9 +410,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { - ast::type::Matrix mat(ty.f32, 3, 2); - - auto* var = Var("my_var", ast::StorageClass::kNone, &mat); + auto* var = Var("my_var", ast::StorageClass::kNone, ty.mat2x3()); mod->AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -529,9 +522,7 @@ TEST_F(TypeDeterminerTest, Expr_Cast) { } TEST_F(TypeDeterminerTest, Expr_Constructor_Scalar) { - auto* s = create( - create(ty.f32, 1.0f)); - + auto* s = Expr(1.0f); EXPECT_TRUE(td()->DetermineResultType(s)); ASSERT_NE(s->result_type(), nullptr); EXPECT_TRUE(s->result_type()->Is()); @@ -746,9 +737,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { Func("my_func", ast::VariableList{}, ty.f32, ast::StatementList{ create(var), - create( - Expr("var"), create( - create(ty.f32, 1.f))), + create(Expr("var"), Expr(1.f)), }, ast::FunctionDecorationList{}); @@ -1104,10 +1093,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) { } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { - ast::type::Matrix mat3x2(ty.f32, 3, 2); - auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32); - auto* matrix = Var("matrix", ast::StorageClass::kNone, &mat3x2); + auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3()); mod->AddGlobalVariable(scalar); mod->AddGlobalVariable(matrix); @@ -1126,10 +1113,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) { - ast::type::Matrix mat3x2(ty.f32, 3, 2); - auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32); - auto* matrix = Var("matrix", ast::StorageClass::kNone, &mat3x2); + auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3()); mod->AddGlobalVariable(scalar); mod->AddGlobalVariable(matrix); @@ -1188,19 +1173,14 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) { } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) { - ast::type::Matrix mat4x3(ty.f32, 4, 3); - ast::type::Matrix mat3x4(ty.f32, 3, 4); - - auto* matrix1 = Var( // source - "mat4x3", ast::StorageClass::kNone, &mat4x3); - auto* matrix2 = Var( // source - "mat3x4", ast::StorageClass::kNone, &mat3x4); + auto* matrix1 = Var("mat3x4", ast::StorageClass::kNone, ty.mat3x4()); + auto* matrix2 = Var("mat4x3", ast::StorageClass::kNone, ty.mat4x3()); mod->AddGlobalVariable(matrix1); mod->AddGlobalVariable(matrix2); ASSERT_TRUE(td()->Determine()) << td()->error(); - auto* expr = Mul("mat4x3", "mat3x4"); + auto* expr = Mul("mat3x4", "mat4x3"); ASSERT_TRUE(td()->DetermineResultType(expr)) << td()->error(); ASSERT_NE(expr->result_type(), nullptr); @@ -2821,9 +2801,7 @@ TEST_P(ImportData_Matrix_OneParam_Test, NoParams) { TEST_P(ImportData_Matrix_OneParam_Test, TooManyParams) { auto param = GetParam(); - ast::type::Matrix mat(ty.f32, 3, 3); - - auto* var = Var("var", ast::StorageClass::kFunction, &mat); + auto* var = Var("var", ast::StorageClass::kFunction, ty.mat3x3()); mod->AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc index 65daa04c88..35b97a27c9 100644 --- a/src/validator/validator_control_block_test.cc +++ b/src/validator/validator_control_block_test.cc @@ -169,9 +169,7 @@ TEST_F(ValidateControlBlockTest, // case -1: {} // default: {} // } - auto* var = Var("a", ast::StorageClass::kNone, ty.u32, - create( - create(ty.u32, 2)), + auto* var = Var("a", ast::StorageClass::kNone, ty.u32, Expr(2u), ast::VariableDecorationList{}); ast::CaseStatementList switch_body; @@ -203,9 +201,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) { // case 2, 2: {} // default: {} // } - auto* var = Var("a", ast::StorageClass::kNone, ty.u32, - create( - create(ty.u32, 3)), + auto* var = Var("a", ast::StorageClass::kNone, ty.u32, Expr(3u), ast::VariableDecorationList{}); ast::CaseStatementList switch_body; diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index fb56f489fb..335ee5f6c4 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -301,7 +301,6 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) { auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f), ast::VariableDecorationList{}); - ast::type::Bool bool_type; auto* cond = Expr(true); auto* body = create(ast::StatementList{ create(var), @@ -336,7 +335,6 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { auto* lhs = Expr("a"); auto* rhs = Expr(3.14f); - ast::type::Bool bool_type; auto* cond = Expr(true); auto* body = create(ast::StatementList{ create(Source{Source::Location{12, 34}}, lhs, @@ -476,7 +474,6 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f), ast::VariableDecorationList{}); - ast::type::Bool bool_type; auto* cond = Expr(true); auto* body = create(ast::StatementList{ create(var), @@ -508,7 +505,6 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f), ast::VariableDecorationList{}); - ast::type::Bool bool_type; auto* cond = Expr(true); auto* body = create(ast::StatementList{ create(Source{Source::Location{12, 34}}, var), diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index 1b4b46d730..49d453028a 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -874,15 +874,14 @@ void main() { } TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { - ast::type::Array ary(ty.f32, 5, ast::ArrayDecorationList{}); - - auto* func = Func("my_func", - ast::VariableList{Var("a", ast::StorageClass::kNone, &ary)}, - ty.void_, - ast::StatementList{ - create(), - }, - ast::FunctionDecorationList{}); + auto* func = Func( + "my_func", + ast::VariableList{Var("a", ast::StorageClass::kNone, ty.array())}, + ty.void_, + ast::StatementList{ + create(), + }, + ast::FunctionDecorationList{}); mod->AddFunction(func); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index a3f2af4084..2a4f8eda61 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -28,8 +28,7 @@ namespace { using HlslGeneratorImplTest = TestHelper; TEST_F(HlslGeneratorImplTest, Generate) { - ast::type::Void void_type; - auto* func = Func("my_func", ast::VariableList{}, &void_type, + auto* func = Func("my_func", ast::VariableList{}, ty.void_, ast::StatementList{}, ast::FunctionDecorationList{}); mod->AddFunction(func); diff --git a/src/writer/msl/generator_impl_case_test.cc b/src/writer/msl/generator_impl_case_test.cc index 5ab3f25d99..dd19fcc072 100644 --- a/src/writer/msl/generator_impl_case_test.cc +++ b/src/writer/msl/generator_impl_case_test.cc @@ -33,13 +33,11 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Case) { - ast::type::I32 i32; - auto* body = create(ast::StatementList{ create(), }); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(ty.i32, 5)); auto* c = create(lit, body); gen.increment_indent(); @@ -52,10 +50,8 @@ TEST_F(MslGeneratorImplTest, Emit_Case) { } TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) { - ast::type::I32 i32; - ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(ty.i32, 5)); auto* c = create( lit, create(ast::StatementList{})); @@ -69,13 +65,11 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) { } TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) { - ast::type::I32 i32; - auto* body = create(ast::StatementList{ create(), }); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(ty.i32, 5)); auto* c = create(lit, body); gen.increment_indent(); @@ -88,14 +82,12 @@ TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) { } TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) { - ast::type::I32 i32; - auto* body = create(ast::StatementList{ create(), }); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); - lit.push_back(create(&i32, 6)); + lit.push_back(create(ty.i32, 5)); + lit.push_back(create(ty.i32, 6)); auto* c = create(lit, body); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_cast_test.cc b/src/writer/msl/generator_impl_cast_test.cc index 73ae2da950..3713b86763 100644 --- a/src/writer/msl/generator_impl_cast_test.cc +++ b/src/writer/msl/generator_impl_cast_test.cc @@ -31,20 +31,14 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Scalar) { - ast::ExpressionList params; - params.push_back(Expr("id")); - - auto* cast = create(ty.f32, params); + auto* cast = Construct("id"); ASSERT_TRUE(gen.EmitExpression(cast)) << gen.error(); EXPECT_EQ(gen.result(), "float(id)"); } TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Vector) { - ast::ExpressionList params; - params.push_back(Expr("id")); - - auto* cast = create(ty.vec3(), params); + auto* cast = vec3("id"); ASSERT_TRUE(gen.EmitExpression(cast)) << gen.error(); EXPECT_EQ(gen.result(), "float3(id)"); diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc index f1a1b1a135..ff82185c22 100644 --- a/src/writer/msl/generator_impl_constructor_test.cc +++ b/src/writer/msl/generator_impl_constructor_test.cc @@ -38,136 +38,76 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) { - auto* lit = create(ty.bool_, false); - auto* expr = create(lit); - + auto* expr = Expr(false); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "false"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Int) { - auto* lit = create(ty.i32, -12345); - auto* expr = create(lit); - + auto* expr = Expr(-12345); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "-12345"); } TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) { - auto* lit = create(ty.u32, 56779); - auto* expr = create(lit); - + auto* expr = Expr(56779u); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "56779u"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Float) { // Use a number close to 1<<30 but whose decimal representation ends in 0. - auto* lit = - create(ty.f32, static_cast((1 << 30) - 4)); - auto* expr = create(lit); - + auto* expr = Expr(static_cast((1 << 30) - 4)); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "1073741824.0f"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) { - auto* lit = create(ty.f32, -1.2e-5); - ast::ExpressionList values; - values.push_back(create(lit)); - - auto* expr = create(ty.f32, values); - + auto* expr = Construct(-1.2e-5f); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "float(-0.000012f)"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) { - auto* lit = create(ty.bool_, true); - ast::ExpressionList values; - values.push_back(create(lit)); - - auto* expr = create(ty.bool_, values); - + auto* expr = Construct(true); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "bool(true)"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) { - auto* lit = create(ty.i32, -12345); - ast::ExpressionList values; - values.push_back(create(lit)); - - auto* expr = create(ty.i32, values); - + auto* expr = Construct(-12345); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "int(-12345)"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Uint) { - auto* lit = create(ty.u32, 12345); - ast::ExpressionList values; - values.push_back(create(lit)); - - auto* expr = create(ty.u32, values); - + auto* expr = Construct(12345u); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "uint(12345u)"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) { - ast::type::Vector vec(ty.f32, 3); - - auto* lit1 = create(ty.f32, 1.f); - auto* lit2 = create(ty.f32, 2.f); - auto* lit3 = create(ty.f32, 3.f); - ast::ExpressionList values; - values.push_back(create(lit1)); - values.push_back(create(lit2)); - values.push_back(create(lit3)); - - auto* expr = create(&vec, values); - + auto* expr = vec3(1.f, 2.f, 3.f); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "float3(1.0f, 2.0f, 3.0f)"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec_Empty) { - ast::type::Vector vec(ty.f32, 3); - - ast::ExpressionList values; - auto* expr = create(&vec, values); - + auto* expr = vec3(); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "float3(0.0f)"); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) { - ast::type::Matrix mat(ty.f32, 3, 2); // 3 ROWS, 2 COLUMNS - ast::type::Vector vec(ty.f32, 3); - - // WGSL matrix is mat2x3 (it flips for AST, sigh). With a type constructor - // of - ast::ExpressionList mat_values; for (size_t i = 0; i < 2; i++) { - auto* lit1 = - create(ty.f32, static_cast(1 + (i * 2))); - auto* lit2 = - create(ty.f32, static_cast(2 + (i * 2))); - auto* lit3 = - create(ty.f32, static_cast(3 + (i * 2))); - - ast::ExpressionList values; - values.push_back(create(lit1)); - values.push_back(create(lit2)); - values.push_back(create(lit3)); - - mat_values.push_back(create(&vec, values)); + mat_values.push_back(vec3(static_cast(1 + (i * 2)), + static_cast(2 + (i * 2)), + static_cast(3 + (i * 2)))); } - auto* expr = create(&mat, mat_values); + auto* expr = Construct(ty.mat2x3(), mat_values); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); // A matrix of type T with n columns and m rows can also be constructed from @@ -177,28 +117,17 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) { - ast::type::Vector vec(ty.f32, 3); - ast::type::Array ary(&vec, 3, ast::ArrayDecorationList{}); + ast::type::Array ary(ty.vec3(), 3, ast::ArrayDecorationList{}); ast::ExpressionList ary_values; for (size_t i = 0; i < 3; i++) { - auto* lit1 = - create(ty.f32, static_cast(1 + (i * 3))); - auto* lit2 = - create(ty.f32, static_cast(2 + (i * 3))); - auto* lit3 = - create(ty.f32, static_cast(3 + (i * 3))); - - ast::ExpressionList values; - values.push_back(create(lit1)); - values.push_back(create(lit2)); - values.push_back(create(lit3)); - - ary_values.push_back(create(&vec, values)); + ary_values.push_back(vec3(static_cast(1 + (i * 3)), + static_cast(2 + (i * 3)), + static_cast(3 + (i * 3)))); } - auto* expr = create(&ary, ary_values); + auto* expr = Construct(&ary, ary_values); ASSERT_TRUE(gen.EmitConstructor(expr)) << gen.error(); EXPECT_EQ(gen.result(), "{float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), " diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 1fec6352e7..7ae20809f6 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -578,8 +578,7 @@ TEST_F(MslGeneratorImplTest, mod->AddFunction(sub_func); ast::ExpressionList expr; - expr.push_back(create( - create(ty.f32, 1.0f))); + expr.push_back(Expr(1.0f)); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32, Call("sub_func", 1.0f), ast::VariableDecorationList{}); @@ -710,8 +709,7 @@ TEST_F(MslGeneratorImplTest, mod->AddFunction(sub_func); ast::ExpressionList expr; - expr.push_back(create( - create(ty.f32, 1.0f))); + expr.push_back(Expr(1.0f)); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32, Call("sub_func", 1.0f), ast::VariableDecorationList{}); @@ -764,15 +762,9 @@ TEST_F(MslGeneratorImplTest, }); auto body = ast::StatementList{ - create( - Expr("bar"), create( - create(ty.f32, 1.f))), + create(Expr("bar"), Expr(1.f)), create(create( - ast::BinaryOp::kEqual, - create( - create(ty.i32, 1)), - create( - create(ty.i32, 1))), + ast::BinaryOp::kEqual, Expr(1), Expr(1)), list, ast::ElseStatementList{}), create(), }; @@ -825,10 +817,8 @@ kernel void main_tint_0() { } TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { - ast::type::Array ary(ty.f32, 5, ast::ArrayDecorationList{}); - ast::VariableList params; - params.push_back(Var("a", ast::StorageClass::kNone, &ary)); // decorations + params.push_back(Var("a", ast::StorageClass::kNone, ty.array())); auto* func = Func("my_func", params, ty.void_, ast::StatementList{ diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc index ef9132d595..b7d97d6d34 100644 --- a/src/writer/msl/generator_impl_import_test.cc +++ b/src/writer/msl/generator_impl_import_test.cc @@ -117,8 +117,8 @@ using MslImportData_DualParam_VectorTest = TestParamHelper; TEST_P(MslImportData_DualParam_VectorTest, FloatVector) { auto param = GetParam(); - auto* expr = Call(param.name, Construct(ty.vec3(), 1.f, 2.f, 3.f), - Construct(ty.vec3(), 4.f, 5.f, 6.f)); + auto* expr = + Call(param.name, vec3(1.f, 2.f, 3.f), vec3(4.f, 5.f, 6.f)); ASSERT_TRUE(td.DetermineResultType(expr)) << td.error(); ASSERT_TRUE(gen.EmitCall(expr)) << gen.error(); EXPECT_EQ(gen.result(), std::string("metal::") + param.msl_name + @@ -178,10 +178,7 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, MslImportData{"clamp", "clamp"})); TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { - ast::type::F32 f32; - ast::type::Matrix mat(&f32, 3, 3); - - auto* var = Var("var", ast::StorageClass::kFunction, &mat); + auto* var = Var("var", ast::StorageClass::kFunction, ty.mat3x3()); mod->AddGlobalVariable(var); auto* expr = Call("determinant", "var"); diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc index 87389fb7fc..7e272d6aa8 100644 --- a/src/writer/msl/generator_impl_module_constant_test.cc +++ b/src/writer/msl/generator_impl_module_constant_test.cc @@ -35,12 +35,9 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) { - ast::type::Array ary(ty.f32, 3, ast::ArrayDecorationList{}); auto* var = - Const("pos", ast::StorageClass::kNone, &ary, - create( - &ary, ast::ExpressionList{Expr(1.f), Expr(2.f), Expr(3.f)}), - ast::VariableDecorationList{}); + Const("pos", ast::StorageClass::kNone, ty.array(), + array(1.f, 2.f, 3.f), ast::VariableDecorationList{}); ASSERT_TRUE(gen.EmitProgramConstVariable(var)) << gen.error(); EXPECT_EQ(gen.result(), "constant float pos[3] = {1.0f, 2.0f, 3.0f};\n"); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index d9a63d3425..b5f4dd1196 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -116,35 +116,27 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_alias) { } TEST_F(MslGeneratorImplTest, calculate_alignment_size_array) { - ast::type::F32 f32; - ast::type::Array ary(&f32, 4, ast::ArrayDecorationList{}); - EXPECT_EQ(4u * 4u, gen.calculate_alignment_size(&ary)); + EXPECT_EQ(4u * 4u, gen.calculate_alignment_size(ty.array())); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_bool) { - ast::type::Bool bool_type; - EXPECT_EQ(1u, gen.calculate_alignment_size(&bool_type)); + EXPECT_EQ(1u, gen.calculate_alignment_size(ty.bool_)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_f32) { - ast::type::F32 f32; - EXPECT_EQ(4u, gen.calculate_alignment_size(&f32)); + EXPECT_EQ(4u, gen.calculate_alignment_size(ty.f32)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_i32) { - ast::type::I32 i32; - EXPECT_EQ(4u, gen.calculate_alignment_size(&i32)); + EXPECT_EQ(4u, gen.calculate_alignment_size(ty.i32)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_matrix) { - ast::type::F32 f32; - ast::type::Matrix mat(&f32, 3, 2); - EXPECT_EQ(4u * 3u * 2u, gen.calculate_alignment_size(&mat)); + EXPECT_EQ(4u * 3u * 2u, gen.calculate_alignment_size(ty.mat3x2())); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_pointer) { - ast::type::Bool bool_type; - ast::type::Pointer ptr(&bool_type, ast::StorageClass::kPrivate); + ast::type::Pointer ptr(ty.bool_, ast::StorageClass::kPrivate); EXPECT_EQ(0u, gen.calculate_alignment_size(&ptr)); } @@ -179,8 +171,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { } TEST_F(MslGeneratorImplTest, calculate_alignment_size_u32) { - ast::type::U32 u32; - EXPECT_EQ(4u, gen.calculate_alignment_size(&u32)); + EXPECT_EQ(4u, gen.calculate_alignment_size(ty.u32)); } struct MslVectorSizeData { @@ -195,8 +186,7 @@ using MslVectorSizeBoolTest = TestParamHelper; TEST_P(MslVectorSizeBoolTest, calculate) { auto param = GetParam(); - ast::type::Bool bool_type; - ast::type::Vector vec(&bool_type, param.elements); + ast::type::Vector vec(ty.bool_, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, @@ -209,8 +199,7 @@ using MslVectorSizeI32Test = TestParamHelper; TEST_P(MslVectorSizeI32Test, calculate) { auto param = GetParam(); - ast::type::I32 i32; - ast::type::Vector vec(&i32, param.elements); + ast::type::Vector vec(ty.i32, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, @@ -223,8 +212,7 @@ using MslVectorSizeU32Test = TestParamHelper; TEST_P(MslVectorSizeU32Test, calculate) { auto param = GetParam(); - ast::type::U32 u32; - ast::type::Vector vec(&u32, param.elements); + ast::type::Vector vec(ty.u32, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, @@ -237,8 +225,7 @@ using MslVectorSizeF32Test = TestParamHelper; TEST_P(MslVectorSizeF32Test, calculate) { auto param = GetParam(); - ast::type::F32 f32; - ast::type::Vector vec(&f32, param.elements); + ast::type::Vector vec(ty.f32, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc index 29a44aaf48..8f50096618 100644 --- a/src/writer/msl/generator_impl_type_test.cc +++ b/src/writer/msl/generator_impl_type_test.cc @@ -59,108 +59,78 @@ TEST_F(MslGeneratorImplTest, EmitType_Alias_NameCollision) { } TEST_F(MslGeneratorImplTest, EmitType_Array) { - ast::type::Bool b; - ast::type::Array a(&b, 4, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.array(), "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[4]"); } TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) { - ast::type::Bool b; - ast::type::Array a(&b, 4, ast::ArrayDecorationList{}); - ast::type::Array c(&a, 5, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error(); + auto* a = ty.array(); + auto* b = ty.array(a, 5); + ASSERT_TRUE(gen.EmitType(b, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[5][4]"); } // TODO(dsinclair): Is this possible? What order should it output in? TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) { - ast::type::Bool b; - ast::type::Array a(&b, 4, ast::ArrayDecorationList{}); - ast::type::Array c(&a, 5, ast::ArrayDecorationList{}); - ast::type::Array d(&c, 0, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error(); + auto* a = ty.array(); + auto* b = ty.array(a, 5); + auto* c = ty.array(b, 0); + ASSERT_TRUE(gen.EmitType(c, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[5][4][1]"); } TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) { - ast::type::Bool b; - ast::type::Array a(&b, 4, ast::ArrayDecorationList{}); - ast::type::Array c(&a, 5, ast::ArrayDecorationList{}); - ast::type::Array d(&c, 6, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&d, "ary")) << gen.error(); + auto* a = ty.array(); + auto* b = ty.array(a, 5); + auto* c = ty.array(b, 6); + ASSERT_TRUE(gen.EmitType(c, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[6][5][4]"); } TEST_F(MslGeneratorImplTest, EmitType_Array_NameCollision) { - ast::type::Bool b; - ast::type::Array a(&b, 4, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&a, "bool")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.array(), "bool")) << gen.error(); EXPECT_EQ(gen.result(), "bool bool_tint_0[4]"); } TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) { - ast::type::Bool b; - ast::type::Array a(&b, 4, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&a, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.array(), "")) << gen.error(); EXPECT_EQ(gen.result(), "bool[4]"); } TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) { - ast::type::Bool b; - ast::type::Array a(&b, 0, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.array(), "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[1]"); } TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray_NameCollision) { - ast::type::Bool b; - ast::type::Array a(&b, 0, ast::ArrayDecorationList{}); - - ASSERT_TRUE(gen.EmitType(&a, "discard_fragment")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.array(), "discard_fragment")) + << gen.error(); EXPECT_EQ(gen.result(), "bool discard_fragment_tint_0[1]"); } TEST_F(MslGeneratorImplTest, EmitType_Bool) { - ast::type::Bool b; - - ASSERT_TRUE(gen.EmitType(&b, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.bool_, "")) << gen.error(); EXPECT_EQ(gen.result(), "bool"); } TEST_F(MslGeneratorImplTest, EmitType_F32) { - ast::type::F32 f32; - - ASSERT_TRUE(gen.EmitType(&f32, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.f32, "")) << gen.error(); EXPECT_EQ(gen.result(), "float"); } TEST_F(MslGeneratorImplTest, EmitType_I32) { - ast::type::I32 i32; - - ASSERT_TRUE(gen.EmitType(&i32, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.i32, "")) << gen.error(); EXPECT_EQ(gen.result(), "int"); } TEST_F(MslGeneratorImplTest, EmitType_Matrix) { - ast::type::F32 f32; - ast::type::Matrix m(&f32, 3, 2); - - ASSERT_TRUE(gen.EmitType(&m, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.mat2x3(), "")) << gen.error(); EXPECT_EQ(gen.result(), "float2x3"); } // TODO(dsinclair): How to annotate as workgroup? TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Pointer) { - ast::type::F32 f32; - ast::type::Pointer p(&f32, ast::StorageClass::kWorkgroup); + ast::type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup); ASSERT_TRUE(gen.EmitType(&p, "")) << gen.error(); EXPECT_EQ(gen.result(), "float*"); @@ -247,24 +217,17 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) { } TEST_F(MslGeneratorImplTest, EmitType_U32) { - ast::type::U32 u32; - - ASSERT_TRUE(gen.EmitType(&u32, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.u32, "")) << gen.error(); EXPECT_EQ(gen.result(), "uint"); } TEST_F(MslGeneratorImplTest, EmitType_Vector) { - ast::type::F32 f32; - ast::type::Vector v(&f32, 3); - - ASSERT_TRUE(gen.EmitType(&v, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.vec3(), "")) << gen.error(); EXPECT_EQ(gen.result(), "float3"); } TEST_F(MslGeneratorImplTest, EmitType_Void) { - ast::type::Void v; - - ASSERT_TRUE(gen.EmitType(&v, "")) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.void_, "")) << gen.error(); EXPECT_EQ(gen.result(), "void"); } @@ -324,8 +287,7 @@ using MslSampledtexturesTest = TestParamHelper; TEST_P(MslSampledtexturesTest, Emit) { auto params = GetParam(); - ast::type::F32 f32; - ast::type::SampledTexture s(params.dim, &f32); + ast::type::SampledTexture s(params.dim, ty.f32); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), params.result); @@ -350,8 +312,7 @@ INSTANTIATE_TEST_SUITE_P( "texturecube_array"})); TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) { - ast::type::U32 u32; - ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, &u32); + ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, ty.u32); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), "texture2d_ms"); diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc index 0a89380c1d..777bb3254d 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -131,9 +131,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec) { - ast::ExpressionList values; - auto* zero_vec = - create(ty.vec3(), values); + auto* zero_vec = vec3(); auto* var = Var("a", ast::StorageClass::kNone, ty.vec3(), zero_vec, ast::VariableDecorationList{}); diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index 734cae791a..6fdd1c6d3b 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -718,7 +718,6 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { // vec2(0.5, -0.5)); // pos[1] - ast::type::U32 u32; ast::type::Array arr(ty.vec2(), 3, ast::ArrayDecorationList{}); auto* var = Const("pos", ast::StorageClass::kPrivate, &arr, diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index 97b744ad10..463dbf7368 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -88,8 +88,7 @@ TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) { TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { auto* v = Var("var", ast::StorageClass::kOutput, ty.vec3()); - auto* val = create(ty.vec3(), - ast::ExpressionList{}); + auto* val = vec3(); auto* assign = create(Expr("var"), val); td.RegisterVariableForTesting(v); @@ -115,11 +114,7 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { } TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) { - auto* first = create( - ty.vec2(), ast::ExpressionList{Expr(1.f), Expr(2.f)}); - - auto* init = create( - ty.vec3(), ast::ExpressionList{first, Expr(3.f)}); + auto* init = vec3(vec2(1.f, 2.f), 3.f); auto* v = Var("var", ast::StorageClass::kOutput, ty.vec3()); auto* assign = create(Expr("var"), init); @@ -154,8 +149,7 @@ OpStore %1 %13 } TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(2.f), Expr(3.f)}); + auto* init = vec3(1.f, 2.f, 3.f); auto* v = Var("var", ast::StorageClass::kOutput, ty.vec3()); auto* assign = create(Expr("var"), init); @@ -231,8 +225,7 @@ OpStore %8 %9 TEST_F(BuilderTest, Assign_Vector) { auto* v = Var("var", ast::StorageClass::kOutput, ty.vec3()); - auto* val = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* val = vec3(1.f, 1.f, 3.f); auto* assign = create(Expr("var"), val); td.RegisterVariableForTesting(v); diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index 425b04c48e..e614b5137b 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -140,12 +140,8 @@ using BinaryArithUnsignedIntegerTest = TestParamHelper; TEST_P(BinaryArithUnsignedIntegerTest, Scalar) { auto param = GetParam(); - ast::type::U32 u32; - - auto* lhs = create( - create(&u32, 3)); - auto* rhs = create( - create(&u32, 4)); + auto* lhs = Expr(3u); + auto* rhs = Expr(4u); auto* expr = create(param.op, lhs, rhs); @@ -201,12 +197,8 @@ using BinaryArithFloatTest = TestParamHelper; TEST_P(BinaryArithFloatTest, Scalar) { auto param = GetParam(); - ast::type::F32 f32; - - auto* lhs = create( - create(&f32, 3.2f)); - auto* rhs = create( - create(&f32, 4.5f)); + auto* lhs = Expr(3.2f); + auto* rhs = Expr(4.5f); auto* expr = create(param.op, lhs, rhs); @@ -256,12 +248,8 @@ using BinaryCompareUnsignedIntegerTest = TestParamHelper; TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) { auto param = GetParam(); - ast::type::U32 u32; - - auto* lhs = create( - create(&u32, 3)); - auto* rhs = create( - create(&u32, 4)); + auto* lhs = Expr(3u); + auto* rhs = Expr(4u); auto* expr = create(param.op, lhs, rhs); @@ -522,8 +510,7 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) { TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { auto* var = Var("mat", ast::StorageClass::kFunction, ty.mat3x3()); - auto* rhs = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(1.f)}); + auto* rhs = vec3(1.f, 1.f, 1.f); td.RegisterVariableForTesting(var); @@ -552,8 +539,7 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) { auto* var = Var("mat", ast::StorageClass::kFunction, ty.mat3x3()); - auto* lhs = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(1.f)}); + auto* lhs = vec3(1.f, 1.f, 1.f); td.RegisterVariableForTesting(var); @@ -643,8 +629,6 @@ OpBranch %7 } TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) { - ast::type::Bool bool_type; - auto* a_var = Var("a", ast::StorageClass::kFunction, ty.bool_, Expr(true), ast::VariableDecorationList{}); auto* b_var = Var("b", ast::StorageClass::kFunction, ty.bool_, Expr(false), @@ -686,24 +670,15 @@ OpBranch %9 } TEST_F(BuilderTest, Binary_logicalOr_Nested_LogicalAnd) { - ast::type::Bool bool_ty; - // Test an expression like // a || (b && c) // From: crbug.com/tint/355 auto* logical_and_expr = create( - ast::BinaryOp::kLogicalAnd, - create( - create(&bool_ty, true)), - create( - create(&bool_ty, false))); + ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false)); - auto* expr = create( - ast::BinaryOp::kLogicalOr, - create( - create(&bool_ty, true)), - logical_and_expr); + auto* expr = create(ast::BinaryOp::kLogicalOr, + Expr(true), logical_and_expr); ASSERT_TRUE(td.DetermineResultType(expr)) << td.error(); @@ -733,24 +708,15 @@ OpBranch %4 } TEST_F(BuilderTest, Binary_logicalAnd_Nested_LogicalOr) { - ast::type::Bool bool_ty; - // Test an expression like // a && (b || c) // From: crbug.com/tint/355 auto* logical_or_expr = create( - ast::BinaryOp::kLogicalOr, - create( - create(&bool_ty, true)), - create( - create(&bool_ty, false))); + ast::BinaryOp::kLogicalOr, Expr(true), Expr(false)); - auto* expr = create( - ast::BinaryOp::kLogicalAnd, - create( - create(&bool_ty, true)), - logical_or_expr); + auto* expr = create(ast::BinaryOp::kLogicalAnd, + Expr(true), logical_or_expr); ASSERT_TRUE(td.DetermineResultType(expr)) << td.error(); @@ -816,8 +782,6 @@ OpBranch %7 } TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) { - ast::type::Bool bool_type; - auto* a_var = Var("a", ast::StorageClass::kFunction, ty.bool_, Expr(true), ast::VariableDecorationList{}); auto* b_var = Var("b", ast::StorageClass::kFunction, ty.bool_, Expr(false), diff --git a/src/writer/spirv/builder_bitcast_expression_test.cc b/src/writer/spirv/builder_bitcast_expression_test.cc index ee068dc9f2..e64aecf80e 100644 --- a/src/writer/spirv/builder_bitcast_expression_test.cc +++ b/src/writer/spirv/builder_bitcast_expression_test.cc @@ -49,8 +49,6 @@ TEST_F(BuilderTest, Bitcast) { } TEST_F(BuilderTest, Bitcast_DuplicateType) { - ast::type::F32 f32; - auto* bitcast = create(ty.f32, Expr(2.4f)); ASSERT_TRUE(td.DetermineResultType(bitcast)) << td.error(); diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc index fe77612329..70a08d05a0 100644 --- a/src/writer/spirv/builder_block_test.cc +++ b/src/writer/spirv/builder_block_test.cc @@ -35,8 +35,6 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Block) { - ast::type::F32 f32; - // Note, this test uses shadow variables which aren't allowed in WGSL but // serves to prove the block code is pushing new scopes as needed. auto* inner = create(ast::StatementList{ diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index 4788081410..51d9e9f814 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -40,9 +40,6 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Expression_Call) { - ast::type::F32 f32; - ast::type::Void void_type; - ast::VariableList func_params; func_params.push_back(Var("a", ast::StorageClass::kFunction, ty.f32)); func_params.push_back(Var("b", ast::StorageClass::kFunction, ty.f32)); diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc index 02c8c75d32..0b8c9e1dff 100644 --- a/src/writer/spirv/builder_constructor_expression_test.cc +++ b/src/writer/spirv/builder_constructor_expression_test.cc @@ -115,7 +115,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithAlias) { // cast(2.3f) auto* alias = ty.alias("Int", ty.i32); - auto* cast = create(alias, ExprList(2.3f)); + auto* cast = Construct(alias, 2.3f); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -197,7 +197,7 @@ TEST_F(SpvBuilderConstructorTest, Type_NonConst_Value_Fails) { } TEST_F(SpvBuilderConstructorTest, Type_Bool_With_Bool) { - auto* cast = create(ty.bool_, ExprList(true)); + auto* cast = Construct(true); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -213,7 +213,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Bool_With_Bool) { } TEST_F(SpvBuilderConstructorTest, Type_I32_With_I32) { - auto* cast = create(ty.i32, ExprList(2)); + auto* cast = Construct(2); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -227,7 +227,7 @@ TEST_F(SpvBuilderConstructorTest, Type_I32_With_I32) { } TEST_F(SpvBuilderConstructorTest, Type_U32_With_U32) { - auto* cast = create(ty.u32, ExprList(2u)); + auto* cast = Construct(2u); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -241,7 +241,7 @@ TEST_F(SpvBuilderConstructorTest, Type_U32_With_U32) { } TEST_F(SpvBuilderConstructorTest, Type_F32_With_F32) { - auto* cast = create(ty.f32, ExprList(2.0f)); + auto* cast = Construct(2.0f); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -993,7 +993,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_F32) { } TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_I32) { - auto* t = Construct(ty.i32); + auto* t = Construct(); EXPECT_TRUE(td.DetermineResultType(t)) << td.error(); @@ -1008,7 +1008,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_I32) { } TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_U32) { - auto* t = Construct(ty.u32); + auto* t = Construct(); EXPECT_TRUE(td.DetermineResultType(t)) << td.error(); @@ -1110,7 +1110,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_I32) { - auto* cast = Construct(ty.i32, 2u); + auto* cast = Construct(2u); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1127,7 +1127,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_I32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_U32) { - auto* cast = Construct(ty.u32, 2); + auto* cast = Construct(2); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1144,7 +1144,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_U32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) { - auto* cast = Construct(ty.i32, 2.4f); + auto* cast = Construct(2.4f); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1161,7 +1161,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) { - auto* cast = Construct(ty.u32, 2.4f); + auto* cast = Construct(2.4f); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1178,7 +1178,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F32) { - auto* cast = Construct(ty.f32, 2); + auto* cast = Construct(2); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1195,7 +1195,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F32) { - auto* cast = Construct(ty.f32, 2u); + auto* cast = Construct(2u); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1214,7 +1214,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_I32) { auto* var = Var("i", ast::StorageClass::kPrivate, ty.vec3()); - auto* cast = Construct(ty.vec3(), "i"); + auto* cast = vec3("i"); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1239,7 +1239,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_I32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_I32) { auto* var = Var("i", ast::StorageClass::kPrivate, ty.vec3()); - auto* cast = Construct(ty.vec3(), "i"); + auto* cast = vec3("i"); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1264,7 +1264,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_I32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_U32) { auto* var = Var("i", ast::StorageClass::kPrivate, ty.vec3()); - auto* cast = Construct(ty.vec3(), "i"); + auto* cast = vec3("i"); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1289,7 +1289,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_U32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_U32) { auto* var = Var("i", ast::StorageClass::kPrivate, ty.vec3()); - auto* cast = Construct(ty.vec3(), "i"); + auto* cast = vec3("i"); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1314,7 +1314,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_U32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F32) { auto* var = Var("i", ast::StorageClass::kPrivate, ty.vec3()); - auto* cast = Construct(ty.vec3(), "i"); + auto* cast = vec3("i"); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); @@ -1339,7 +1339,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F32) { auto* var = Var("i", ast::StorageClass::kPrivate, ty.vec3()); - auto* cast = Construct(ty.vec3(), "i"); + auto* cast = vec3("i"); ASSERT_TRUE(td.DetermineResultType(cast)) << td.error(); diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index d3b50faaeb..16189d6aac 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -22,8 +22,6 @@ #include "src/ast/identifier_expression.h" #include "src/ast/pipeline_stage.h" #include "src/ast/stage_decoration.h" -#include "src/ast/type/f32_type.h" -#include "src/ast/type/void_type.h" #include "src/ast/variable.h" #include "src/ast/workgroup_decoration.h" #include "src/type_determiner.h" @@ -88,9 +86,6 @@ INSTANTIATE_TEST_SUITE_P( SpvExecutionModelGLCompute})); TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) { - ast::type::F32 f32; - ast::type::Void void_type; - auto* func = Func("main", {}, ty.void_, ast::StatementList{}, ast::FunctionDecorationList{ diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc index ee02aea89b..fef4b90055 100644 --- a/src/writer/spirv/builder_function_variable_test.cc +++ b/src/writer/spirv/builder_function_variable_test.cc @@ -63,8 +63,7 @@ TEST_F(BuilderTest, FunctionVar_NoStorageClass) { } TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* init = vec3(1.f, 1.f, 3.f); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, init, @@ -93,8 +92,7 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { } TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) { - auto* init = create( - ty.vec2(), ast::ExpressionList{Expr(1.f), Add(3.f, 3.f)}); + auto* init = vec2(1.f, Add(3.f, 3.f)); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Var("var", ast::StorageClass::kFunction, ty.vec2(), init, @@ -203,8 +201,7 @@ OpStore %7 %6 } TEST_F(BuilderTest, FunctionVar_Const) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* init = vec3(1.f, 1.f, 3.f); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init, diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index 2543a3a245..6d67e53e4b 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -85,8 +85,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) { } TEST_F(BuilderTest, GlobalVar_WithConstructor) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* init = vec3(1.f, 1.f, 3.f); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, init, @@ -109,8 +108,7 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) { } TEST_F(BuilderTest, GlobalVar_Const) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* init = vec3(1.f, 1.f, 3.f); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init, @@ -131,8 +129,7 @@ TEST_F(BuilderTest, GlobalVar_Const) { } TEST_F(BuilderTest, GlobalVar_Complex_Constructor) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(2.f), Expr(3.f)}); + auto* init = vec3(ast::ExpressionList{Expr(1.f), Expr(2.f), Expr(3.f)}); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init, @@ -152,11 +149,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) { } TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { - auto* first = create( - ty.vec2(), ast::ExpressionList{Expr(1.f), Expr(2.f)}); - - auto* init = create( - ty.vec3(), ast::ExpressionList{first, Expr(3.f)}); + auto* init = vec3(vec2(1.f, 2.f), 3.f); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc index c06fb70186..453ef6bcae 100644 --- a/src/writer/spirv/builder_ident_expression_test.cc +++ b/src/writer/spirv/builder_ident_expression_test.cc @@ -38,8 +38,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* init = vec3(1.f, 1.f, 3.f); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init, @@ -81,8 +80,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalVar) { } TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { - auto* init = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* init = vec3(1.f, 1.f, 3.f); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init, diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc index 966c082f67..25e03b89a2 100644 --- a/src/writer/spirv/builder_if_test.cc +++ b/src/writer/spirv/builder_if_test.cc @@ -41,12 +41,9 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, If_Empty) { - ast::type::Bool bool_type; - // if (true) { // } - auto* cond = create( - create(&bool_type, true)); + auto* cond = Expr(true); auto* expr = create( cond, create(ast::StatementList{}), @@ -70,13 +67,10 @@ OpBranch %3 } TEST_F(BuilderTest, If_Empty_OutsideFunction_IsError) { - ast::type::Bool bool_type; - // Outside a function. // if (true) { // } - auto* cond = create( - create(&bool_type, true)); + auto* cond = Expr(true); ast::ElseStatementList elses; auto* block = create(ast::StatementList{}); diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc index b91fa7dd6d..b9cfb02559 100644 --- a/src/writer/spirv/builder_loop_test.cc +++ b/src/writer/spirv/builder_loop_test.cc @@ -100,7 +100,6 @@ OpBranch %5 } TEST_F(BuilderTest, Loop_WithContinuing) { - ast::type::I32 i32; // loop { // a = 2; // continuing { diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc index 5e711093b5..d3a55ff039 100644 --- a/src/writer/spirv/builder_return_test.cc +++ b/src/writer/spirv/builder_return_test.cc @@ -46,8 +46,7 @@ TEST_F(BuilderTest, Return) { } TEST_F(BuilderTest, Return_WithValue) { - auto* val = create( - ty.vec3(), ast::ExpressionList{Expr(1.f), Expr(1.f), Expr(3.f)}); + auto* val = vec3(1.f, 1.f, 3.f); auto* ret = create(val); diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc index 289761d2d6..2d8a85d245 100644 --- a/src/writer/wgsl/generator_impl_array_accessor_test.cc +++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc @@ -31,8 +31,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) { - auto* lit = create(ty.i32, 5); - auto* idx = create(lit); + auto* idx = Expr(5); auto* ary = Expr("ary"); auto* expr = create(ary, idx); diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc index 0bdd97fa84..99121cad5a 100644 --- a/src/writer/wgsl/generator_impl_test.cc +++ b/src/writer/wgsl/generator_impl_test.cc @@ -30,9 +30,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Generate) { - ast::type::Void void_type; - - mod->AddFunction(Func("my_func", ast::VariableList{}, &void_type, + mod->AddFunction(Func("my_func", ast::VariableList{}, ty.void_, ast::StatementList{}, ast::FunctionDecorationList{})); ASSERT_TRUE(gen.Generate(*mod)) << gen.error(); diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc index 4a81c29833..dfc9e7cba7 100644 --- a/src/writer/wgsl/generator_impl_type_test.cc +++ b/src/writer/wgsl/generator_impl_type_test.cc @@ -202,9 +202,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Vector) { } TEST_F(WgslGeneratorImplTest, EmitType_Void) { - ast::type::Void v; - - ASSERT_TRUE(gen.EmitType(&v)) << gen.error(); + ASSERT_TRUE(gen.EmitType(ty.void_)) << gen.error(); EXPECT_EQ(gen.result(), "void"); }