From 5ed161b2d9421b8ca9b8e337636b4dcafbbee843 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Sat, 12 Dec 2020 01:35:43 +0000 Subject: [PATCH] ast: Add Source argument to literals Bug: tint:396 Bug: tint:390 Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019 Commit-Queue: Ben Clayton Reviewed-by: dan sinclair --- src/ast/bool_literal.cc | 7 +- src/ast/bool_literal.h | 3 +- src/ast/bool_literal_test.cc | 10 +- src/ast/builder.h | 16 +- src/ast/case_statement_test.cc | 20 +- src/ast/clone_context.h | 3 +- src/ast/else_statement_test.cc | 6 +- src/ast/float_literal.cc | 7 +- src/ast/float_literal.h | 3 +- src/ast/float_literal_test.cc | 8 +- src/ast/int_literal.cc | 3 +- src/ast/int_literal.h | 3 +- src/ast/int_literal_test.cc | 4 +- src/ast/literal.cc | 3 +- src/ast/literal.h | 3 +- src/ast/node.h | 2 +- src/ast/null_literal.cc | 6 +- src/ast/null_literal.h | 3 +- src/ast/null_literal_test.cc | 6 +- src/ast/scalar_constructor_expression_test.cc | 8 +- src/ast/sint_literal.cc | 7 +- src/ast/sint_literal.h | 3 +- src/ast/sint_literal_test.cc | 10 +- src/ast/switch_statement_test.cc | 14 +- src/ast/uint_literal.cc | 7 +- src/ast/uint_literal.h | 3 +- src/ast/uint_literal_test.cc | 9 +- src/inspector/inspector_test.cc | 8 +- src/reader/spirv/function.cc | 20 +- src/reader/spirv/function.h | 6 +- src/reader/spirv/parser_impl.cc | 31 +- src/reader/wgsl/parser_impl.cc | 10 +- src/transform/bound_array_accessors.cc | 8 +- src/transform/emit_vertex_point_size.cc | 2 +- src/transform/vertex_pulling.cc | 2 +- src/type_determiner_test.cc | 585 +++++++++--------- src/validator/validator_control_block_test.cc | 66 +- src/validator/validator_function_test.cc | 20 +- src/validator/validator_test.cc | 126 ++-- src/writer/hlsl/generator_impl.cc | 2 +- .../generator_impl_array_accessor_test.cc | 2 +- src/writer/hlsl/generator_impl_binary_test.cc | 38 +- src/writer/hlsl/generator_impl_case_test.cc | 10 +- .../hlsl/generator_impl_constructor_test.cc | 48 +- .../hlsl/generator_impl_function_test.cc | 25 +- src/writer/hlsl/generator_impl_import_test.cc | 36 +- src/writer/hlsl/generator_impl_loop_test.cc | 4 +- .../generator_impl_member_accessor_test.cc | 48 +- .../generator_impl_module_constant_test.cc | 8 +- src/writer/hlsl/generator_impl_switch_test.cc | 2 +- .../msl/generator_impl_array_accessor_test.cc | 2 +- src/writer/msl/generator_impl_case_test.cc | 10 +- .../msl/generator_impl_constructor_test.cc | 48 +- .../msl/generator_impl_function_test.cc | 25 +- src/writer/msl/generator_impl_import_test.cc | 36 +- src/writer/msl/generator_impl_loop_test.cc | 4 +- .../generator_impl_module_constant_test.cc | 8 +- src/writer/msl/generator_impl_switch_test.cc | 2 +- src/writer/spirv/builder.cc | 20 +- .../spirv/builder_accessor_expression_test.cc | 48 +- src/writer/spirv/builder_assign_test.cc | 28 +- .../spirv/builder_binary_expression_test.cc | 222 +++---- .../spirv/builder_bitcast_expression_test.cc | 12 +- src/writer/spirv/builder_block_test.cc | 6 +- src/writer/spirv/builder_call_test.cc | 8 +- .../spirv/builder_function_variable_test.cc | 30 +- .../spirv/builder_global_variable_test.cc | 28 +- .../spirv/builder_ident_expression_test.cc | 14 +- src/writer/spirv/builder_if_test.cc | 48 +- src/writer/spirv/builder_literal_test.cc | 26 +- src/writer/spirv/builder_loop_test.cc | 6 +- src/writer/spirv/builder_return_test.cc | 6 +- src/writer/spirv/builder_switch_test.cc | 52 +- .../spirv/builder_unary_op_expression_test.cc | 16 +- .../generator_impl_array_accessor_test.cc | 2 +- src/writer/wgsl/generator_impl_case_test.cc | 6 +- .../wgsl/generator_impl_constructor_test.cc | 44 +- src/writer/wgsl/generator_impl_switch_test.cc | 2 +- 78 files changed, 1038 insertions(+), 1005 deletions(-) diff --git a/src/ast/bool_literal.cc b/src/ast/bool_literal.cc index 4c6af63923..c21d87fde8 100644 --- a/src/ast/bool_literal.cc +++ b/src/ast/bool_literal.cc @@ -22,8 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::BoolLiteral); namespace tint { namespace ast { -BoolLiteral::BoolLiteral(type::Type* type, bool value) - : Base(type), value_(value) {} +BoolLiteral::BoolLiteral(const Source& source, type::Type* type, bool value) + : Base(source, type), value_(value) {} BoolLiteral::~BoolLiteral() = default; @@ -36,7 +36,8 @@ std::string BoolLiteral::name() const { } BoolLiteral* BoolLiteral::Clone(CloneContext* ctx) const { - return ctx->mod->create(ctx->Clone(type()), value_); + return ctx->mod->create(ctx->Clone(source()), ctx->Clone(type()), + value_); } } // namespace ast diff --git a/src/ast/bool_literal.h b/src/ast/bool_literal.h index c95ca827fb..1b984f5f2d 100644 --- a/src/ast/bool_literal.h +++ b/src/ast/bool_literal.h @@ -26,9 +26,10 @@ namespace ast { class BoolLiteral : public Castable { public: /// Constructor + /// @param source the input source /// @param type the type of the literal /// @param value the bool literals value - BoolLiteral(type::Type* type, bool value); + BoolLiteral(const Source& source, type::Type* type, bool value); ~BoolLiteral() override; /// @returns true if the bool literal is true diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc index 186d71e7a2..d98f98891d 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -29,7 +29,7 @@ using BoolLiteralTest = TestHelper; TEST_F(BoolLiteralTest, True) { type::Bool bool_type; - BoolLiteral b{&bool_type, true}; + BoolLiteral b{Source{}, &bool_type, true}; ASSERT_TRUE(b.Is()); ASSERT_TRUE(b.IsTrue()); ASSERT_FALSE(b.IsFalse()); @@ -37,7 +37,7 @@ TEST_F(BoolLiteralTest, True) { TEST_F(BoolLiteralTest, False) { type::Bool bool_type; - BoolLiteral b{&bool_type, false}; + BoolLiteral b{Source{}, &bool_type, false}; ASSERT_TRUE(b.Is()); ASSERT_FALSE(b.IsTrue()); ASSERT_TRUE(b.IsFalse()); @@ -45,7 +45,7 @@ TEST_F(BoolLiteralTest, False) { TEST_F(BoolLiteralTest, Is) { type::Bool bool_type; - BoolLiteral b{&bool_type, false}; + BoolLiteral b{Source{}, &bool_type, false}; Literal* l = &b; EXPECT_TRUE(l->Is()); EXPECT_FALSE(l->Is()); @@ -57,8 +57,8 @@ TEST_F(BoolLiteralTest, Is) { TEST_F(BoolLiteralTest, ToStr) { type::Bool bool_type; - BoolLiteral t{&bool_type, true}; - BoolLiteral f{&bool_type, false}; + BoolLiteral t{Source{}, &bool_type, true}; + BoolLiteral f{Source{}, &bool_type, false}; EXPECT_EQ(t.to_str(), "true"); EXPECT_EQ(f.to_str(), "false"); diff --git a/src/ast/builder.h b/src/ast/builder.h index 189ebdb91d..63e625c205 100644 --- a/src/ast/builder.h +++ b/src/ast/builder.h @@ -275,19 +275,27 @@ class Builder { /// @param val the boolan value /// @return a boolean literal with the given value - BoolLiteral* Literal(bool val) { return create(ty.bool_, val); } + BoolLiteral* Literal(bool val) { + return create(Source{}, ty.bool_, val); + } /// @param val the float value /// @return a float literal with the given value - FloatLiteral* Literal(f32 val) { return create(ty.f32, val); } + FloatLiteral* Literal(f32 val) { + return create(Source{}, ty.f32, val); + } /// @param val the unsigned int value /// @return a UintLiteral with the given value - UintLiteral* Literal(u32 val) { return create(ty.u32, val); } + UintLiteral* Literal(u32 val) { + return create(Source{}, ty.u32, val); + } /// @param val the integer value /// @return the SintLiteral with the given value - SintLiteral* Literal(i32 val) { return create(ty.i32, val); } + SintLiteral* Literal(i32 val) { + return create(Source{}, ty.i32, val); + } /// @param args the arguments for the type constructor /// @return an `TypeConstructorExpression` of type `ty`, with the values diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc index 37617a8083..9ecf1bbae5 100644 --- a/src/ast/case_statement_test.cc +++ b/src/ast/case_statement_test.cc @@ -32,7 +32,7 @@ TEST_F(CaseStatementTest, Creation_i32) { type::I32 i32; CaseSelectorList b; - auto* selector = create(&i32, 2); + auto* selector = create(Source{}, &i32, 2); b.push_back(selector); auto* body = create(); @@ -50,7 +50,7 @@ TEST_F(CaseStatementTest, Creation_u32) { type::U32 u32; CaseSelectorList b; - auto* selector = create(&u32, 2); + auto* selector = create(Source{}, &u32, 2); b.push_back(selector); auto* body = create(); @@ -67,7 +67,7 @@ TEST_F(CaseStatementTest, Creation_u32) { TEST_F(CaseStatementTest, Creation_WithSource) { type::I32 i32; CaseSelectorList b; - b.push_back(create(&i32, 2)); + b.push_back(create(Source{}, &i32, 2)); auto* body = create(); body->append(create()); @@ -89,7 +89,7 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) { TEST_F(CaseStatementTest, IsDefault_WithSelectors) { type::I32 i32; CaseSelectorList b; - b.push_back(create(&i32, 2)); + b.push_back(create(Source{}, &i32, 2)); CaseStatement c(b, create()); EXPECT_FALSE(c.IsDefault()); @@ -108,7 +108,7 @@ TEST_F(CaseStatementTest, IsValid) { TEST_F(CaseStatementTest, IsValid_NullBodyStatement) { type::I32 i32; CaseSelectorList b; - b.push_back(create(&i32, 2)); + b.push_back(create(Source{}, &i32, 2)); auto* body = create(); body->append(create()); @@ -121,7 +121,7 @@ TEST_F(CaseStatementTest, IsValid_NullBodyStatement) { TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) { type::I32 i32; CaseSelectorList b; - b.push_back(create(&i32, 2)); + b.push_back(create(Source{}, &i32, 2)); auto* body = create(); body->append(create(Source{}, nullptr, create(), @@ -134,7 +134,7 @@ TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) { TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) { type::I32 i32; CaseSelectorList b; - b.push_back(create(&i32, -2)); + b.push_back(create(Source{}, &i32, -2)); auto* body = create(); body->append(create()); @@ -151,7 +151,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) { TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) { type::U32 u32; CaseSelectorList b; - b.push_back(create(&u32, 2)); + b.push_back(create(Source{}, &u32, 2)); auto* body = create(); body->append(create()); @@ -169,8 +169,8 @@ TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) { type::I32 i32; CaseSelectorList b; - b.push_back(create(&i32, 1)); - b.push_back(create(&i32, 2)); + b.push_back(create(Source{}, &i32, 1)); + b.push_back(create(Source{}, &i32, 2)); auto* body = create(); body->append(create()); diff --git a/src/ast/clone_context.h b/src/ast/clone_context.h index 7733b850be..9bfb906c9b 100644 --- a/src/ast/clone_context.h +++ b/src/ast/clone_context.h @@ -109,7 +109,8 @@ class CloneContext { /// // Replace all ast::UintLiterals with the number 42 /// CloneCtx ctx(mod); /// ctx.ReplaceAll([&] (ast::UintLiteral* in) { - /// return ctx.mod->create(ctx.Clone(in->type()), 42); + /// return ctx.mod->create(ctx.Clone(in->source()), + /// ctx.Clone(in->type()), 42); /// }); /// auto* out = ctx.Clone(tree); /// ``` diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc index 98dfd71446..58a75af911 100644 --- a/src/ast/else_statement_test.cc +++ b/src/ast/else_statement_test.cc @@ -30,7 +30,7 @@ using ElseStatementTest = TestHelper; TEST_F(ElseStatementTest, Creation) { type::Bool bool_type; auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* body = create(); body->append(create()); @@ -57,7 +57,7 @@ TEST_F(ElseStatementTest, IsElse) { TEST_F(ElseStatementTest, HasCondition) { type::Bool bool_type; auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); ElseStatement e(cond, create()); EXPECT_TRUE(e.HasCondition()); } @@ -107,7 +107,7 @@ TEST_F(ElseStatementTest, IsValid_InvalidBodyStatement) { TEST_F(ElseStatementTest, ToStr) { type::Bool bool_type; auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* body = create(); body->append(create()); diff --git a/src/ast/float_literal.cc b/src/ast/float_literal.cc index d6f30c7841..5ce4347ca5 100644 --- a/src/ast/float_literal.cc +++ b/src/ast/float_literal.cc @@ -25,8 +25,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::FloatLiteral); namespace tint { namespace ast { -FloatLiteral::FloatLiteral(type::Type* type, float value) - : Base(type), value_(value) {} +FloatLiteral::FloatLiteral(const Source& source, type::Type* type, float value) + : Base(source, type), value_(value) {} FloatLiteral::~FloatLiteral() = default; @@ -43,7 +43,8 @@ std::string FloatLiteral::name() const { } FloatLiteral* FloatLiteral::Clone(CloneContext* ctx) const { - return ctx->mod->create(ctx->Clone(type()), value_); + return ctx->mod->create(ctx->Clone(source()), + ctx->Clone(type()), value_); } } // namespace ast diff --git a/src/ast/float_literal.h b/src/ast/float_literal.h index 9e55e47e53..ad33124932 100644 --- a/src/ast/float_literal.h +++ b/src/ast/float_literal.h @@ -26,9 +26,10 @@ namespace ast { class FloatLiteral : public Castable { public: /// Constructor + /// @param source the input source /// @param type the type of the literal /// @param value the float literals value - FloatLiteral(type::Type* type, float value); + FloatLiteral(const Source& source, type::Type* type, float value); ~FloatLiteral() override; /// @returns the float literal value diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc index 77b03f6cbf..2b4394e38a 100644 --- a/src/ast/float_literal_test.cc +++ b/src/ast/float_literal_test.cc @@ -29,14 +29,14 @@ using FloatLiteralTest = TestHelper; TEST_F(FloatLiteralTest, Value) { type::F32 f32; - FloatLiteral f{&f32, 47.2f}; + FloatLiteral f{Source{}, &f32, 47.2f}; ASSERT_TRUE(f.Is()); EXPECT_EQ(f.value(), 47.2f); } TEST_F(FloatLiteralTest, Is) { type::F32 f32; - FloatLiteral f{&f32, 42.f}; + FloatLiteral f{Source{}, &f32, 42.f}; Literal* l = &f; EXPECT_FALSE(l->Is()); EXPECT_FALSE(l->Is()); @@ -48,14 +48,14 @@ TEST_F(FloatLiteralTest, Is) { TEST_F(FloatLiteralTest, ToStr) { type::F32 f32; - FloatLiteral f{&f32, 42.1f}; + FloatLiteral f{Source{}, &f32, 42.1f}; EXPECT_EQ(f.to_str(), "42.099998"); } TEST_F(FloatLiteralTest, ToName) { type::F32 f32; - FloatLiteral f{&f32, 42.1f}; + FloatLiteral f{Source{}, &f32, 42.1f}; EXPECT_EQ(f.name(), "__float42.0999985"); } diff --git a/src/ast/int_literal.cc b/src/ast/int_literal.cc index aa35f3cdc3..e48801e7b3 100644 --- a/src/ast/int_literal.cc +++ b/src/ast/int_literal.cc @@ -19,7 +19,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::IntLiteral); namespace tint { namespace ast { -IntLiteral::IntLiteral(type::Type* type) : Base(type) {} +IntLiteral::IntLiteral(const Source& source, type::Type* type) + : Base(source, type) {} IntLiteral::~IntLiteral() = default; diff --git a/src/ast/int_literal.h b/src/ast/int_literal.h index 49ecda47b1..f522c1eb6a 100644 --- a/src/ast/int_literal.h +++ b/src/ast/int_literal.h @@ -27,8 +27,9 @@ class IntLiteral : public Castable { protected: /// Constructor + /// @param source the input source /// @param type the type of the literal - explicit IntLiteral(type::Type* type); + IntLiteral(const Source& source, type::Type* type); }; } // namespace ast diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc index 3a1eb7599c..edf744042d 100644 --- a/src/ast/int_literal_test.cc +++ b/src/ast/int_literal_test.cc @@ -31,13 +31,13 @@ using IntLiteralTest = TestHelper; TEST_F(IntLiteralTest, Sint_IsInt) { type::I32 i32; - SintLiteral i{&i32, 47}; + SintLiteral i{Source{}, &i32, 47}; ASSERT_TRUE(i.Is()); } TEST_F(IntLiteralTest, Uint_IsInt) { type::I32 i32; - UintLiteral i{&i32, 42}; + UintLiteral i{Source{}, &i32, 42}; EXPECT_TRUE(i.Is()); } diff --git a/src/ast/literal.cc b/src/ast/literal.cc index 77a7612573..05375ad2d3 100644 --- a/src/ast/literal.cc +++ b/src/ast/literal.cc @@ -19,7 +19,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::Literal); namespace tint { namespace ast { -Literal::Literal(type::Type* type) : type_(type) {} +Literal::Literal(const Source& source, type::Type* type) + : Base(source), type_(type) {} Literal::~Literal() = default; diff --git a/src/ast/literal.h b/src/ast/literal.h index 947ed38e96..dea8a63563 100644 --- a/src/ast/literal.h +++ b/src/ast/literal.h @@ -47,8 +47,9 @@ class Literal : public Castable { protected: /// Constructor + /// @param source the input source /// @param type the type of the literal - explicit Literal(type::Type* type); + explicit Literal(const Source& source, type::Type* type); private: type::Type* type_ = nullptr; diff --git a/src/ast/node.h b/src/ast/node.h index f72c41aebe..42301d5119 100644 --- a/src/ast/node.h +++ b/src/ast/node.h @@ -64,7 +64,7 @@ class Node : public Castable { /// Create a new node Node(); /// Create a new node - /// @param source The input source for the node + /// @param source the input source for the node explicit Node(const Source& source); /// Move constructor Node(Node&&); diff --git a/src/ast/null_literal.cc b/src/ast/null_literal.cc index 4ae8324c78..9b654a3000 100644 --- a/src/ast/null_literal.cc +++ b/src/ast/null_literal.cc @@ -22,7 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::NullLiteral); namespace tint { namespace ast { -NullLiteral::NullLiteral(type::Type* type) : Base(type) {} +NullLiteral::NullLiteral(const Source& source, type::Type* type) + : Base(source, type) {} NullLiteral::~NullLiteral() = default; @@ -35,7 +36,8 @@ std::string NullLiteral::name() const { } NullLiteral* NullLiteral::Clone(CloneContext* ctx) const { - return ctx->mod->create(ctx->Clone(type())); + return ctx->mod->create(ctx->Clone(source()), + ctx->Clone(type())); } } // namespace ast diff --git a/src/ast/null_literal.h b/src/ast/null_literal.h index 8ae3ff03de..31ada3bfaa 100644 --- a/src/ast/null_literal.h +++ b/src/ast/null_literal.h @@ -26,8 +26,9 @@ namespace ast { class NullLiteral : public Castable { public: /// Constructor + /// @param source the input source /// @param type the type - explicit NullLiteral(type::Type* type); + NullLiteral(const Source& source, type::Type* type); ~NullLiteral() override; /// @returns the name for this literal. This name is unique to this value. diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc index 1ae8c83177..1d2afa01f8 100644 --- a/src/ast/null_literal_test.cc +++ b/src/ast/null_literal_test.cc @@ -29,7 +29,7 @@ using NullLiteralTest = TestHelper; TEST_F(NullLiteralTest, Is) { type::I32 i32; - NullLiteral i{&i32}; + NullLiteral i{Source{}, &i32}; Literal* l = &i; EXPECT_FALSE(l->Is()); EXPECT_FALSE(l->Is()); @@ -41,14 +41,14 @@ TEST_F(NullLiteralTest, Is) { TEST_F(NullLiteralTest, ToStr) { type::I32 i32; - NullLiteral i{&i32}; + NullLiteral i{Source{}, &i32}; EXPECT_EQ(i.to_str(), "null __i32"); } TEST_F(NullLiteralTest, Name_I32) { type::I32 i32; - NullLiteral i{&i32}; + NullLiteral i{Source{}, &i32}; EXPECT_EQ("__null__i32", i.name()); } diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc index 01683564db..cdb62f4d7b 100644 --- a/src/ast/scalar_constructor_expression_test.cc +++ b/src/ast/scalar_constructor_expression_test.cc @@ -26,14 +26,14 @@ using ScalarConstructorExpressionTest = TestHelper; TEST_F(ScalarConstructorExpressionTest, Creation) { type::Bool bool_type; - auto* b = create(&bool_type, true); + auto* b = create(Source{}, &bool_type, true); ScalarConstructorExpression c(b); EXPECT_EQ(c.literal(), b); } TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) { type::Bool bool_type; - auto* b = create(&bool_type, true); + auto* b = create(Source{}, &bool_type, true); ScalarConstructorExpression c(Source{Source::Location{20, 2}}, b); auto src = c.source(); EXPECT_EQ(src.range.begin.line, 20u); @@ -42,7 +42,7 @@ TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) { TEST_F(ScalarConstructorExpressionTest, IsValid) { type::Bool bool_type; - auto* b = create(&bool_type, true); + auto* b = create(Source{}, &bool_type, true); ScalarConstructorExpression c(b); EXPECT_TRUE(c.IsValid()); } @@ -54,7 +54,7 @@ TEST_F(ScalarConstructorExpressionTest, IsValid_MissingLiteral) { TEST_F(ScalarConstructorExpressionTest, ToStr) { type::Bool bool_type; - auto* b = create(&bool_type, true); + auto* b = create(Source{}, &bool_type, true); ScalarConstructorExpression c(b); std::ostringstream out; c.to_str(out, 2); diff --git a/src/ast/sint_literal.cc b/src/ast/sint_literal.cc index 0b3b4b3924..52b8b0eed8 100644 --- a/src/ast/sint_literal.cc +++ b/src/ast/sint_literal.cc @@ -22,8 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::SintLiteral); namespace tint { namespace ast { -SintLiteral::SintLiteral(type::Type* type, int32_t value) - : Base(type), value_(value) {} +SintLiteral::SintLiteral(const Source& source, type::Type* type, int32_t value) + : Base(source, type), value_(value) {} SintLiteral::~SintLiteral() = default; @@ -36,7 +36,8 @@ std::string SintLiteral::name() const { } SintLiteral* SintLiteral::Clone(CloneContext* ctx) const { - return ctx->mod->create(ctx->Clone(type()), value_); + return ctx->mod->create(ctx->Clone(source()), ctx->Clone(type()), + value_); } } // namespace ast diff --git a/src/ast/sint_literal.h b/src/ast/sint_literal.h index 9cba513665..cf4ac57730 100644 --- a/src/ast/sint_literal.h +++ b/src/ast/sint_literal.h @@ -26,9 +26,10 @@ namespace ast { class SintLiteral : public Castable { public: /// Constructor + /// @param source the input source /// @param type the type /// @param value the signed int literals value - SintLiteral(type::Type* type, int32_t value); + SintLiteral(const Source& source, type::Type* type, int32_t value); ~SintLiteral() override; /// @returns the int literal value diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc index 09b4a34b2b..f4fcc08ebb 100644 --- a/src/ast/sint_literal_test.cc +++ b/src/ast/sint_literal_test.cc @@ -30,14 +30,14 @@ using SintLiteralTest = TestHelper; TEST_F(SintLiteralTest, Value) { type::I32 i32; - SintLiteral i{&i32, 47}; + SintLiteral i{Source{}, &i32, 47}; ASSERT_TRUE(i.Is()); EXPECT_EQ(i.value(), 47); } TEST_F(SintLiteralTest, Is) { type::I32 i32; - SintLiteral i{&i32, 42}; + SintLiteral i{Source{}, &i32, 42}; Literal* l = &i; EXPECT_FALSE(l->Is()); EXPECT_TRUE(l->Is()); @@ -48,20 +48,20 @@ TEST_F(SintLiteralTest, Is) { TEST_F(SintLiteralTest, ToStr) { type::I32 i32; - SintLiteral i{&i32, -42}; + SintLiteral i{Source{}, &i32, -42}; EXPECT_EQ(i.to_str(), "-42"); } TEST_F(SintLiteralTest, Name_I32) { type::I32 i32; - SintLiteral i{&i32, 2}; + SintLiteral i{Source{}, &i32, 2}; EXPECT_EQ("__sint__i32_2", i.name()); } TEST_F(SintLiteralTest, Name_U32) { type::U32 u32; - SintLiteral i{&u32, 2}; + SintLiteral i{Source{}, &u32, 2}; EXPECT_EQ("__sint__u32_2", i.name()); } diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc index bd610faa6f..41232373fb 100644 --- a/src/ast/switch_statement_test.cc +++ b/src/ast/switch_statement_test.cc @@ -32,7 +32,7 @@ TEST_F(SwitchStatementTest, Creation) { type::I32 i32; CaseSelectorList lit; - lit.push_back(create(&i32, 1)); + lit.push_back(create(Source{}, &i32, 1)); auto* ident = create(mod.RegisterSymbol("ident"), "ident"); @@ -61,7 +61,7 @@ TEST_F(SwitchStatementTest, IsSwitch) { type::I32 i32; CaseSelectorList lit; - lit.push_back(create(&i32, 2)); + lit.push_back(create(Source{}, &i32, 2)); auto* ident = create(mod.RegisterSymbol("ident"), "ident"); @@ -76,7 +76,7 @@ TEST_F(SwitchStatementTest, IsValid) { type::I32 i32; CaseSelectorList lit; - lit.push_back(create(&i32, 2)); + lit.push_back(create(Source{}, &i32, 2)); auto* ident = create(mod.RegisterSymbol("ident"), "ident"); @@ -91,7 +91,7 @@ TEST_F(SwitchStatementTest, IsValid_Null_Condition) { type::I32 i32; CaseSelectorList lit; - lit.push_back(create(&i32, 2)); + lit.push_back(create(Source{}, &i32, 2)); CaseStatementList body; body.push_back(create(lit, create())); @@ -104,7 +104,7 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) { type::I32 i32; CaseSelectorList lit; - lit.push_back(create(&i32, 2)); + lit.push_back(create(Source{}, &i32, 2)); auto* ident = create(mod.RegisterSymbol(""), ""); CaseStatementList body; @@ -118,7 +118,7 @@ TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) { type::I32 i32; CaseSelectorList lit; - lit.push_back(create(&i32, 2)); + lit.push_back(create(Source{}, &i32, 2)); auto* ident = create(mod.RegisterSymbol("ident"), "ident"); @@ -163,7 +163,7 @@ TEST_F(SwitchStatementTest, ToStr) { type::I32 i32; CaseSelectorList lit; - lit.push_back(create(&i32, 2)); + lit.push_back(create(Source{}, &i32, 2)); auto* ident = create(mod.RegisterSymbol("ident"), "ident"); diff --git a/src/ast/uint_literal.cc b/src/ast/uint_literal.cc index f361e4ac70..c30a60822a 100644 --- a/src/ast/uint_literal.cc +++ b/src/ast/uint_literal.cc @@ -22,8 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::UintLiteral); namespace tint { namespace ast { -UintLiteral::UintLiteral(type::Type* type, uint32_t value) - : Base(type), value_(value) {} +UintLiteral::UintLiteral(const Source& source, type::Type* type, uint32_t value) + : Base(source, type), value_(value) {} UintLiteral::~UintLiteral() = default; @@ -36,7 +36,8 @@ std::string UintLiteral::name() const { } UintLiteral* UintLiteral::Clone(CloneContext* ctx) const { - return ctx->mod->create(ctx->Clone(type()), value_); + return ctx->mod->create(ctx->Clone(source()), ctx->Clone(type()), + value_); } } // namespace ast diff --git a/src/ast/uint_literal.h b/src/ast/uint_literal.h index 822fa8d599..9010b6d593 100644 --- a/src/ast/uint_literal.h +++ b/src/ast/uint_literal.h @@ -26,9 +26,10 @@ namespace ast { class UintLiteral : public Castable { public: /// Constructor + /// @param source the input source /// @param type the type of the literal /// @param value the uint literals value - UintLiteral(type::Type* type, uint32_t value); + UintLiteral(const Source& source, type::Type* type, uint32_t value); ~UintLiteral() override; /// @returns the uint literal value diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc index 579fdca468..6090de1915 100644 --- a/src/ast/uint_literal_test.cc +++ b/src/ast/uint_literal_test.cc @@ -29,14 +29,14 @@ using UintLiteralTest = TestHelper; TEST_F(UintLiteralTest, Value) { type::U32 u32; - UintLiteral u{&u32, 47}; + UintLiteral u{Source{}, &u32, 47}; ASSERT_TRUE(u.Is()); EXPECT_EQ(u.value(), 47u); } TEST_F(UintLiteralTest, Is) { type::U32 u32; - UintLiteral u{&u32, 42}; + UintLiteral u{Source{}, &u32, 42}; Literal* l = &u; EXPECT_FALSE(l->Is()); EXPECT_FALSE(l->Is()); @@ -47,9 +47,8 @@ TEST_F(UintLiteralTest, Is) { TEST_F(UintLiteralTest, ToStr) { type::U32 u32; - UintLiteral i{&u32, 42}; - - EXPECT_EQ(i.to_str(), "42"); + UintLiteral u{Source{}, &u32, 42}; + EXPECT_EQ(u.to_str(), "42"); } } // namespace diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index 5a406238b4..337a705404 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -228,28 +228,28 @@ class InspectorHelper { /// @param val scalar value for the literal to contain /// @returns a Literal of the expected type and value ast::Literal* MakeLiteral(ast::type::Type* type, bool* val) { - return create(type, *val); + return create(Source{}, type, *val); } /// @param type AST type of the literal, must resolve to UIntLiteral /// @param val scalar value for the literal to contain /// @returns a Literal of the expected type and value ast::Literal* MakeLiteral(ast::type::Type* type, uint32_t* val) { - return create(type, *val); + return create(Source{}, type, *val); } /// @param type AST type of the literal, must resolve to IntLiteral /// @param val scalar value for the literal to contain /// @returns a Literal of the expected type and value ast::Literal* MakeLiteral(ast::type::Type* type, int32_t* val) { - return create(type, *val); + return create(Source{}, type, *val); } /// @param type AST type of the literal, must resolve to FloattLiteral /// @param val scalar value for the literal to contain /// @returns a Literal of the expected type and value ast::Literal* MakeLiteral(ast::type::Type* type, float* val) { - return create(type, *val); + return create(Source{}, type, *val); } /// @param vec Vector of strings to be searched diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index e5d22bdca2..17b9edeafe 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -695,7 +695,7 @@ void FunctionEmitter::PushTrueGuard(uint32_t end_id) { assert(!statements_stack_.empty()); const auto& top = statements_stack_.back(); - auto* cond = MakeTrue(); + auto* cond = MakeTrue(Source{}); auto* body = create(); AddStatement( create(Source{}, cond, body, ast::ElseStatementList{})); @@ -2142,7 +2142,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) { ast::StorageClass::kFunction, // storage_class parser_impl_.Bool(), // type false, // is_const - MakeTrue(), // constructor + MakeTrue(Source{}), // constructor ast::VariableDecorationList{}); // decorations auto* guard_decl = create(guard_var); AddStatement(guard_decl); @@ -2354,10 +2354,10 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) { const uint32_t value32 = uint32_t(value & 0xFFFFFFFF); if (selector.type->is_unsigned_scalar_or_vector()) { selectors.emplace_back( - create(selector.type, value32)); + create(Source{}, selector.type, value32)); } else { selectors.emplace_back( - create(selector.type, value32)); + create(Source{}, selector.type, value32)); } } } @@ -2572,7 +2572,7 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed( return create( create( ast_module_.RegisterSymbol(flow_guard), flow_guard), - MakeFalse()); + MakeFalse(Source{})); } // For an unconditional branch, the break out to an if-selection @@ -3256,7 +3256,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract( auto make_index = [this](uint32_t literal) { auto* type = create(); return create( - create(type, literal)); + create(Source{}, type, literal)); }; const auto composite = inst.GetSingleWordInOperand(0); @@ -3356,15 +3356,15 @@ TypedExpression FunctionEmitter::MakeCompositeExtract( return current_expr; } -ast::Expression* FunctionEmitter::MakeTrue() const { +ast::Expression* FunctionEmitter::MakeTrue(const Source& source) const { return create( - create(parser_impl_.Bool(), true)); + create(source, parser_impl_.Bool(), true)); } -ast::Expression* FunctionEmitter::MakeFalse() const { +ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const { ast::type::Bool bool_type; return create( - create(parser_impl_.Bool(), false)); + create(source, parser_impl_.Bool(), false)); } TypedExpression FunctionEmitter::MakeVectorShuffle( diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h index 8f8eeba5b2..4b234fbd4b 100644 --- a/src/reader/spirv/function.h +++ b/src/reader/spirv/function.h @@ -698,7 +698,7 @@ class FunctionEmitter { /// return the given value. Otherwise, wrap the value in a TypeConstructor /// expression. /// @param value the value to pass through or convert - /// @reutrns the value as an I32 value. + /// @returns the value as an I32 value. TypedExpression ToI32(TypedExpression value); private: @@ -865,10 +865,10 @@ class FunctionEmitter { void PushTrueGuard(uint32_t end_id); /// @returns a boolean true expression. - ast::Expression* MakeTrue() const; + ast::Expression* MakeTrue(const Source&) const; /// @returns a boolean false expression. - ast::Expression* MakeFalse() const; + ast::Expression* MakeFalse(const Source&) const; /// Creates a new `ast::Node` owned by the Module. When the Module is /// destructed, the `ast::Node` will also be destructed. diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index 9d46f47911..9ef2d3654c 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -1033,7 +1033,7 @@ bool ParserImpl::EmitScalarSpecConstants() { ast_type = ConvertType(inst.type_id()); ast_expr = create(create( - ast_type, inst.opcode() == SpvOpSpecConstantTrue)); + Source{}, ast_type, inst.opcode() == SpvOpSpecConstantTrue)); break; } case SpvOpSpecConstant: { @@ -1042,17 +1042,17 @@ bool ParserImpl::EmitScalarSpecConstants() { if (ast_type->Is()) { ast_expr = create(create( - ast_type, static_cast(literal_value))); + Source{}, ast_type, static_cast(literal_value))); } else if (ast_type->Is()) { ast_expr = create(create( - ast_type, static_cast(literal_value))); + Source{}, ast_type, static_cast(literal_value))); } else if (ast_type->Is()) { float float_value; // Copy the bits so we can read them as a float. std::memcpy(&float_value, &literal_value, sizeof(float_value)); ast_expr = create( - create(ast_type, float_value)); + create(Source{}, ast_type, float_value)); } else { return Fail() << " invalid result type for OpSpecConstant " << inst.PrettyPrint(); @@ -1314,6 +1314,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) { return {}; } + auto source = GetSourceForInst(inst); auto* ast_type = original_ast_type->UnwrapIfNeeded(); // TODO(dneto): Note: NullConstant for int, uint, float map to a regular 0. @@ -1322,25 +1323,25 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) { // See https://bugs.chromium.org/p/tint/issues/detail?id=34 if (ast_type->Is()) { return {ast_type, - create( - create(ast_type, spirv_const->GetU32()))}; + create(create( + source, ast_type, spirv_const->GetU32()))}; } if (ast_type->Is()) { return {ast_type, - create( - create(ast_type, spirv_const->GetS32()))}; + create(create( + source, ast_type, spirv_const->GetS32()))}; } if (ast_type->Is()) { return {ast_type, - create( - create(ast_type, spirv_const->GetFloat()))}; + create(create( + source, ast_type, spirv_const->GetFloat()))}; } if (ast_type->Is()) { const bool value = spirv_const->AsNullConstant() ? false : spirv_const->AsBoolConstant()->value(); return {ast_type, create( - create(ast_type, value))}; + create(source, ast_type, value))}; } auto* spirv_composite_const = spirv_const->AsCompositeConstant(); if (spirv_composite_const != nullptr) { @@ -1394,19 +1395,19 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) { if (type->Is()) { return create( - create(type, false)); + create(Source{}, type, false)); } if (type->Is()) { return create( - create(type, 0u)); + create(Source{}, type, 0u)); } if (type->Is()) { return create( - create(type, 0)); + create(Source{}, type, 0)); } if (type->Is()) { return create( - create(type, 0.0f)); + create(Source{}, type, 0.0f)); } if (const auto* vec_ty = type->As()) { ast::ExpressionList ast_components; diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index b1db835887..8098051cae 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -2678,19 +2678,19 @@ Maybe ParserImpl::const_literal() { auto t = peek(); if (match(Token::Type::kTrue)) { auto* type = module_.create(); - return create(type, true); + return create(Source{}, type, true); } if (match(Token::Type::kFalse)) { auto* type = module_.create(); - return create(type, false); + return create(Source{}, type, false); } if (match(Token::Type::kSintLiteral)) { auto* type = module_.create(); - return create(type, t.to_i32()); + return create(Source{}, type, t.to_i32()); } if (match(Token::Type::kUintLiteral)) { auto* type = module_.create(); - return create(type, t.to_u32()); + return create(Source{}, type, t.to_u32()); } if (match(Token::Type::kFloatLiteral)) { auto p = peek(); @@ -2699,7 +2699,7 @@ Maybe ParserImpl::const_literal() { add_error(p.source(), "float literals must not be suffixed with 'f'"); } auto* type = module_.create(); - return create(type, t.to_f32()); + return create(Source{}, type, t.to_f32()); } return Failure::kNoMatch; } diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc index ba5e9541fe..a5b53f259e 100644 --- a/src/transform/bound_array_accessors.cc +++ b/src/transform/bound_array_accessors.cc @@ -105,13 +105,15 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( } else if (val >= int32_t(size)) { val = int32_t(size) - 1; } - lit = ctx->mod->create(ctx->Clone(sint->type()), val); + lit = ctx->mod->create(ctx->Clone(sint->source()), + ctx->Clone(sint->type()), val); } else if (auto* uint = lit->As()) { uint32_t val = uint->value(); if (val >= size - 1) { val = size - 1; } - lit = ctx->mod->create(ctx->Clone(uint->type()), val); + lit = ctx->mod->create(ctx->Clone(uint->source()), + ctx->Clone(uint->type()), val); } else { diag::Diagnostic err; err.severity = diag::Severity::Error; @@ -132,7 +134,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( params.push_back( ctx->mod->create(u32, cast_expr)); params.push_back(ctx->mod->create( - ctx->mod->create(u32, size - 1))); + ctx->mod->create(Source{}, u32, size - 1))); auto* call_expr = ctx->mod->create( ctx->mod->create( diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc index 1c53e05040..ac07d6fd56 100644 --- a/src/transform/emit_vertex_point_size.cc +++ b/src/transform/emit_vertex_point_size.cc @@ -66,7 +66,7 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) { // Build the AST expression & statement for assigning pointsize one. auto* one = mod->create( - mod->create(f32, 1.0f)); + mod->create(Source{}, f32, 1.0f)); auto* pointsize_ident = mod->create( Source{}, mod->RegisterSymbol(kPointSizeVar), kPointSizeVar); auto* pointsize_assign = diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 05fbae5e8b..8fa3949651 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -353,7 +353,7 @@ void VertexPulling::State::AddVertexPullingPreamble( ast::Expression* VertexPulling::State::GenUint(uint32_t value) { return mod->create( - mod->create(GetU32Type(), value)); + mod->create(Source{}, GetU32Type(), value)); } ast::Expression* VertexPulling::State::CreatePullingPositionIdent() { diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 1749a19368..9386c1dce4 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -128,9 +128,9 @@ TEST_F(TypeDeterminerTest, Stmt_Assign) { ast::type::I32 i32; auto* lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); ast::AssignmentStatement assign(lhs, rhs); @@ -147,15 +147,15 @@ TEST_F(TypeDeterminerTest, Stmt_Case) { ast::type::F32 f32; auto* lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); auto* body = create(); body->append(create(lhs, rhs)); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 3)); + lit.push_back(create(Source{}, &i32, 3)); ast::CaseStatement cse(lit, body); EXPECT_TRUE(td()->DetermineResultType(&cse)); @@ -170,9 +170,9 @@ TEST_F(TypeDeterminerTest, Stmt_Block) { ast::type::F32 f32; auto* lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); ast::BlockStatement block; block.append(create(lhs, rhs)); @@ -189,15 +189,15 @@ TEST_F(TypeDeterminerTest, Stmt_Else) { ast::type::F32 f32; auto* lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); auto* body = create(); body->append(create(lhs, rhs)); ast::ElseStatement stmt(create( - create(&i32, 3)), + create(Source{}, &i32, 3)), body); EXPECT_TRUE(td()->DetermineResultType(&stmt)); @@ -214,29 +214,29 @@ TEST_F(TypeDeterminerTest, Stmt_If) { ast::type::F32 f32; auto* else_lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* else_rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); auto* else_body = create(); else_body->append(create(else_lhs, else_rhs)); - auto* else_stmt = - create(create( - create(&i32, 3)), - else_body); + auto* else_stmt = create( + create( + create(Source{}, &i32, 3)), + else_body); auto* lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); auto* body = create(); body->append(create(lhs, rhs)); ast::IfStatement stmt(Source{}, create( - create(&i32, 3)), + create(Source{}, &i32, 3)), body, ast::ElseStatementList{else_stmt}); EXPECT_TRUE(td()->DetermineResultType(&stmt)); @@ -257,17 +257,17 @@ TEST_F(TypeDeterminerTest, Stmt_Loop) { ast::type::F32 f32; auto* body_lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* body_rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); auto* body = create(); body->append(create(body_lhs, body_rhs)); auto* continuing_lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* continuing_rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); auto* continuing = create(); continuing->append( @@ -290,7 +290,7 @@ TEST_F(TypeDeterminerTest, Stmt_Return) { ast::type::I32 i32; auto* cond = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); ast::ReturnStatement ret(Source{}, cond); @@ -310,21 +310,21 @@ TEST_F(TypeDeterminerTest, Stmt_Switch) { ast::type::F32 f32; auto* lhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); auto* body = create(); body->append(create(lhs, rhs)); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 3)); + lit.push_back(create(Source{}, &i32, 3)); ast::CaseStatementList cases; cases.push_back(create(lit, body)); ast::SwitchStatement stmt(create( - create(&i32, 2)), + create(Source{}, &i32, 2)), cases); EXPECT_TRUE(td()->DetermineResultType(&stmt)) << td()->error(); @@ -400,8 +400,8 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* init = var->constructor(); ast::VariableDeclStatement decl(var); @@ -420,8 +420,8 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* init = var->constructor(); mod->AddGlobalVariable(var); @@ -444,7 +444,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{}); auto* idx = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* var = create(Source{}, // source "my_var", // name @@ -476,7 +476,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { ast::type::Alias aary(mod->RegisterSymbol("myarrty"), "myarrty", &ary); auto* idx = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* var = create(Source{}, // source "my_var", // name @@ -507,7 +507,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{}); auto* idx = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* var = create(Source{}, // source "my_var", // name @@ -536,7 +536,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { ast::type::Matrix mat(&f32, 3, 2); auto* idx = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* var = create(Source{}, // source "my_var", // name @@ -568,9 +568,9 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { ast::type::Matrix mat(&f32, 3, 2); auto* idx1 = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* idx2 = create( - create(&i32, 1)); + create(Source{}, &i32, 1)); auto* var = create(Source{}, // source "my_var", // name @@ -605,7 +605,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { ast::type::Vector vec(&f32, 3); auto* idx = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* var = create(Source{}, // source "my_var", // name @@ -680,7 +680,7 @@ TEST_F(TypeDeterminerTest, Expr_Call_WithParams) { ast::ExpressionList call_params; call_params.push_back(create( - create(&f32, 2.4))); + create(Source{}, &f32, 2.4))); auto* param = call_params.back(); @@ -700,7 +700,7 @@ TEST_F(TypeDeterminerTest, Expr_Call_Intrinsic) { ast::ExpressionList call_params; call_params.push_back(create( - create(&f32, 2.4))); + create(Source{}, &f32, 2.4))); ast::CallExpression call( create(mod->RegisterSymbol("round"), "round"), @@ -730,7 +730,8 @@ TEST_F(TypeDeterminerTest, Expr_Cast) { TEST_F(TypeDeterminerTest, Expr_Constructor_Scalar) { ast::type::F32 f32; - ast::ScalarConstructorExpression s(create(&f32, 1.0f)); + ast::ScalarConstructorExpression s( + create(Source{}, &f32, 1.0f)); EXPECT_TRUE(td()->DetermineResultType(&s)); ASSERT_NE(s.result_type(), nullptr); @@ -743,11 +744,11 @@ TEST_F(TypeDeterminerTest, Expr_Constructor_Type) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::TypeConstructorExpression tc(&vec, vals); @@ -1135,7 +1136,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { body->append(create( create(mod->RegisterSymbol("var"), "var"), create( - create(&f32, 1.f)))); + create(Source{}, &f32, 1.f)))); ast::VariableList params; auto* func = @@ -1365,7 +1366,7 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { auto* foo_ident = create(mod->RegisterSymbol("foo"), "foo"); auto* idx = create( - create(&i32, 0)); + create(Source{}, &i32, 0)); auto* swizzle = create(mod->RegisterSymbol("yx"), "yx"); @@ -2933,7 +2934,7 @@ TEST_P(ImportData_SingleParamTest, Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -2953,11 +2954,11 @@ TEST_P(ImportData_SingleParamTest, Vector) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals)); @@ -2980,7 +2981,7 @@ TEST_P(ImportData_SingleParamTest, Error_Integer) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3012,11 +3013,11 @@ TEST_P(ImportData_SingleParamTest, Error_MultipleParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3062,7 +3063,7 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3082,11 +3083,11 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Vector) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals)); @@ -3109,7 +3110,7 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, -11))); + create(Source{}, &i32, -11))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3129,11 +3130,11 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Vector) { ast::ExpressionList vals; vals.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals)); @@ -3156,7 +3157,7 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3176,11 +3177,11 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Vector) { ast::ExpressionList vals; vals.push_back(create( - create(&u32, 1.0f))); + create(Source{}, &u32, 1.0f))); vals.push_back(create( - create(&u32, 1.0f))); + create(Source{}, &u32, 1.0f))); vals.push_back(create( - create(&u32, 3.0f))); + create(Source{}, &u32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals)); @@ -3203,7 +3204,7 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_Bool) { ast::ExpressionList params; params.push_back(create( - create(&bool_type, false))); + create(Source{}, &bool_type, false))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3235,11 +3236,11 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_MultipleParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3260,7 +3261,7 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error(); @@ -3280,11 +3281,11 @@ TEST_F(TypeDeterminerTest, ImportData_Length_FloatVector) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals)); @@ -3304,7 +3305,7 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Error_Integer) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create(mod->RegisterSymbol("length"), "length"); @@ -3332,11 +3333,11 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Error_MultipleParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create(mod->RegisterSymbol("length"), "length"); @@ -3355,9 +3356,9 @@ TEST_P(ImportData_TwoParamTest, Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3377,19 +3378,19 @@ TEST_P(ImportData_TwoParamTest, Vector) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -3413,9 +3414,9 @@ TEST_P(ImportData_TwoParamTest, Error_Integer) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 2))); + create(Source{}, &i32, 2))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3447,7 +3448,7 @@ TEST_P(ImportData_TwoParamTest, Error_OneParam) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3467,17 +3468,17 @@ TEST_P(ImportData_TwoParamTest, Error_MismatchedParamCount) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec2, vals_1)); @@ -3500,15 +3501,15 @@ TEST_P(ImportData_TwoParamTest, Error_MismatchedParamType) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); params.push_back(create(&vec, vals)); auto* ident = create( @@ -3526,11 +3527,11 @@ TEST_P(ImportData_TwoParamTest, Error_TooManyParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3554,9 +3555,9 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol("distance"), "distance"); @@ -3574,19 +3575,19 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Vector) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -3607,9 +3608,9 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_Integer) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 2))); + create(Source{}, &i32, 2))); auto* ident = create( mod->RegisterSymbol("distance"), "distance"); @@ -3637,7 +3638,7 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_OneParam) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol("distance"), "distance"); @@ -3655,17 +3656,17 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamCount) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec2, vals_1)); @@ -3685,15 +3686,15 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamType) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); params.push_back(create(&vec, vals)); auto* ident = create( @@ -3708,11 +3709,11 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_TooManyParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol("distance"), "distance"); @@ -3729,19 +3730,19 @@ TEST_F(TypeDeterminerTest, ImportData_Cross) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -3763,9 +3764,9 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); auto* ident = create(mod->RegisterSymbol("cross"), "cross"); @@ -3782,19 +3783,19 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_IntType) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_1.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -3826,11 +3827,11 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooFewParams) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -3850,27 +3851,27 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooManyParams) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_3; vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -3894,11 +3895,11 @@ TEST_P(ImportData_ThreeParamTest, Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3918,27 +3919,27 @@ TEST_P(ImportData_ThreeParamTest, Vector) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_3; vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -3963,11 +3964,11 @@ TEST_P(ImportData_ThreeParamTest, Error_Integer) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 2))); + create(Source{}, &i32, 2))); params.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -3999,7 +4000,7 @@ TEST_P(ImportData_ThreeParamTest, Error_OneParam) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4016,9 +4017,9 @@ TEST_P(ImportData_ThreeParamTest, Error_TwoParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4038,25 +4039,25 @@ TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamCount) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_3; vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec2, vals_1)); @@ -4080,17 +4081,17 @@ TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamType) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); params.push_back(create(&vec, vals)); auto* ident = create( @@ -4108,13 +4109,13 @@ TEST_P(ImportData_ThreeParamTest, Error_TooManyParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4143,11 +4144,11 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4167,27 +4168,27 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Vector) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_3; vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -4212,11 +4213,11 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4236,27 +4237,27 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Vector) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_1.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList vals_3; vals_3.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_3.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_3.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -4281,11 +4282,11 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Scalar) { ast::ExpressionList params; params.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); params.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); params.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4305,27 +4306,27 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Vector) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_1.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_1.push_back(create( - create(&u32, 3))); + create(Source{}, &u32, 3))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_2.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_2.push_back(create( - create(&u32, 3))); + create(Source{}, &u32, 3))); ast::ExpressionList vals_3; vals_3.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_3.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_3.push_back(create( - create(&u32, 3))); + create(Source{}, &u32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -4350,11 +4351,11 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_Bool) { ast::ExpressionList params; params.push_back(create( - create(&bool_type, true))); + create(Source{}, &bool_type, true))); params.push_back(create( - create(&bool_type, false))); + create(Source{}, &bool_type, false))); params.push_back(create( - create(&bool_type, true))); + create(Source{}, &bool_type, true))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4386,7 +4387,7 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_OneParam) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4403,9 +4404,9 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TwoParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4425,25 +4426,25 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamCount) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_1.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_2.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals_3; vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals_3.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create(&vec2, vals_1)); @@ -4467,17 +4468,17 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamType) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); ast::ExpressionList params; params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); params.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); params.push_back(create(&vec, vals)); auto* ident = create( @@ -4495,13 +4496,13 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TooManyParams) { ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4526,7 +4527,7 @@ TEST_P(ImportData_Int_SingleParamTest, Scalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4546,11 +4547,11 @@ TEST_P(ImportData_Int_SingleParamTest, Vector) { ast::ExpressionList vals; vals.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals)); @@ -4573,7 +4574,7 @@ TEST_P(ImportData_Int_SingleParamTest, Error_Float) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4605,11 +4606,11 @@ TEST_P(ImportData_Int_SingleParamTest, Error_MultipleParams) { ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4636,9 +4637,9 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Signed) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4657,9 +4658,9 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Unsigned) { ast::ExpressionList params; params.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); params.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4678,9 +4679,9 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Float) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1))); + create(Source{}, &f32, 1))); params.push_back(create( - create(&f32, 1))); + create(Source{}, &f32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4700,19 +4701,19 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Signed) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_1.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -4737,19 +4738,19 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Unsigned) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_1.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_1.push_back(create( - create(&u32, 3))); + create(Source{}, &u32, 3))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_2.push_back(create( - create(&u32, 1))); + create(Source{}, &u32, 1))); vals_2.push_back(create( - create(&u32, 3))); + create(Source{}, &u32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -4774,19 +4775,19 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Float) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&f32, 1))); + create(Source{}, &f32, 1))); vals_1.push_back(create( - create(&f32, 1))); + create(Source{}, &f32, 1))); vals_1.push_back(create( - create(&f32, 3))); + create(Source{}, &f32, 3))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&f32, 1))); + create(Source{}, &f32, 1))); vals_2.push_back(create( - create(&f32, 1))); + create(Source{}, &f32, 1))); vals_2.push_back(create( - create(&f32, 3))); + create(Source{}, &f32, 3))); ast::ExpressionList params; params.push_back(create(&vec, vals_1)); @@ -4810,9 +4811,9 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_Bool) { ast::ExpressionList params; params.push_back(create( - create(&bool_type, true))); + create(Source{}, &bool_type, true))); params.push_back(create( - create(&bool_type, false))); + create(Source{}, &bool_type, false))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4844,7 +4845,7 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_OneParam) { ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); @@ -4864,17 +4865,17 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamCount) { ast::ExpressionList vals_1; vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_1.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); ast::ExpressionList vals_2; vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals_2.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList params; params.push_back(create(&vec2, vals_1)); @@ -4897,15 +4898,15 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamType) { ast::ExpressionList vals; vals.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); vals.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create(&vec, vals)); auto* ident = create( @@ -4923,11 +4924,11 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_TooManyParams) { ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* ident = create( mod->RegisterSymbol(param.name), param.name); diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc index e60af3d3f4..087ba4868f 100644 --- a/src/validator/validator_control_block_test.cc +++ b/src/validator/validator_control_block_test.cc @@ -50,8 +50,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) { &f32, // type false, // is_const create( - create(&f32, 3.14f)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 3.14f)), // constructor + ast::VariableDecorationList{}); // decorations auto* cond = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); @@ -84,13 +84,13 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* cond = create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl; - csl.push_back(create(&i32, 1)); + csl.push_back(create(Source{}, &i32, 1)); ast::CaseStatementList body; body.push_back( create(csl, create())); @@ -122,8 +122,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; auto* cond = @@ -135,7 +135,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) { create(default_csl_1, block_default_1)); ast::CaseSelectorList csl_case_1; - csl_case_1.push_back(create(&i32, 1)); + csl_case_1.push_back(create(Source{}, &i32, 1)); auto* block_case_1 = create(); switch_body.push_back(create(csl_case_1, block_case_1)); @@ -172,15 +172,15 @@ TEST_F(ValidateControlBlockTest, &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; auto* cond = create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl; - csl.push_back(create(&u32, 1)); + csl.push_back(create(Source{}, &u32, 1)); switch_body.push_back(create( Source{Source::Location{12, 34}}, csl, create())); @@ -215,15 +215,15 @@ TEST_F(ValidateControlBlockTest, &u32, // type false, // is_const create( - create(&u32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &u32, 2)), // constructor + ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; auto* cond = create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl; - csl.push_back(create(&i32, -1)); + csl.push_back(create(Source{}, &i32, -1)); switch_body.push_back(create( Source{Source::Location{12, 34}}, csl, create())); @@ -257,21 +257,21 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) { &u32, // type false, // is_const create( - create(&u32, 3)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &u32, 3)), // constructor + ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; auto* cond = create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl_1; - csl_1.push_back(create(&u32, 0)); + csl_1.push_back(create(Source{}, &u32, 0)); switch_body.push_back( create(csl_1, create())); ast::CaseSelectorList csl_2; - csl_2.push_back(create(&u32, 2)); - csl_2.push_back(create(&u32, 2)); + csl_2.push_back(create(Source{}, &u32, 2)); + csl_2.push_back(create(Source{}, &u32, 2)); switch_body.push_back(create( Source{Source::Location{12, 34}}, csl_2, create())); @@ -305,23 +305,23 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; auto* cond = create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl_1; - csl_1.push_back(create(&i32, 10)); + csl_1.push_back(create(Source{}, &i32, 10)); switch_body.push_back( create(csl_1, create())); ast::CaseSelectorList csl_2; - csl_2.push_back(create(&i32, 0)); - csl_2.push_back(create(&i32, 1)); - csl_2.push_back(create(&i32, 2)); - csl_2.push_back(create(&i32, 10)); + csl_2.push_back(create(Source{}, &i32, 0)); + csl_2.push_back(create(Source{}, &i32, 1)); + csl_2.push_back(create(Source{}, &i32, 2)); + csl_2.push_back(create(Source{}, &i32, 10)); switch_body.push_back(create( Source{Source::Location{12, 34}}, csl_2, create())); @@ -353,8 +353,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* cond = create(mod()->RegisterSymbol("a"), "a"); @@ -390,8 +390,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* cond = create(mod()->RegisterSymbol("a"), "a"); @@ -401,7 +401,7 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) { body.push_back(create(Source{Source::Location{12, 34}}, default_csl, block_default)); ast::CaseSelectorList case_csl; - case_csl.push_back(create(&i32, 5)); + case_csl.push_back(create(Source{}, &i32, 5)); auto* block_case = create(); body.push_back(create(case_csl, block_case)); @@ -430,8 +430,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) { &my_int, // type false, // is_const create( - create(&u32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &u32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* cond = create(mod()->RegisterSymbol("a"), "a"); diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index 8440faa8a1..b581bcbd75 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -46,8 +46,8 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations ast::VariableList params; ast::type::Void void_type; @@ -94,8 +94,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations ast::VariableList params; ast::type::Void void_type; @@ -155,7 +155,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { ast::VariableList params; auto* body = create(); auto* return_expr = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); body->append(create(Source{Source::Location{12, 34}}, return_expr)); @@ -179,7 +179,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) { ast::VariableList params; auto* body = create(); auto* return_expr = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); body->append(create(Source{Source::Location{12, 34}}, return_expr)); @@ -205,7 +205,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { ast::VariableList params; auto* body = create(); auto* return_expr = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); body->append(create(Source{}, return_expr)); auto* func = @@ -215,7 +215,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { ast::VariableList params_copy; auto* body_copy = create(); auto* return_expr_copy = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); body_copy->append(create(Source{}, return_expr_copy)); auto* func_copy = create( @@ -274,7 +274,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { auto* body0 = create(); body0->append(create(var)); auto* return_expr = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); body0->append(create(Source{}, return_expr)); auto* func0 = create(Source{}, mod()->RegisterSymbol("func"), @@ -293,7 +293,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) { ast::type::I32 i32; ast::VariableList params; auto* return_expr = create( - create(&i32, 0)); + create(Source{}, &i32, 0)); auto* body = create(); body->append(create(Source{}, return_expr)); diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index 9c5c5d3049..982f4e515a 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -65,7 +65,7 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) { ast::type::I32 i32; auto* lhs = create( - create(&i32, 1)); + create(Source{}, &i32, 1)); auto* rhs = create(mod()->RegisterSymbol("my_var"), "my_var"); ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs); @@ -83,7 +83,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) { auto* lhs = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b"); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* assign = create( Source{Source::Location{12, 34}}, lhs, rhs); @@ -101,7 +101,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) { auto* lhs = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b"); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* body = create(); body->append(create( @@ -123,13 +123,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs); td()->RegisterVariableForTesting(var); @@ -154,13 +154,13 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs); td()->RegisterVariableForTesting(var); @@ -188,13 +188,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* body = create(); body->append(create(var)); @@ -223,12 +223,12 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&f32, 2.3f)); + create(Source{}, &f32, 2.3f)); ast::BlockStatement block; block.append(create(var)); @@ -324,14 +324,14 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { &f32, // type false, // is_const create( - create(&f32, 2.1)), // constructor - ast::VariableDecorationList{})); // decorations + create(Source{}, &f32, 2.1)), // constructor + ast::VariableDecorationList{})); // decorations auto* lhs = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"), "not_global_var"); auto* rhs = create( - create(&f32, 3.14f)); + create(Source{}, &f32, 3.14f)); ast::VariableList params; auto* body = create(); @@ -363,13 +363,13 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { &f32, // type false, // is_const create( - create(&f32, 2.1)), // constructor - ast::VariableDecorationList{})); // decorations + create(Source{}, &f32, 2.1)), // constructor + ast::VariableDecorationList{})); // decorations auto* lhs = create( mod()->RegisterSymbol("global_var"), "global_var"); auto* rhs = create( - create(&f32, 3.14f)); + create(Source{}, &f32, 3.14f)); ast::VariableList params; @@ -402,19 +402,19 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) { &f32, // type false, // is_const create( - create(&f32, 2.0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.0)), // constructor + ast::VariableDecorationList{}); // decorations ast::type::Bool bool_type; auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* body = create(); body->append(create(var)); auto* lhs = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&f32, 3.14f)); + create(Source{}, &f32, 3.14f)); auto* outer_body = create(); outer_body->append( @@ -442,17 +442,17 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { &f32, // type false, // is_const create( - create(&f32, 2.0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.0)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&f32, 3.14f)); + create(Source{}, &f32, 3.14f)); ast::type::Bool bool_type; auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* body = create(); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); @@ -479,8 +479,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) { &f32, // type false, // is_const create( - create(&f32, 0.1)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 0.1)), // constructor + ast::VariableDecorationList{}); // decorations mod()->AddGlobalVariable(var0); auto* var1 = create( @@ -490,8 +490,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) { &f32, // type false, // is_const create( - create(&i32, 0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 0)), // constructor + ast::VariableDecorationList{}); // decorations mod()->AddGlobalVariable(var1); EXPECT_TRUE(v()->ValidateGlobalVariables(mod()->global_variables())) @@ -510,8 +510,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) { &f32, // type false, // is_const create( - create(&f32, 0.1)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 0.1)), // constructor + ast::VariableDecorationList{}); // decorations mod()->AddGlobalVariable(var0); auto* var1 = create( @@ -521,8 +521,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) { &f32, // type false, // is_const create( - create(&i32, 0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 0)), // constructor + ast::VariableDecorationList{}); // decorations mod()->AddGlobalVariable(var1); EXPECT_FALSE(v()->ValidateGlobalVariables(mod()->global_variables())); @@ -543,13 +543,13 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) { &i32, // type true, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* body = create(); body->append(create(var)); @@ -580,8 +580,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { &f32, // type false, // is_const create( - create(&f32, 2.1)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.1)), // constructor + ast::VariableDecorationList{}); // decorations mod()->AddGlobalVariable(global_var); auto* var = create( @@ -591,8 +591,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { &f32, // type false, // is_const create( - create(&f32, 2.0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.0)), // constructor + ast::VariableDecorationList{}); // decorations ast::VariableList params; auto* body = create(); body->append(create( @@ -624,8 +624,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) { &i32, // type false, // is_const create( - create(&i32, 2)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &i32, 2)), // constructor + ast::VariableDecorationList{}); // decorations auto* var_a_float = create( Source{}, // source @@ -634,8 +634,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) { &f32, // type false, // is_const create( - create(&f32, 0.1)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 0.1)), // constructor + ast::VariableDecorationList{}); // decorations ast::VariableList params; auto* body = create(); @@ -667,12 +667,12 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { &f32, // type false, // is_const create( - create(&f32, 2.0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.0)), // constructor + ast::VariableDecorationList{}); // decorations ast::type::Bool bool_type; auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* body = create(); body->append(create(var)); @@ -683,8 +683,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { &f32, // type false, // is_const create( - create(&f32, 3.14)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 3.14)), // constructor + ast::VariableDecorationList{}); // decorations auto* outer_body = create(); outer_body->append( @@ -711,8 +711,8 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { &f32, // type false, // is_const create( - create(&f32, 3.14)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 3.14)), // constructor + ast::VariableDecorationList{}); // decorations auto* var = create( Source{}, // source @@ -721,12 +721,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { &f32, // type false, // is_const create( - create(&f32, 2.0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.0)), // constructor + ast::VariableDecorationList{}); // decorations ast::type::Bool bool_type; auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* body = create(); body->append(create( Source{Source::Location{12, 34}}, var)); @@ -753,8 +753,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { &f32, // type false, // is_const create( - create(&f32, 2.0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.0)), // constructor + ast::VariableDecorationList{}); // decorations auto* var1 = create( Source{}, // source @@ -763,8 +763,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { &void_type, // type false, // is_const create( - create(&f32, 1.0)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 1.0)), // constructor + ast::VariableDecorationList{}); // decorations ast::VariableList params0; auto* body0 = create(); @@ -813,7 +813,7 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) { auto* lhs = create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); auto* body = create(); body->append(create(var)); diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index fa49a4b0e0..209f94a95e 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -779,7 +779,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, auto emit_vector_appended_with_i32_zero = [&](tint::ast::Expression* vector) { auto* i32 = module_->create(); - ast::SintLiteral zero_lit(i32, 0); + ast::SintLiteral zero_lit(Source{}, i32, 0); ast::ScalarConstructorExpression zero(&zero_lit); zero.set_result_type(i32); return AppendVector(vector, &zero, diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc index ddf140c9ce..d0a6885601 100644 --- a/src/writer/hlsl/generator_impl_array_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc @@ -31,7 +31,7 @@ using HlslGeneratorImplTest_Expression = TestHelper; TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) { ast::type::I32 i32; - auto* lit = create(&i32, 5); + auto* lit = create(Source{}, &i32, 5); auto* idx = create(lit); auto* ary = create(mod.RegisterSymbol("ary"), "ary"); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index 106d27954c..5ab8160fa3 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -193,15 +193,15 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), }); auto* rhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs); @@ -217,15 +217,15 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) { ast::type::Vector vec3(&f32, 3); auto* lhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* rhs = create(&vec3, vals); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs); @@ -252,7 +252,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) { auto* lhs = create(mod.RegisterSymbol("mat"), "mat"); auto* rhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); td.RegisterVariableForTesting(var); @@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) { nullptr, // constructor ast::VariableDecorationList{}); // decorations auto* lhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); auto* rhs = create(mod.RegisterSymbol("mat"), "mat"); @@ -307,11 +307,11 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* rhs = create(&vec3, vals); td.RegisterVariableForTesting(var); @@ -339,11 +339,11 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* lhs = create(&vec3, vals); auto* rhs = @@ -462,13 +462,13 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { auto* body = create(); body->append(create( Source{}, create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); auto* else_stmt = create(body); body = create(); body->append(create( Source{}, create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* else_if_stmt = create( create( ast::BinaryOp::kLogicalOr, @@ -479,7 +479,7 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { body = create(); body->append(create( Source{}, create( - create(&i32, 1)))); + create(Source{}, &i32, 1)))); ast::IfStatement expr( Source{}, diff --git a/src/writer/hlsl/generator_impl_case_test.cc b/src/writer/hlsl/generator_impl_case_test.cc index 0efe976724..c6117bb2ca 100644 --- a/src/writer/hlsl/generator_impl_case_test.cc +++ b/src/writer/hlsl/generator_impl_case_test.cc @@ -37,7 +37,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(Source{}, &i32, 5)); ast::CaseStatement c(lit, body); gen.increment_indent(); @@ -53,7 +53,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) { ast::type::I32 i32; ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(Source{}, &i32, 5)); ast::CaseStatement c(lit, create()); gen.increment_indent(); @@ -72,7 +72,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(Source{}, &i32, 5)); ast::CaseStatement c(lit, body); gen.increment_indent(); @@ -91,8 +91,8 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); - lit.push_back(create(&i32, 6)); + lit.push_back(create(Source{}, &i32, 5)); + lit.push_back(create(Source{}, &i32, 6)); ast::CaseStatement c(lit, body); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_constructor_test.cc b/src/writer/hlsl/generator_impl_constructor_test.cc index 3bbdbc7d16..0cb4ba0373 100644 --- a/src/writer/hlsl/generator_impl_constructor_test.cc +++ b/src/writer/hlsl/generator_impl_constructor_test.cc @@ -37,7 +37,7 @@ using HlslGeneratorImplTest_Constructor = TestHelper; TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) { ast::type::Bool bool_type; - auto* lit = create(&bool_type, false); + auto* lit = create(Source{}, &bool_type, false); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) { ast::type::I32 i32; - auto* lit = create(&i32, -12345); + auto* lit = create(Source{}, &i32, -12345); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -55,7 +55,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) { ast::type::U32 u32; - auto* lit = create(&u32, 56779); + auto* lit = create(Source{}, &u32, 56779); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -65,8 +65,8 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) { ast::type::F32 f32; // Use a number close to 1<<30 but whose decimal representation ends in 0. - auto* lit = - create(&f32, static_cast((1 << 30) - 4)); + auto* lit = create(Source{}, &f32, + static_cast((1 << 30) - 4)); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -76,7 +76,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) { ast::type::F32 f32; - auto* lit = create(&f32, -1.2e-5); + auto* lit = create(Source{}, &f32, -1.2e-5); ast::ExpressionList values; values.push_back(create(lit)); @@ -89,7 +89,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) { ast::type::Bool b; - auto* lit = create(&b, true); + auto* lit = create(Source{}, &b, true); ast::ExpressionList values; values.push_back(create(lit)); @@ -102,7 +102,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) { ast::type::I32 i32; - auto* lit = create(&i32, -12345); + auto* lit = create(Source{}, &i32, -12345); ast::ExpressionList values; values.push_back(create(lit)); @@ -115,7 +115,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) { ast::type::U32 u32; - auto* lit = create(&u32, 12345); + auto* lit = create(Source{}, &u32, 12345); ast::ExpressionList values; values.push_back(create(lit)); @@ -129,9 +129,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) { ast::type::F32 f32; ast::type::Vector vec(&f32, 3); - auto* lit1 = create(&f32, 1.f); - auto* lit2 = create(&f32, 2.f); - auto* lit3 = create(&f32, 3.f); + auto* lit1 = create(Source{}, &f32, 1.f); + auto* lit2 = create(Source{}, &f32, 2.f); + auto* lit3 = create(Source{}, &f32, 3.f); ast::ExpressionList values; values.push_back(create(lit1)); values.push_back(create(lit2)); @@ -165,12 +165,12 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) { ast::ExpressionList mat_values; for (size_t i = 0; i < 2; i++) { - auto* lit1 = - create(&f32, static_cast(1 + (i * 2))); - auto* lit2 = - create(&f32, static_cast(2 + (i * 2))); - auto* lit3 = - create(&f32, static_cast(3 + (i * 2))); + auto* lit1 = create(Source{}, &f32, + static_cast(1 + (i * 2))); + auto* lit2 = create(Source{}, &f32, + static_cast(2 + (i * 2))); + auto* lit3 = create(Source{}, &f32, + static_cast(3 + (i * 2))); ast::ExpressionList values; values.push_back(create(lit1)); @@ -198,12 +198,12 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) { ast::ExpressionList ary_values; for (size_t i = 0; i < 3; i++) { - auto* lit1 = - create(&f32, static_cast(1 + (i * 3))); - auto* lit2 = - create(&f32, static_cast(2 + (i * 3))); - auto* lit3 = - create(&f32, static_cast(3 + (i * 3))); + auto* lit1 = create(Source{}, &f32, + static_cast(1 + (i * 3))); + auto* lit2 = create(Source{}, &f32, + static_cast(2 + (i * 3))); + auto* lit3 = create(Source{}, &f32, + static_cast(3 + (i * 3))); ast::ExpressionList values; values.push_back(create(lit1)); diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index f05f0f76d0..ff3bd55fea 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -606,7 +606,7 @@ TEST_F(HlslGeneratorImplTest_Function, "coord"), create(mod.RegisterSymbol("b"), "b")), create( - create(&f32, 2.0f))); + create(Source{}, &f32, 2.0f))); auto* body = create(); body->append(assign); @@ -710,7 +710,7 @@ TEST_F( ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); body = create(); body->append(create( @@ -798,7 +798,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); body = create(); body->append(create( @@ -900,7 +900,7 @@ TEST_F( ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); body = create(); body->append(create( @@ -990,7 +990,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); auto* var = create(Source{}, // source @@ -1082,7 +1082,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); auto* var = create(Source{}, // source @@ -1150,18 +1150,19 @@ TEST_F(HlslGeneratorImplTest_Function, body->append(create( create(mod.RegisterSymbol("bar"), "bar"), create( - create(&f32, 1.0f)))); + create(Source{}, &f32, 1.0f)))); auto* list = create(); list->append(create(Source{})); body->append(create( Source{}, - create(ast::BinaryOp::kEqual, - create( - create(&i32, 1)), - create( - create(&i32, 1))), + create( + ast::BinaryOp::kEqual, + create( + create(Source{}, &i32, 1)), + create( + create(Source{}, &i32, 1))), list, ast::ElseStatementList{})); body->append(create(Source{})); diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc index de3e4b5387..47b1ec2067 100644 --- a/src/writer/hlsl/generator_impl_import_test.cc +++ b/src/writer/hlsl/generator_impl_import_test.cc @@ -54,7 +54,7 @@ TEST_P(HlslImportData_SingleParamTest, FloatScalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod.RegisterSymbol(param.name), param.name); @@ -100,7 +100,7 @@ TEST_P(HlslImportData_SingleIntParamTest, IntScalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), @@ -122,9 +122,9 @@ TEST_P(HlslImportData_DualParamTest, FloatScalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 2.f))); + create(Source{}, &f32, 2.f))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), @@ -155,21 +155,21 @@ TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) { params.push_back(create( &vec, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 2.f)), + create(Source{}, &f32, 2.f)), create( - create(&f32, 3.f)), + create(Source{}, &f32, 3.f)), })); params.push_back(create( &vec, ast::ExpressionList{ create( - create(&f32, 4.f)), + create(Source{}, &f32, 4.f)), create( - create(&f32, 5.f)), + create(Source{}, &f32, 5.f)), create( - create(&f32, 6.f)), + create(Source{}, &f32, 6.f)), })); ast::CallExpression expr(create( @@ -194,9 +194,9 @@ TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 2))); + create(Source{}, &i32, 2))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), @@ -219,11 +219,11 @@ TEST_P(HlslImportData_TripleParamTest, FloatScalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 2.f))); + create(Source{}, &f32, 2.f))); params.push_back(create( - create(&f32, 3.f))); + create(Source{}, &f32, 3.f))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), @@ -253,11 +253,11 @@ TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 2))); + create(Source{}, &i32, 2))); params.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc index b06f1bc81b..25b4a63fda 100644 --- a/src/writer/hlsl/generator_impl_loop_test.cc +++ b/src/writer/hlsl/generator_impl_loop_test.cc @@ -153,8 +153,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { &f32, // type false, // is_const create( - create(&f32, 2.4)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.4)), // constructor + ast::VariableDecorationList{}); // decorations auto* body = create(); body->append(create(var)); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index 8bbc18ee6d..055b6795b9 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -519,9 +519,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, "data"), create(mod.RegisterSymbol("a"), "a")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create( - create(&i32, 1))); + create(Source{}, &i32, 1))); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -573,7 +573,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(mod.RegisterSymbol("data"), "data"), create(mod.RegisterSymbol("a"), "a")), create( - create(&i32, 2))); + create(Source{}, &i32, 2))); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -629,11 +629,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create( ast::BinaryOp::kAdd, create( - create(&i32, 2)), + create(Source{}, &i32, 2)), create( - create(&i32, 4))), + create(Source{}, &i32, 4))), create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -692,7 +692,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(mod.RegisterSymbol("data"), "data"), create(mod.RegisterSymbol("b"), "b")); auto* rhs = create( - create(&f32, 2.0f)); + create(Source{}, &f32, 2.0f)); ast::AssignmentStatement assign(lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)); @@ -747,9 +747,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(mod.RegisterSymbol("data"), "data"), create(mod.RegisterSymbol("a"), "a")), create( - create(&i32, 2))); + create(Source{}, &i32, 2))); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); ast::AssignmentStatement assign(lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error(); @@ -804,7 +804,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(mod.RegisterSymbol("data"), "data"), create(mod.RegisterSymbol("a"), "a")); auto* rhs = create( - create(&i32, 2)); + create(Source{}, &i32, 2)); ast::AssignmentStatement assign(lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)); @@ -910,9 +910,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - auto* lit1 = create(&f32, 1.f); - auto* lit2 = create(&f32, 2.f); - auto* lit3 = create(&f32, 3.f); + auto* lit1 = create(Source{}, &f32, 1.f); + auto* lit2 = create(Source{}, &f32, 2.f); + auto* lit3 = create(Source{}, &f32, 3.f); ast::ExpressionList values; values.push_back(create(lit1)); values.push_back(create(lit2)); @@ -1001,7 +1001,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, "data"), create(mod.RegisterSymbol("c"), "c")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod.RegisterSymbol("b"), "b")); ASSERT_TRUE(td.DetermineResultType(&expr)); @@ -1081,7 +1081,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(mod.RegisterSymbol("c"), "c")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod.RegisterSymbol("b"), "b")), create(mod.RegisterSymbol("xy"), "xy")); @@ -1161,7 +1161,7 @@ TEST_F( create(mod.RegisterSymbol("c"), "c")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod.RegisterSymbol("b"), "b")), create(mod.RegisterSymbol("g"), "g")); @@ -1240,10 +1240,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(mod.RegisterSymbol("c"), "c")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod.RegisterSymbol("b"), "b")), create( - create(&i32, 1))); + create(Source{}, &i32, 1))); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1318,12 +1318,12 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, "data"), create(mod.RegisterSymbol("c"), "c")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod.RegisterSymbol("b"), "b")); - auto* lit1 = create(&f32, 1.f); - auto* lit2 = create(&f32, 2.f); - auto* lit3 = create(&f32, 3.f); + auto* lit1 = create(Source{}, &f32, 1.f); + auto* lit2 = create(Source{}, &f32, 2.f); + auto* lit3 = create(Source{}, &f32, 3.f); ast::ExpressionList values; values.push_back(create(lit1)); values.push_back(create(lit2)); @@ -1410,12 +1410,12 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(mod.RegisterSymbol("c"), "c")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod.RegisterSymbol("b"), "b")), create(mod.RegisterSymbol("y"), "y")); auto* rhs = create( - create(&i32, 1.f)); + create(Source{}, &i32, 1.f)); ast::AssignmentStatement assign(lhs, rhs); diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc index c98882f478..cae5bd3a1d 100644 --- a/src/writer/hlsl/generator_impl_module_constant_test.cc +++ b/src/writer/hlsl/generator_impl_module_constant_test.cc @@ -38,11 +38,11 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) { ast::ExpressionList exprs; exprs.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); exprs.push_back(create( - create(&f32, 2.0f))); + create(Source{}, &f32, 2.0f))); exprs.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* var = create( Source{}, // source @@ -67,7 +67,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) { &f32, // type true, // is_const create( - create(&f32, 3.0f)), // constructor + create(Source{}, &f32, 3.0f)), // constructor ast::VariableDecorationList{ // decorations create(23, Source{}), diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc index 7e8ef38a75..9456dfffec 100644 --- a/src/writer/hlsl/generator_impl_switch_test.cc +++ b/src/writer/hlsl/generator_impl_switch_test.cc @@ -37,7 +37,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { ast::type::I32 i32; ast::CaseSelectorList case_val; - case_val.push_back(create(&i32, 5)); + case_val.push_back(create(Source{}, &i32, 5)); auto* case_body = create(); case_body->append(create()); diff --git a/src/writer/msl/generator_impl_array_accessor_test.cc b/src/writer/msl/generator_impl_array_accessor_test.cc index 156077358c..41da25934a 100644 --- a/src/writer/msl/generator_impl_array_accessor_test.cc +++ b/src/writer/msl/generator_impl_array_accessor_test.cc @@ -33,7 +33,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_ArrayAccessor) { ast::type::I32 i32; - auto* lit = create(&i32, 5); + auto* lit = create(Source{}, &i32, 5); auto* idx = create(lit); auto* ary = create(mod.RegisterSymbol("ary"), "ary"); diff --git a/src/writer/msl/generator_impl_case_test.cc b/src/writer/msl/generator_impl_case_test.cc index e8e2244733..5740d2add4 100644 --- a/src/writer/msl/generator_impl_case_test.cc +++ b/src/writer/msl/generator_impl_case_test.cc @@ -39,7 +39,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(Source{}, &i32, 5)); ast::CaseStatement c(lit, body); gen.increment_indent(); @@ -55,7 +55,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) { ast::type::I32 i32; ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(Source{}, &i32, 5)); ast::CaseStatement c(lit, create()); gen.increment_indent(); @@ -74,7 +74,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(Source{}, &i32, 5)); ast::CaseStatement c(lit, body); gen.increment_indent(); @@ -93,8 +93,8 @@ TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); - lit.push_back(create(&i32, 6)); + lit.push_back(create(Source{}, &i32, 5)); + lit.push_back(create(Source{}, &i32, 6)); ast::CaseStatement c(lit, body); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc index cd83117405..0f50308ecc 100644 --- a/src/writer/msl/generator_impl_constructor_test.cc +++ b/src/writer/msl/generator_impl_constructor_test.cc @@ -39,7 +39,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) { ast::type::Bool bool_type; - auto* lit = create(&bool_type, false); + auto* lit = create(Source{}, &bool_type, false); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -48,7 +48,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) { TEST_F(MslGeneratorImplTest, EmitConstructor_Int) { ast::type::I32 i32; - auto* lit = create(&i32, -12345); + auto* lit = create(Source{}, &i32, -12345); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -57,7 +57,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Int) { TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) { ast::type::U32 u32; - auto* lit = create(&u32, 56779); + auto* lit = create(Source{}, &u32, 56779); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -67,8 +67,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) { TEST_F(MslGeneratorImplTest, EmitConstructor_Float) { ast::type::F32 f32; // Use a number close to 1<<30 but whose decimal representation ends in 0. - auto* lit = - create(&f32, static_cast((1 << 30) - 4)); + auto* lit = create(Source{}, &f32, + static_cast((1 << 30) - 4)); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -78,7 +78,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Float) { TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) { ast::type::F32 f32; - auto* lit = create(&f32, -1.2e-5); + auto* lit = create(Source{}, &f32, -1.2e-5); ast::ExpressionList values; values.push_back(create(lit)); @@ -91,7 +91,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) { TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) { ast::type::Bool b; - auto* lit = create(&b, true); + auto* lit = create(Source{}, &b, true); ast::ExpressionList values; values.push_back(create(lit)); @@ -104,7 +104,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) { TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) { ast::type::I32 i32; - auto* lit = create(&i32, -12345); + auto* lit = create(Source{}, &i32, -12345); ast::ExpressionList values; values.push_back(create(lit)); @@ -117,7 +117,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) { TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Uint) { ast::type::U32 u32; - auto* lit = create(&u32, 12345); + auto* lit = create(Source{}, &u32, 12345); ast::ExpressionList values; values.push_back(create(lit)); @@ -131,9 +131,9 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) { ast::type::F32 f32; ast::type::Vector vec(&f32, 3); - auto* lit1 = create(&f32, 1.f); - auto* lit2 = create(&f32, 2.f); - auto* lit3 = create(&f32, 3.f); + auto* lit1 = create(Source{}, &f32, 1.f); + auto* lit2 = create(Source{}, &f32, 2.f); + auto* lit3 = create(Source{}, &f32, 3.f); ast::ExpressionList values; values.push_back(create(lit1)); values.push_back(create(lit2)); @@ -167,12 +167,12 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) { ast::ExpressionList mat_values; for (size_t i = 0; i < 2; i++) { - auto* lit1 = - create(&f32, static_cast(1 + (i * 2))); - auto* lit2 = - create(&f32, static_cast(2 + (i * 2))); - auto* lit3 = - create(&f32, static_cast(3 + (i * 2))); + auto* lit1 = create(Source{}, &f32, + static_cast(1 + (i * 2))); + auto* lit2 = create(Source{}, &f32, + static_cast(2 + (i * 2))); + auto* lit3 = create(Source{}, &f32, + static_cast(3 + (i * 2))); ast::ExpressionList values; values.push_back(create(lit1)); @@ -199,12 +199,12 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) { ast::ExpressionList ary_values; for (size_t i = 0; i < 3; i++) { - auto* lit1 = - create(&f32, static_cast(1 + (i * 3))); - auto* lit2 = - create(&f32, static_cast(2 + (i * 3))); - auto* lit3 = - create(&f32, static_cast(3 + (i * 3))); + auto* lit1 = create(Source{}, &f32, + static_cast(1 + (i * 3))); + auto* lit2 = create(Source{}, &f32, + static_cast(2 + (i * 3))); + auto* lit3 = create(Source{}, &f32, + static_cast(3 + (i * 3))); ast::ExpressionList values; values.push_back(create(lit1)); diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 680441faae..d7cd5f1207 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -594,7 +594,7 @@ TEST_F( ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); body = create(); body->append(create( @@ -685,7 +685,7 @@ TEST_F(MslGeneratorImplTest, ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); body = create(); body->append(create( @@ -791,7 +791,7 @@ TEST_F( ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); body = create(); body->append(create( @@ -879,7 +879,7 @@ TEST_F(MslGeneratorImplTest, ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); auto* var = create(Source{}, // source @@ -985,7 +985,7 @@ TEST_F(MslGeneratorImplTest, ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); auto* var = create(Source{}, // source @@ -1097,7 +1097,7 @@ TEST_F(MslGeneratorImplTest, ast::ExpressionList expr; expr.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); auto* var = create(Source{}, // source @@ -1172,18 +1172,19 @@ TEST_F(MslGeneratorImplTest, body->append(create( create(mod.RegisterSymbol("bar"), "bar"), create( - create(&f32, 1.0f)))); + create(Source{}, &f32, 1.0f)))); auto* list = create(); list->append(create(Source{})); body->append(create( Source{}, - create(ast::BinaryOp::kEqual, - create( - create(&i32, 1)), - create( - create(&i32, 1))), + create( + ast::BinaryOp::kEqual, + create( + create(Source{}, &i32, 1)), + create( + create(Source{}, &i32, 1))), list, ast::ElseStatementList{})); body->append(create(Source{})); diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc index d543348bb3..1d654c2b23 100644 --- a/src/writer/msl/generator_impl_import_test.cc +++ b/src/writer/msl/generator_impl_import_test.cc @@ -55,7 +55,7 @@ TEST_P(MslImportData_SingleParamTest, FloatScalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* ident = create( mod.RegisterSymbol(param.name), param.name); @@ -99,7 +99,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_IntScalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); ast::CallExpression expr( create(mod.RegisterSymbol("abs"), "abs"), @@ -119,9 +119,9 @@ TEST_P(MslImportData_DualParamTest, FloatScalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 2.f))); + create(Source{}, &f32, 2.f))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), @@ -155,21 +155,21 @@ TEST_P(MslImportData_DualParam_VectorTest, FloatVector) { params.push_back(create( &vec, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 2.f)), + create(Source{}, &f32, 2.f)), create( - create(&f32, 3.f)), + create(Source{}, &f32, 3.f)), })); params.push_back(create( &vec, ast::ExpressionList{ create( - create(&f32, 4.f)), + create(Source{}, &f32, 4.f)), create( - create(&f32, 5.f)), + create(Source{}, &f32, 5.f)), create( - create(&f32, 6.f)), + create(Source{}, &f32, 6.f)), })); ast::CallExpression expr(create( @@ -194,9 +194,9 @@ TEST_P(MslImportData_DualParam_Int_Test, IntScalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 2))); + create(Source{}, &i32, 2))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), @@ -219,11 +219,11 @@ TEST_P(MslImportData_TripleParamTest, FloatScalar) { ast::ExpressionList params; params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); params.push_back(create( - create(&f32, 2.f))); + create(Source{}, &f32, 2.f))); params.push_back(create( - create(&f32, 3.f))); + create(Source{}, &f32, 3.f))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), @@ -251,11 +251,11 @@ TEST_P(MslImportData_TripleParam_Int_Test, IntScalar) { ast::ExpressionList params; params.push_back(create( - create(&i32, 1))); + create(Source{}, &i32, 1))); params.push_back(create( - create(&i32, 2))); + create(Source{}, &i32, 2))); params.push_back(create( - create(&i32, 3))); + create(Source{}, &i32, 3))); ast::CallExpression expr(create( mod.RegisterSymbol(param.name), param.name), diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc index b6c91fdf9d..004af071a6 100644 --- a/src/writer/msl/generator_impl_loop_test.cc +++ b/src/writer/msl/generator_impl_loop_test.cc @@ -158,8 +158,8 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) { &f32, // type false, // is_const create( - create(&f32, 2.4)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &f32, 2.4)), // constructor + ast::VariableDecorationList{}); // decorations auto* body = create(); body->append(create(var)); diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc index efe5ee0691..980beeae82 100644 --- a/src/writer/msl/generator_impl_module_constant_test.cc +++ b/src/writer/msl/generator_impl_module_constant_test.cc @@ -40,11 +40,11 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) { ast::ExpressionList exprs; exprs.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); exprs.push_back(create( - create(&f32, 2.0f))); + create(Source{}, &f32, 2.0f))); exprs.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* var = create( Source{}, // source @@ -69,7 +69,7 @@ TEST_F(MslGeneratorImplTest, Emit_SpecConstant) { &f32, // type true, // is_const create( - create(&f32, 3.0f)), // constructor + create(Source{}, &f32, 3.0f)), // constructor ast::VariableDecorationList{ // decorations create(23, Source{}), diff --git a/src/writer/msl/generator_impl_switch_test.cc b/src/writer/msl/generator_impl_switch_test.cc index fd69599ce3..06173747c3 100644 --- a/src/writer/msl/generator_impl_switch_test.cc +++ b/src/writer/msl/generator_impl_switch_test.cc @@ -39,7 +39,7 @@ TEST_F(MslGeneratorImplTest, Emit_Switch) { ast::type::I32 i32; ast::CaseSelectorList case_val; - case_val.push_back(create(&i32, 5)); + case_val.push_back(create(Source{}, &i32, 5)); auto* case_body = create(); case_body->append(create()); diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 244844e60e..2143b579af 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -376,7 +376,7 @@ void Builder::GenerateLabel(uint32_t id) { uint32_t Builder::GenerateU32Literal(uint32_t val) { ast::type::U32 u32; - ast::SintLiteral lit(&u32, val); + ast::SintLiteral lit(Source{}, &u32, val); return GenerateLiteralIfNeeded(nullptr, &lit); } @@ -640,7 +640,7 @@ bool Builder::GenerateFunctionVariable(ast::Variable* var) { // TODO(dsinclair) We could detect if the constructor is fully const and emit // an initializer value for the variable instead of doing the OpLoad. - ast::NullLiteral nl(var->type()->UnwrapPtrIfNeeded()); + ast::NullLiteral nl(Source{}, var->type()->UnwrapPtrIfNeeded()); auto null_id = GenerateLiteralIfNeeded(var, &nl); if (null_id == 0) { return 0; @@ -741,16 +741,16 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { // then WGSL requires an initializer. if (var->HasConstantIdDecoration()) { if (type->Is()) { - ast::FloatLiteral l(type, 0.0f); + ast::FloatLiteral l(Source{}, type, 0.0f); init_id = GenerateLiteralIfNeeded(var, &l); } else if (type->Is()) { - ast::UintLiteral l(type, 0); + ast::UintLiteral l(Source{}, type, 0); init_id = GenerateLiteralIfNeeded(var, &l); } else if (type->Is()) { - ast::SintLiteral l(type, 0); + ast::SintLiteral l(Source{}, type, 0); init_id = GenerateLiteralIfNeeded(var, &l); } else if (type->Is()) { - ast::BoolLiteral l(type, false); + ast::BoolLiteral l(Source{}, type, false); init_id = GenerateLiteralIfNeeded(var, &l); } else { error_ = "invalid type for constant_id, must be scalar"; @@ -763,7 +763,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { } else if (var->storage_class() == ast::StorageClass::kPrivate || var->storage_class() == ast::StorageClass::kNone || var->storage_class() == ast::StorageClass::kOutput) { - ast::NullLiteral nl(type); + ast::NullLiteral nl(Source{}, type); init_id = GenerateLiteralIfNeeded(var, &nl); if (init_id == 0) { return 0; @@ -1015,7 +1015,7 @@ uint32_t Builder::GenerateAccessorExpression(ast::Expression* expr) { auto ary_result = result_op(); - ast::NullLiteral nl(ary_res_type); + ast::NullLiteral nl(Source{}, ary_res_type); auto init = GenerateLiteralIfNeeded(nullptr, &nl); // If we're access chaining into an array then we must be in a function @@ -1220,7 +1220,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( // Generate the zero initializer if there are no values provided. if (values.empty()) { - ast::NullLiteral nl(init->type()->UnwrapPtrIfNeeded()); + ast::NullLiteral nl(Source{}, init->type()->UnwrapPtrIfNeeded()); return GenerateLiteralIfNeeded(nullptr, &nl); } @@ -2053,7 +2053,7 @@ void Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident, spirv_params.emplace_back(gen_param(pidx.depth_ref)); ast::type::F32 f32; - ast::FloatLiteral float_0(&f32, 0.0); + ast::FloatLiteral float_0(Source{}, &f32, 0.0); image_operands.emplace_back(ImageOperand{ SpvImageOperandsLodMask, Operand::Int(GenerateLiteralIfNeeded(nullptr, &float_0))}); diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index 32be7051cc..157e0cdf7a 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -59,7 +59,7 @@ TEST_F(BuilderTest, ArrayAccessor) { auto* ary = create(mod->RegisterSymbol("ary"), "ary"); auto* idx_expr = create( - create(&i32, 1)); + create(Source{}, &i32, 1)); ast::ArrayAccessorExpression expr(ary, idx_expr); @@ -152,12 +152,12 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) { create(mod->RegisterSymbol("ary"), "ary"); ast::ArrayAccessorExpression expr( - ary, - create(ast::BinaryOp::kAdd, - create( - create(&i32, 1)), - create( - create(&i32, 2)))); + ary, create( + ast::BinaryOp::kAdd, + create( + create(Source{}, &i32, 1)), + create( + create(Source{}, &i32, 2)))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -201,9 +201,9 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { create( create(mod->RegisterSymbol("ary"), "ary"), create( - create(&i32, 3))), + create(Source{}, &i32, 3))), create( - create(&i32, 2))); + create(Source{}, &i32, 2))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -249,7 +249,7 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { create( create(mod->RegisterSymbol("ary"), "ary"), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod->RegisterSymbol("xy"), "xy")); td.RegisterVariableForTesting(&var); @@ -492,7 +492,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { create(mod->RegisterSymbol("a"), "a")); auto* rhs = create( - create(&f32, 2.f)); + create(Source{}, &f32, 2.f)); ast::AssignmentStatement expr(lhs, rhs); @@ -766,7 +766,7 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { "ident"), create(mod->RegisterSymbol("yxz"), "yxz")), create( - create(&i32, 1))); + create(Source{}, &i32, 1))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -840,11 +840,11 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { create( mod->RegisterSymbol("index"), "index"), create( - create(&i32, 0))), + create(Source{}, &i32, 0))), create( mod->RegisterSymbol("foo"), "foo")), create( - create(&i32, 2))), + create(Source{}, &i32, 2))), create(mod->RegisterSymbol("bar"), "bar")), create(mod->RegisterSymbol("baz"), "baz")), @@ -903,25 +903,25 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { ary_params.push_back(create( &vec, ast::ExpressionList{ create( - create(&f32, 0.0)), + create(Source{}, &f32, 0.0)), create( - create(&f32, 0.5)), + create(Source{}, &f32, 0.5)), })); ary_params.push_back(create( &vec, ast::ExpressionList{ create( - create(&f32, -0.5)), + create(Source{}, &f32, -0.5)), create( - create(&f32, -0.5)), + create(Source{}, &f32, -0.5)), })); ary_params.push_back(create( &vec, ast::ExpressionList{ create( - create(&f32, 0.5)), + create(Source{}, &f32, 0.5)), create( - create(&f32, -0.5)), + create(Source{}, &f32, -0.5)), })); ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &arr, true, @@ -931,7 +931,7 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { ast::ArrayAccessorExpression expr( create(mod->RegisterSymbol("pos"), "pos"), create( - create(&u32, 1))); + create(Source{}, &u32, 1))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error(); @@ -977,9 +977,9 @@ TEST_F(BuilderTest, Accessor_Const_Vec) { ast::ExpressionList vec_params; vec_params.push_back(create( - create(&f32, 0.0))); + create(Source{}, &f32, 0.0))); vec_params.push_back(create( - create(&f32, 0.5))); + create(Source{}, &f32, 0.5))); ast::Variable var( Source{}, "pos", ast::StorageClass::kPrivate, &vec, true, @@ -989,7 +989,7 @@ TEST_F(BuilderTest, Accessor_Const_Vec) { ast::ArrayAccessorExpression expr( create(mod->RegisterSymbol("pos"), "pos"), create( - create(&u32, 1))); + create(Source{}, &u32, 1))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error(); diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index 2285beb8bd..8947438d6e 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -50,7 +50,7 @@ TEST_F(BuilderTest, Assign_Var) { auto* ident = create(mod->RegisterSymbol("var"), "var"); auto* val = create( - create(&f32, 1.0f)); + create(Source{}, &f32, 1.0f)); ast::AssignmentStatement assign(ident, val); @@ -120,16 +120,16 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) { auto* first = create( &vec2, ast::ExpressionList{ create( - create(&f32, 1.0f)), + create(Source{}, &f32, 1.0f)), create( - create(&f32, 2.0f)), + create(Source{}, &f32, 2.0f)), }); auto* init = create( &vec3, ast::ExpressionList{ first, create( - create(&f32, 3.0f)), + create(Source{}, &f32, 3.0f)), }); ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false, @@ -174,11 +174,11 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 2.0f))); + create(Source{}, &f32, 2.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec3, vals); @@ -239,7 +239,7 @@ TEST_F(BuilderTest, Assign_StructMember) { create(mod->RegisterSymbol("b"), "b")); auto* val = create( - create(&f32, 4.0f)); + create(Source{}, &f32, 4.0f)); ast::AssignmentStatement assign(ident, val); @@ -282,11 +282,11 @@ TEST_F(BuilderTest, Assign_Vector) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* val = create(&vec3, vals); @@ -330,7 +330,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) { create(mod->RegisterSymbol("var"), "var"), create(mod->RegisterSymbol("y"), "y")); auto* val = create( - create(&f32, 1.0f)); + create(Source{}, &f32, 1.0f)); ast::AssignmentStatement assign(ident, val); @@ -375,9 +375,9 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { auto* ident = create( create(mod->RegisterSymbol("var"), "var"), create( - create(&i32, 1))); + create(Source{}, &i32, 1))); auto* val = create( - create(&f32, 1.0f)); + create(Source{}, &f32, 1.0f)); ast::AssignmentStatement assign(ident, val); diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index 880834ea71..1fdfd7ace8 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -57,9 +57,9 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar) { ast::type::I32 i32; auto* lhs = create( - create(&i32, 3)); + create(Source{}, &i32, 3)); auto* rhs = create( - create(&i32, 4)); + create(Source{}, &i32, 4)); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -84,21 +84,21 @@ TEST_P(BinaryArithSignedIntegerTest, Vector) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), }); auto* rhs = create( &vec3, ast::ExpressionList{ create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), }); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -175,9 +175,9 @@ TEST_P(BinaryArithUnsignedIntegerTest, Scalar) { ast::type::U32 u32; auto* lhs = create( - create(&u32, 3)); + create(Source{}, &u32, 3)); auto* rhs = create( - create(&u32, 4)); + create(Source{}, &u32, 4)); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -202,21 +202,21 @@ TEST_P(BinaryArithUnsignedIntegerTest, Vector) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), }); auto* rhs = create( &vec3, ast::ExpressionList{ create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), }); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -256,9 +256,9 @@ TEST_P(BinaryArithFloatTest, Scalar) { ast::type::F32 f32; auto* lhs = create( - create(&f32, 3.2f)); + create(Source{}, &f32, 3.2f)); auto* rhs = create( - create(&f32, 4.5f)); + create(Source{}, &f32, 4.5f)); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -283,21 +283,21 @@ TEST_P(BinaryArithFloatTest, Vector) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), }); auto* rhs = create( &vec3, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), }); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -331,9 +331,9 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) { ast::type::U32 u32; auto* lhs = create( - create(&u32, 3)); + create(Source{}, &u32, 3)); auto* rhs = create( - create(&u32, 4)); + create(Source{}, &u32, 4)); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -360,21 +360,21 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Vector) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), }); auto* rhs = create( &vec3, ast::ExpressionList{ create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), create( - create(&u32, 1)), + create(Source{}, &u32, 1)), }); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -412,9 +412,9 @@ TEST_P(BinaryCompareSignedIntegerTest, Scalar) { ast::type::I32 i32; auto* lhs = create( - create(&i32, 3)); + create(Source{}, &i32, 3)); auto* rhs = create( - create(&i32, 4)); + create(Source{}, &i32, 4)); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -441,21 +441,21 @@ TEST_P(BinaryCompareSignedIntegerTest, Vector) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), }); auto* rhs = create( &vec3, ast::ExpressionList{ create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), create( - create(&i32, 1)), + create(Source{}, &i32, 1)), }); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -493,9 +493,9 @@ TEST_P(BinaryCompareFloatTest, Scalar) { ast::type::F32 f32; auto* lhs = create( - create(&f32, 3.2f)); + create(Source{}, &f32, 3.2f)); auto* rhs = create( - create(&f32, 4.5f)); + create(Source{}, &f32, 4.5f)); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -522,21 +522,21 @@ TEST_P(BinaryCompareFloatTest, Vector) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), }); auto* rhs = create( &vec3, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), }); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -574,15 +574,15 @@ TEST_F(BuilderTest, Binary_Multiply_VectorScalar) { auto* lhs = create( &vec3, ast::ExpressionList{ create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), create( - create(&f32, 1.f)), + create(Source{}, &f32, 1.f)), }); auto* rhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs); @@ -605,15 +605,15 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarVector) { ast::type::Vector vec3(&f32, 3); auto* lhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* rhs = create(&vec3, vals); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs); @@ -647,7 +647,7 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) { auto* lhs = create(mod->RegisterSymbol("mat"), "mat"); auto* rhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); td.RegisterVariableForTesting(var); @@ -685,7 +685,7 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) { nullptr, // constructor ast::VariableDecorationList{}); // decorations auto* lhs = create( - create(&f32, 1.f)); + create(Source{}, &f32, 1.f)); auto* rhs = create(mod->RegisterSymbol("mat"), "mat"); @@ -730,11 +730,11 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* rhs = create(&vec3, vals); td.RegisterVariableForTesting(var); @@ -777,11 +777,11 @@ TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); vals.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); auto* lhs = create(&vec3, vals); auto* rhs = @@ -855,19 +855,19 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) { TEST_F(BuilderTest, Binary_LogicalAnd) { ast::type::I32 i32; - auto* lhs = - create(ast::BinaryOp::kEqual, - create( - create(&i32, 1)), - create( - create(&i32, 2))); + auto* lhs = create( + ast::BinaryOp::kEqual, + create( + create(Source{}, &i32, 1)), + create( + create(Source{}, &i32, 2))); - auto* rhs = - create(ast::BinaryOp::kEqual, - create( - create(&i32, 3)), - create( - create(&i32, 4))); + auto* rhs = create( + ast::BinaryOp::kEqual, + create( + create(Source{}, &i32, 3)), + create( + create(Source{}, &i32, 4))); ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, lhs, rhs); @@ -907,17 +907,17 @@ TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) { &bool_type, // type false, // is_const create( - create(&bool_type, true)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &bool_type, true)), // constructor + ast::VariableDecorationList{}); // decorations auto* b_var = create( Source{}, // source "b", // name ast::StorageClass::kFunction, // storage_class &bool_type, // type false, // is_const - create( - create(&bool_type, false)), // constructor - ast::VariableDecorationList{}); // decorations + create(create( + Source{}, &bool_type, false)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create(mod->RegisterSymbol("a"), "a"); auto* rhs = create(mod->RegisterSymbol("b"), "b"); @@ -966,14 +966,15 @@ TEST_F(BuilderTest, Binary_logicalOr_Nested_LogicalAnd) { auto* logical_and_expr = create( ast::BinaryOp::kLogicalAnd, create( - create(&bool_ty, true)), + create(Source{}, &bool_ty, true)), create( - create(&bool_ty, false))); + create(Source{}, &bool_ty, false))); - ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, - create( - create(&bool_ty, true)), - logical_and_expr); + ast::BinaryExpression expr( + ast::BinaryOp::kLogicalOr, + create( + create(Source{}, &bool_ty, true)), + logical_and_expr); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -1012,14 +1013,15 @@ TEST_F(BuilderTest, Binary_logicalAnd_Nested_LogicalOr) { auto* logical_or_expr = create( ast::BinaryOp::kLogicalOr, create( - create(&bool_ty, true)), + create(Source{}, &bool_ty, true)), create( - create(&bool_ty, false))); + create(Source{}, &bool_ty, false))); - ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, - create( - create(&bool_ty, true)), - logical_or_expr); + ast::BinaryExpression expr( + ast::BinaryOp::kLogicalAnd, + create( + create(Source{}, &bool_ty, true)), + logical_or_expr); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -1051,19 +1053,19 @@ OpBranch %4 TEST_F(BuilderTest, Binary_LogicalOr) { ast::type::I32 i32; - auto* lhs = - create(ast::BinaryOp::kEqual, - create( - create(&i32, 1)), - create( - create(&i32, 2))); + auto* lhs = create( + ast::BinaryOp::kEqual, + create( + create(Source{}, &i32, 1)), + create( + create(Source{}, &i32, 2))); - auto* rhs = - create(ast::BinaryOp::kEqual, - create( - create(&i32, 3)), - create( - create(&i32, 4))); + auto* rhs = create( + ast::BinaryOp::kEqual, + create( + create(Source{}, &i32, 3)), + create( + create(Source{}, &i32, 4))); ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, lhs, rhs); @@ -1103,17 +1105,17 @@ TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) { &bool_type, // type false, // is_const create( - create(&bool_type, true)), // constructor - ast::VariableDecorationList{}); // decorations + create(Source{}, &bool_type, true)), // constructor + ast::VariableDecorationList{}); // decorations auto* b_var = create( Source{}, // source "b", // name ast::StorageClass::kFunction, // storage_class &bool_type, // type false, // is_const - create( - create(&bool_type, false)), // constructor - ast::VariableDecorationList{}); // decorations + create(create( + Source{}, &bool_type, false)), // constructor + ast::VariableDecorationList{}); // decorations auto* lhs = create(mod->RegisterSymbol("a"), "a"); auto* rhs = create(mod->RegisterSymbol("b"), "b"); diff --git a/src/writer/spirv/builder_bitcast_expression_test.cc b/src/writer/spirv/builder_bitcast_expression_test.cc index ee166f73de..b9ccae751f 100644 --- a/src/writer/spirv/builder_bitcast_expression_test.cc +++ b/src/writer/spirv/builder_bitcast_expression_test.cc @@ -35,9 +35,9 @@ TEST_F(BuilderTest, Bitcast) { ast::type::U32 u32; ast::type::F32 f32; - ast::BitcastExpression bitcast(&u32, - create( - create(&f32, 2.4))); + ast::BitcastExpression bitcast( + &u32, create( + create(Source{}, &f32, 2.4))); ASSERT_TRUE(td.DetermineResultType(&bitcast)) << td.error(); @@ -56,9 +56,9 @@ TEST_F(BuilderTest, Bitcast) { TEST_F(BuilderTest, Bitcast_DuplicateType) { ast::type::F32 f32; - ast::BitcastExpression bitcast(&f32, - create( - create(&f32, 2.4))); + ast::BitcastExpression bitcast( + &f32, create( + create(Source{}, &f32, 2.4))); 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 838a08445a..7dea26ef83 100644 --- a/src/writer/spirv/builder_block_test.cc +++ b/src/writer/spirv/builder_block_test.cc @@ -52,7 +52,7 @@ TEST_F(BuilderTest, Block) { outer.append(create( create(mod->RegisterSymbol("var"), "var"), create( - create(&f32, 1.0f)))); + create(Source{}, &f32, 1.0f)))); auto* inner = create(); inner->append(create( @@ -66,13 +66,13 @@ TEST_F(BuilderTest, Block) { inner->append(create( create(mod->RegisterSymbol("var"), "var"), create( - create(&f32, 2.0f)))); + create(Source{}, &f32, 2.0f)))); outer.append(inner); outer.append(create( create(mod->RegisterSymbol("var"), "var"), create( - create(&f32, 3.0f)))); + create(Source{}, &f32, 3.0f)))); ASSERT_TRUE(td.DetermineResultType(&outer)) << td.error(); diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index 8cc1ba25d1..e7a7b5298f 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -77,9 +77,9 @@ TEST_F(BuilderTest, Expression_Call) { ast::ExpressionList call_params; call_params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); call_params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); ast::CallExpression expr(create( mod->RegisterSymbol("a_func"), "a_func"), @@ -159,9 +159,9 @@ TEST_F(BuilderTest, Statement_Call) { ast::ExpressionList call_params; call_params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); call_params.push_back(create( - create(&f32, 1.f))); + create(Source{}, &f32, 1.f))); ast::CallStatement expr( create(create( diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc index fcdfeb3ba6..8e40badca5 100644 --- a/src/writer/spirv/builder_function_variable_test.cc +++ b/src/writer/spirv/builder_function_variable_test.cc @@ -70,11 +70,11 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec, vals); @@ -110,16 +110,16 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) { ast::type::F32 f32; ast::type::Vector vec(&f32, 2); - auto* rel = - create(ast::BinaryOp::kAdd, - create( - create(&f32, 3.0f)), - create( - create(&f32, 3.0f))); + auto* rel = create( + ast::BinaryOp::kAdd, + create( + create(Source{}, &f32, 3.0f)), + create( + create(Source{}, &f32, 3.0f))); ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(rel); auto* init = create(&vec, vals); @@ -160,7 +160,7 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) { ast::type::F32 f32; auto* init = create( - create(&f32, 1.0f)); + create(Source{}, &f32, 1.0f)); ASSERT_TRUE(td.DetermineResultType(init)) << td.error(); @@ -207,7 +207,7 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) { ast::type::F32 f32; auto* init = create( - create(&f32, 1.0f)); + create(Source{}, &f32, 1.0f)); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); @@ -250,11 +250,11 @@ TEST_F(BuilderTest, FunctionVar_Const) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec, vals); diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index 16062c2ce4..9a8f136165 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -99,11 +99,11 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec, vals); @@ -135,11 +135,11 @@ TEST_F(BuilderTest, GlobalVar_Const) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec, vals); @@ -168,11 +168,11 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 2.0f))); + create(Source{}, &f32, 2.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec3, vals); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); @@ -201,16 +201,16 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { auto* first = create( &vec2, ast::ExpressionList{ create( - create(&f32, 1.0f)), + create(Source{}, &f32, 1.0f)), create( - create(&f32, 2.0f)), + create(Source{}, &f32, 2.0f)), }); auto* init = create( &vec3, ast::ExpressionList{ first, create( - create(&f32, 3.0f)), + create(Source{}, &f32, 3.0f)), }); EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); @@ -328,7 +328,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) { &bool_type, // type false, // is_const create( - create(&bool_type, true)), // constructor + create(Source{}, &bool_type, true)), // constructor ast::VariableDecorationList{ // decorations create(1200, Source{}), @@ -383,7 +383,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) { &f32, // type false, // is_const create( - create(&f32, 2.0)), // constructor + create(Source{}, &f32, 2.0)), // constructor ast::VariableDecorationList{ // decorations create(0, Source{}), diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc index d678c7621e..4f1f3af77f 100644 --- a/src/writer/spirv/builder_ident_expression_test.cc +++ b/src/writer/spirv/builder_ident_expression_test.cc @@ -43,11 +43,11 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec, vals); @@ -102,11 +102,11 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* init = create(&vec, vals); @@ -195,7 +195,7 @@ TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) { ast::Variable var(Source{}, "var", ast::StorageClass::kNone, &i32, true, create( - create(&i32, 2)), + create(Source{}, &i32, 2)), ast::VariableDecorationList{}); td.RegisterVariableForTesting(&var); diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc index b85dff9a3d..e3724bb2dc 100644 --- a/src/writer/spirv/builder_if_test.cc +++ b/src/writer/spirv/builder_if_test.cc @@ -46,7 +46,7 @@ TEST_F(BuilderTest, If_Empty) { // if (true) { // } auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); ast::IfStatement expr(Source{}, cond, create(), ast::ElseStatementList{}); @@ -88,10 +88,10 @@ TEST_F(BuilderTest, If_WithStatements) { body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); ast::IfStatement expr(Source{}, cond, body, ast::ElseStatementList{}); @@ -142,16 +142,16 @@ TEST_F(BuilderTest, If_WithElse) { body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* else_body = create(); else_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); ast::IfStatement expr(Source{}, cond, body, {create(else_body)}); @@ -208,19 +208,19 @@ TEST_F(BuilderTest, If_WithElseIf) { body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* else_body = create(); else_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); auto* else_cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); ast::IfStatement expr(Source{}, cond, body, {create(else_cond, else_body)}); @@ -286,30 +286,30 @@ TEST_F(BuilderTest, If_WithMultiple) { body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* elseif_1_body = create(); elseif_1_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); auto* elseif_2_body = create(); elseif_2_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 4)))); + create(Source{}, &i32, 4)))); auto* else_body = create(); else_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 5)))); + create(Source{}, &i32, 5)))); auto* elseif_1_cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* elseif_2_cond = create( - create(&bool_type, false)); + create(Source{}, &bool_type, false)); auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); ast::IfStatement expr( Source{}, cond, body, @@ -376,7 +376,7 @@ TEST_F(BuilderTest, If_WithBreak) { // } // } auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* if_body = create(); if_body->append(create()); @@ -424,7 +424,7 @@ TEST_F(BuilderTest, If_WithElseBreak) { // } // } auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* else_body = create(); else_body->append(create()); @@ -474,7 +474,7 @@ TEST_F(BuilderTest, If_WithContinue) { // } // } auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* if_body = create(); if_body->append(create()); @@ -522,7 +522,7 @@ TEST_F(BuilderTest, If_WithElseContinue) { // } // } auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* else_body = create(); else_body->append(create()); @@ -570,7 +570,7 @@ TEST_F(BuilderTest, If_WithReturn) { // return; // } auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* if_body = create(); if_body->append(create(Source{})); @@ -600,9 +600,9 @@ TEST_F(BuilderTest, If_WithReturnValue) { // return false; // } auto* cond = create( - create(&bool_type, true)); + create(Source{}, &bool_type, true)); auto* cond2 = create( - create(&bool_type, false)); + create(Source{}, &bool_type, false)); auto* if_body = create(); if_body->append(create(Source{}, cond2)); diff --git a/src/writer/spirv/builder_literal_test.cc b/src/writer/spirv/builder_literal_test.cc index a50f0ca7b8..acecbdeb79 100644 --- a/src/writer/spirv/builder_literal_test.cc +++ b/src/writer/spirv/builder_literal_test.cc @@ -35,7 +35,7 @@ using BuilderTest = TestHelper; TEST_F(BuilderTest, Literal_Bool_True) { ast::type::Bool bool_type; - ast::BoolLiteral b_true(&bool_type, true); + ast::BoolLiteral b_true(Source{}, &bool_type, true); auto id = b.GenerateLiteralIfNeeded(nullptr, &b_true); ASSERT_FALSE(b.has_error()) << b.error(); @@ -48,7 +48,7 @@ TEST_F(BuilderTest, Literal_Bool_True) { TEST_F(BuilderTest, Literal_Bool_False) { ast::type::Bool bool_type; - ast::BoolLiteral b_false(&bool_type, false); + ast::BoolLiteral b_false(Source{}, &bool_type, false); auto id = b.GenerateLiteralIfNeeded(nullptr, &b_false); ASSERT_FALSE(b.has_error()) << b.error(); @@ -61,8 +61,8 @@ TEST_F(BuilderTest, Literal_Bool_False) { TEST_F(BuilderTest, Literal_Bool_Dedup) { ast::type::Bool bool_type; - ast::BoolLiteral b_true(&bool_type, true); - ast::BoolLiteral b_false(&bool_type, false); + ast::BoolLiteral b_true(Source{}, &bool_type, true); + ast::BoolLiteral b_false(Source{}, &bool_type, false); ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &b_true), 0u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -79,7 +79,7 @@ TEST_F(BuilderTest, Literal_Bool_Dedup) { TEST_F(BuilderTest, Literal_I32) { ast::type::I32 i32; - ast::SintLiteral i(&i32, -23); + ast::SintLiteral i(Source{}, &i32, -23); auto id = b.GenerateLiteralIfNeeded(nullptr, &i); ASSERT_FALSE(b.has_error()) << b.error(); @@ -92,8 +92,8 @@ TEST_F(BuilderTest, Literal_I32) { TEST_F(BuilderTest, Literal_I32_Dedup) { ast::type::I32 i32; - ast::SintLiteral i1(&i32, -23); - ast::SintLiteral i2(&i32, -23); + ast::SintLiteral i1(Source{}, &i32, -23); + ast::SintLiteral i2(Source{}, &i32, -23); ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i1), 0u); ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i2), 0u); @@ -106,7 +106,7 @@ TEST_F(BuilderTest, Literal_I32_Dedup) { TEST_F(BuilderTest, Literal_U32) { ast::type::U32 u32; - ast::UintLiteral i(&u32, 23); + ast::UintLiteral i(Source{}, &u32, 23); auto id = b.GenerateLiteralIfNeeded(nullptr, &i); ASSERT_FALSE(b.has_error()) << b.error(); @@ -119,8 +119,8 @@ TEST_F(BuilderTest, Literal_U32) { TEST_F(BuilderTest, Literal_U32_Dedup) { ast::type::U32 u32; - ast::UintLiteral i1(&u32, 23); - ast::UintLiteral i2(&u32, 23); + ast::UintLiteral i1(Source{}, &u32, 23); + ast::UintLiteral i2(Source{}, &u32, 23); ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i1), 0u); ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i2), 0u); @@ -133,7 +133,7 @@ TEST_F(BuilderTest, Literal_U32_Dedup) { TEST_F(BuilderTest, Literal_F32) { ast::type::F32 f32; - ast::FloatLiteral i(&f32, 23.245f); + ast::FloatLiteral i(Source{}, &f32, 23.245f); auto id = b.GenerateLiteralIfNeeded(nullptr, &i); ASSERT_FALSE(b.has_error()) << b.error(); @@ -146,8 +146,8 @@ TEST_F(BuilderTest, Literal_F32) { TEST_F(BuilderTest, Literal_F32_Dedup) { ast::type::F32 f32; - ast::FloatLiteral i1(&f32, 23.245f); - ast::FloatLiteral i2(&f32, 23.245f); + ast::FloatLiteral i1(Source{}, &f32, 23.245f); + ast::FloatLiteral i2(Source{}, &f32, 23.245f); ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i1), 0u); ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i2), 0u); diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc index 5bc1327ee7..98cffeb6a7 100644 --- a/src/writer/spirv/builder_loop_test.cc +++ b/src/writer/spirv/builder_loop_test.cc @@ -78,7 +78,7 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); ast::LoopStatement expr(body, create()); @@ -131,13 +131,13 @@ TEST_F(BuilderTest, Loop_WithContinuing) { body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* continuing = create(); continuing->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); ast::LoopStatement expr(body, continuing); td.RegisterVariableForTesting(var); diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc index a219649b03..8c661008f9 100644 --- a/src/writer/spirv/builder_return_test.cc +++ b/src/writer/spirv/builder_return_test.cc @@ -51,11 +51,11 @@ TEST_F(BuilderTest, Return_WithValue) { ast::ExpressionList vals; vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 1.0f))); + create(Source{}, &f32, 1.0f))); vals.push_back(create( - create(&f32, 3.0f))); + create(Source{}, &f32, 3.0f))); auto* val = create(&vec, vals); diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc index c8d7be0642..4ace391593 100644 --- a/src/writer/spirv/builder_switch_test.cc +++ b/src/writer/spirv/builder_switch_test.cc @@ -45,7 +45,7 @@ TEST_F(BuilderTest, Switch_Empty) { // switch (1) { // } auto* cond = create( - create(&i32, 1)); + create(Source{}, &i32, 1)); ast::SwitchStatement expr(cond, ast::CaseStatementList{}); @@ -97,19 +97,19 @@ TEST_F(BuilderTest, Switch_WithCase) { case_1_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 1)))); + create(Source{}, &i32, 1)))); auto* case_2_body = create(); case_2_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); ast::CaseSelectorList selector_1; - selector_1.push_back(create(&i32, 1)); + selector_1.push_back(create(Source{}, &i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(create(&i32, 2)); + selector_2.push_back(create(Source{}, &i32, 2)); ast::CaseStatementList cases; cases.push_back(create(selector_1, case_1_body)); @@ -191,7 +191,7 @@ TEST_F(BuilderTest, Switch_WithDefault) { default_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 1)))); + create(Source{}, &i32, 1)))); ast::CaseStatementList cases; cases.push_back(create(default_body)); @@ -270,26 +270,26 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { case_1_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 1)))); + create(Source{}, &i32, 1)))); auto* case_2_body = create(); case_2_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* default_body = create(); default_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); ast::CaseSelectorList selector_1; - selector_1.push_back(create(&i32, 1)); + selector_1.push_back(create(Source{}, &i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(create(&i32, 2)); - selector_2.push_back(create(&i32, 3)); + selector_2.push_back(create(Source{}, &i32, 2)); + selector_2.push_back(create(Source{}, &i32, 3)); ast::CaseStatementList cases; cases.push_back(create(selector_1, case_1_body)); @@ -379,26 +379,26 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { case_1_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 1)))); + create(Source{}, &i32, 1)))); case_1_body->append(create()); auto* case_2_body = create(); case_2_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 2)))); + create(Source{}, &i32, 2)))); auto* default_body = create(); default_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 3)))); + create(Source{}, &i32, 3)))); ast::CaseSelectorList selector_1; - selector_1.push_back(create(&i32, 1)); + selector_1.push_back(create(Source{}, &i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(create(&i32, 2)); + selector_2.push_back(create(Source{}, &i32, 2)); ast::CaseStatementList cases; cases.push_back(create(selector_1, case_1_body)); @@ -484,11 +484,11 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { case_1_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 1)))); + create(Source{}, &i32, 1)))); case_1_body->append(create()); ast::CaseSelectorList selector_1; - selector_1.push_back(create(&i32, 1)); + selector_1.push_back(create(Source{}, &i32, 1)); ast::CaseStatementList cases; cases.push_back(create(selector_1, case_1_body)); @@ -545,19 +545,19 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { if_body->append(create()); auto* case_1_body = create(); - case_1_body->append( - create(Source{}, - create( - create(&bool_type, true)), - if_body, ast::ElseStatementList{})); + case_1_body->append(create( + Source{}, + create( + create(Source{}, &bool_type, true)), + if_body, ast::ElseStatementList{})); case_1_body->append(create( create(mod->RegisterSymbol("v"), "v"), create( - create(&i32, 1)))); + create(Source{}, &i32, 1)))); ast::CaseSelectorList selector_1; - selector_1.push_back(create(&i32, 1)); + selector_1.push_back(create(Source{}, &i32, 1)); ast::CaseStatementList cases; cases.push_back(create(selector_1, case_1_body)); diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc index 2579b87d75..ab14418639 100644 --- a/src/writer/spirv/builder_unary_op_expression_test.cc +++ b/src/writer/spirv/builder_unary_op_expression_test.cc @@ -42,7 +42,7 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) { ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, create( - create(&i32, 1))); + create(Source{}, &i32, 1))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -59,9 +59,10 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) { TEST_F(BuilderTest, UnaryOp_Negation_Float) { ast::type::F32 f32; - ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, - create( - create(&f32, 1))); + ast::UnaryOpExpression expr( + ast::UnaryOp::kNegation, + create( + create(Source{}, &f32, 1))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -78,9 +79,10 @@ TEST_F(BuilderTest, UnaryOp_Negation_Float) { TEST_F(BuilderTest, UnaryOp_Not) { ast::type::Bool bool_type; - ast::UnaryOpExpression expr(ast::UnaryOp::kNot, - create( - create(&bool_type, false))); + ast::UnaryOpExpression expr( + ast::UnaryOp::kNot, + create( + create(Source{}, &bool_type, false))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc index 034051d768..06c76195ea 100644 --- a/src/writer/wgsl/generator_impl_array_accessor_test.cc +++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc @@ -32,7 +32,7 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) { ast::type::I32 i32; - auto* lit = create(&i32, 5); + auto* lit = create(Source{}, &i32, 5); auto* idx = create(lit); auto* ary = create(mod.RegisterSymbol("ary"), "ary"); diff --git a/src/writer/wgsl/generator_impl_case_test.cc b/src/writer/wgsl/generator_impl_case_test.cc index b23348ff5c..1a1a444d0b 100644 --- a/src/writer/wgsl/generator_impl_case_test.cc +++ b/src/writer/wgsl/generator_impl_case_test.cc @@ -37,7 +37,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Case) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); + lit.push_back(create(Source{}, &i32, 5)); ast::CaseStatement c(lit, body); gen.increment_indent(); @@ -56,8 +56,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) { body->append(create()); ast::CaseSelectorList lit; - lit.push_back(create(&i32, 5)); - lit.push_back(create(&i32, 6)); + lit.push_back(create(Source{}, &i32, 5)); + lit.push_back(create(Source{}, &i32, 6)); ast::CaseStatement c(lit, body); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_constructor_test.cc b/src/writer/wgsl/generator_impl_constructor_test.cc index 14da9a1ddb..f945e55de4 100644 --- a/src/writer/wgsl/generator_impl_constructor_test.cc +++ b/src/writer/wgsl/generator_impl_constructor_test.cc @@ -37,7 +37,7 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) { ast::type::Bool bool_type; - auto* lit = create(&bool_type, false); + auto* lit = create(Source{}, &bool_type, false); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -46,7 +46,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) { ast::type::I32 i32; - auto* lit = create(&i32, -12345); + auto* lit = create(Source{}, &i32, -12345); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -55,7 +55,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) { TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) { ast::type::U32 u32; - auto* lit = create(&u32, 56779); + auto* lit = create(Source{}, &u32, 56779); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -65,8 +65,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) { ast::type::F32 f32; // Use a number close to 1<<30 but whose decimal representation ends in 0. - auto* lit = - create(&f32, static_cast((1 << 30) - 4)); + auto* lit = create(Source{}, &f32, + static_cast((1 << 30) - 4)); ast::ScalarConstructorExpression expr(lit); ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error(); @@ -76,7 +76,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) { ast::type::F32 f32; - auto* lit = create(&f32, -1.2e-5); + auto* lit = create(Source{}, &f32, -1.2e-5); ast::ExpressionList values; values.push_back(create(lit)); @@ -89,7 +89,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Bool) { ast::type::Bool b; - auto* lit = create(&b, true); + auto* lit = create(Source{}, &b, true); ast::ExpressionList values; values.push_back(create(lit)); @@ -102,7 +102,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Bool) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Int) { ast::type::I32 i32; - auto* lit = create(&i32, -12345); + auto* lit = create(Source{}, &i32, -12345); ast::ExpressionList values; values.push_back(create(lit)); @@ -115,7 +115,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Int) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Uint) { ast::type::U32 u32; - auto* lit = create(&u32, 12345); + auto* lit = create(Source{}, &u32, 12345); ast::ExpressionList values; values.push_back(create(lit)); @@ -129,9 +129,9 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) { ast::type::F32 f32; ast::type::Vector vec(&f32, 3); - auto* lit1 = create(&f32, 1.f); - auto* lit2 = create(&f32, 2.f); - auto* lit3 = create(&f32, 3.f); + auto* lit1 = create(Source{}, &f32, 1.f); + auto* lit2 = create(Source{}, &f32, 2.f); + auto* lit3 = create(Source{}, &f32, 3.f); ast::ExpressionList values; values.push_back(create(lit1)); values.push_back(create(lit2)); @@ -152,10 +152,10 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) { ast::ExpressionList mat_values; for (size_t i = 0; i < 3; i++) { - auto* lit1 = - create(&f32, static_cast(1 + (i * 2))); - auto* lit2 = - create(&f32, static_cast(2 + (i * 2))); + auto* lit1 = create(Source{}, &f32, + static_cast(1 + (i * 2))); + auto* lit2 = create(Source{}, &f32, + static_cast(2 + (i * 2))); ast::ExpressionList values; values.push_back(create(lit1)); @@ -179,12 +179,12 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) { ast::ExpressionList ary_values; for (size_t i = 0; i < 3; i++) { - auto* lit1 = - create(&f32, static_cast(1 + (i * 3))); - auto* lit2 = - create(&f32, static_cast(2 + (i * 3))); - auto* lit3 = - create(&f32, static_cast(3 + (i * 3))); + auto* lit1 = create(Source{}, &f32, + static_cast(1 + (i * 3))); + auto* lit2 = create(Source{}, &f32, + static_cast(2 + (i * 3))); + auto* lit3 = create(Source{}, &f32, + static_cast(3 + (i * 3))); ast::ExpressionList values; values.push_back(create(lit1)); diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc index 732998fdbe..dfa38afe20 100644 --- a/src/writer/wgsl/generator_impl_switch_test.cc +++ b/src/writer/wgsl/generator_impl_switch_test.cc @@ -38,7 +38,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) { ast::type::I32 i32; ast::CaseSelectorList case_val; - case_val.push_back(create(&i32, 5)); + case_val.push_back(create(Source{}, &i32, 5)); auto* case_body = create(); case_body->append(create());