ast: Remove expression constructors that don't take a Source
Parsers need fixing up.
Bug: tint:396
Bug: tint:390
Change-Id: I7f823e2489101b43c1b21a6b89c248695a3f35b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35160
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/ast/array_accessor_expression.cc b/src/ast/array_accessor_expression.cc
index 7c5900b..82cfd2b 100644
--- a/src/ast/array_accessor_expression.cc
+++ b/src/ast/array_accessor_expression.cc
@@ -22,10 +22,6 @@
namespace tint {
namespace ast {
-ArrayAccessorExpression::ArrayAccessorExpression(Expression* array,
- Expression* idx_expr)
- : Base(), array_(array), idx_expr_(idx_expr) {}
-
ArrayAccessorExpression::ArrayAccessorExpression(const Source& source,
Expression* array,
Expression* idx_expr)
@@ -38,8 +34,8 @@
ArrayAccessorExpression* ArrayAccessorExpression::Clone(
CloneContext* ctx) const {
- return ctx->mod->create<ArrayAccessorExpression>(ctx->Clone(array_),
- ctx->Clone(idx_expr_));
+ return ctx->mod->create<ArrayAccessorExpression>(
+ ctx->Clone(source()), ctx->Clone(array_), ctx->Clone(idx_expr_));
}
bool ArrayAccessorExpression::IsValid() const {
diff --git a/src/ast/array_accessor_expression.h b/src/ast/array_accessor_expression.h
index 9738767..d35c20a 100644
--- a/src/ast/array_accessor_expression.h
+++ b/src/ast/array_accessor_expression.h
@@ -29,10 +29,6 @@
: public Castable<ArrayAccessorExpression, Expression> {
public:
/// Constructor
- /// @param array the array
- /// @param idx_expr the index expression
- ArrayAccessorExpression(Expression* array, Expression* idx_expr);
- /// Constructor
/// @param source the array accessor source
/// @param array the array
/// @param idx_expr the index expression
diff --git a/src/ast/array_accessor_expression_test.cc b/src/ast/array_accessor_expression_test.cc
index 9bb30e0..1de4435 100644
--- a/src/ast/array_accessor_expression_test.cc
+++ b/src/ast/array_accessor_expression_test.cc
@@ -24,17 +24,21 @@
using ArrayAccessorExpressionTest = TestHelper;
TEST_F(ArrayAccessorExpressionTest, Create) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("idx"), "idx");
- ArrayAccessorExpression exp(ary, idx);
+ ArrayAccessorExpression exp(Source{}, ary, idx);
ASSERT_EQ(exp.array(), ary);
ASSERT_EQ(exp.idx_expr(), idx);
}
TEST_F(ArrayAccessorExpressionTest, CreateWithSource) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("idx"), "idx");
ArrayAccessorExpression exp(Source{Source::Location{20, 2}}, ary, idx);
auto src = exp.source();
@@ -43,54 +47,66 @@
}
TEST_F(ArrayAccessorExpressionTest, IsArrayAccessor) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("idx"), "idx");
- ArrayAccessorExpression exp(ary, idx);
+ ArrayAccessorExpression exp(Source{}, ary, idx);
EXPECT_TRUE(exp.Is<ArrayAccessorExpression>());
}
TEST_F(ArrayAccessorExpressionTest, IsValid) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("idx"), "idx");
- ArrayAccessorExpression exp(ary, idx);
+ ArrayAccessorExpression exp(Source{}, ary, idx);
EXPECT_TRUE(exp.IsValid());
}
TEST_F(ArrayAccessorExpressionTest, IsValid_MissingArray) {
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("idx"), "idx");
- ArrayAccessorExpression exp(nullptr, idx);
+ ArrayAccessorExpression exp(Source{}, nullptr, idx);
EXPECT_FALSE(exp.IsValid());
}
TEST_F(ArrayAccessorExpressionTest, IsValid_MissingIndex) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ary"), "ary");
- ArrayAccessorExpression exp(ary, nullptr);
+ ArrayAccessorExpression exp(Source{}, ary, nullptr);
EXPECT_FALSE(exp.IsValid());
}
TEST_F(ArrayAccessorExpressionTest, IsValid_InvalidArray) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
- ArrayAccessorExpression exp(ary, idx);
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("idx"), "idx");
+ ArrayAccessorExpression exp(Source{}, ary, idx);
EXPECT_FALSE(exp.IsValid());
}
TEST_F(ArrayAccessorExpressionTest, IsValid_InvalidIndex) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
- ArrayAccessorExpression exp(ary, idx);
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
+ ArrayAccessorExpression exp(Source{}, ary, idx);
EXPECT_FALSE(exp.IsValid());
}
TEST_F(ArrayAccessorExpressionTest, ToStr) {
- auto* ary = create<IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx = create<IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("idx"), "idx");
- ArrayAccessorExpression exp(ary, idx);
+ ArrayAccessorExpression exp(Source{}, ary, idx);
std::ostringstream out;
exp.to_str(out, 2);
diff --git a/src/ast/assignment_statement_test.cc b/src/ast/assignment_statement_test.cc
index 4f69c58..5cb5954 100644
--- a/src/ast/assignment_statement_test.cc
+++ b/src/ast/assignment_statement_test.cc
@@ -24,8 +24,10 @@
using AssignmentStatementTest = TestHelper;
TEST_F(AssignmentStatementTest, Creation) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
AssignmentStatement stmt(lhs, rhs);
EXPECT_EQ(stmt.lhs(), lhs);
@@ -33,8 +35,10 @@
}
TEST_F(AssignmentStatementTest, CreationWithSource) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
AssignmentStatement stmt(Source{Source::Location{20, 2}}, lhs, rhs);
auto src = stmt.source();
@@ -43,52 +47,64 @@
}
TEST_F(AssignmentStatementTest, IsAssign) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
AssignmentStatement stmt(lhs, rhs);
EXPECT_TRUE(stmt.Is<AssignmentStatement>());
}
TEST_F(AssignmentStatementTest, IsValid) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
AssignmentStatement stmt(lhs, rhs);
EXPECT_TRUE(stmt.IsValid());
}
TEST_F(AssignmentStatementTest, IsValid_MissingLHS) {
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
AssignmentStatement stmt(nullptr, rhs);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(AssignmentStatementTest, IsValid_MissingRHS) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
AssignmentStatement stmt(lhs, nullptr);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(AssignmentStatementTest, IsValid_InvalidLHS) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
AssignmentStatement stmt(lhs, rhs);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(AssignmentStatementTest, IsValid_InvalidRHS) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
AssignmentStatement stmt(lhs, rhs);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(AssignmentStatementTest, ToStr) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
AssignmentStatement stmt(lhs, rhs);
std::ostringstream out;
diff --git a/src/ast/binary_expression.cc b/src/ast/binary_expression.cc
index edd2e4b..e8566fd 100644
--- a/src/ast/binary_expression.cc
+++ b/src/ast/binary_expression.cc
@@ -22,11 +22,6 @@
namespace tint {
namespace ast {
-BinaryExpression::BinaryExpression(BinaryOp op,
- Expression* lhs,
- Expression* rhs)
- : Base(), op_(op), lhs_(lhs), rhs_(rhs) {}
-
BinaryExpression::BinaryExpression(const Source& source,
BinaryOp op,
Expression* lhs,
diff --git a/src/ast/binary_expression.h b/src/ast/binary_expression.h
index d042e6d..8283a5d 100644
--- a/src/ast/binary_expression.h
+++ b/src/ast/binary_expression.h
@@ -51,11 +51,6 @@
class BinaryExpression : public Castable<BinaryExpression, Expression> {
public:
/// Constructor
- /// @param op the operation type
- /// @param lhs the left side of the expression
- /// @param rhs the right side of the expression
- BinaryExpression(BinaryOp op, Expression* lhs, Expression* rhs);
- /// Constructor
/// @param source the binary expression source
/// @param op the operation type
/// @param lhs the left side of the expression
diff --git a/src/ast/binary_expression_test.cc b/src/ast/binary_expression_test.cc
index ecba1ac..4758a25 100644
--- a/src/ast/binary_expression_test.cc
+++ b/src/ast/binary_expression_test.cc
@@ -26,18 +26,22 @@
using BinaryExpressionTest = TestHelper;
TEST_F(BinaryExpressionTest, Creation) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
- BinaryExpression r(BinaryOp::kEqual, lhs, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, lhs, rhs);
EXPECT_EQ(r.lhs(), lhs);
EXPECT_EQ(r.rhs(), rhs);
EXPECT_EQ(r.op(), BinaryOp::kEqual);
}
TEST_F(BinaryExpressionTest, Creation_WithSource) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
BinaryExpression r(Source{Source::Location{20, 2}}, BinaryOp::kEqual, lhs,
rhs);
@@ -47,64 +51,78 @@
}
TEST_F(BinaryExpressionTest, IsBinary) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
- BinaryExpression r(BinaryOp::kEqual, lhs, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, lhs, rhs);
EXPECT_TRUE(r.Is<BinaryExpression>());
}
TEST_F(BinaryExpressionTest, IsValid) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
- BinaryExpression r(BinaryOp::kEqual, lhs, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, lhs, rhs);
EXPECT_TRUE(r.IsValid());
}
TEST_F(BinaryExpressionTest, IsValid_Null_LHS) {
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
- BinaryExpression r(BinaryOp::kEqual, nullptr, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, nullptr, rhs);
EXPECT_FALSE(r.IsValid());
}
TEST_F(BinaryExpressionTest, IsValid_Invalid_LHS) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
- BinaryExpression r(BinaryOp::kEqual, lhs, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, lhs, rhs);
EXPECT_FALSE(r.IsValid());
}
TEST_F(BinaryExpressionTest, IsValid_Null_RHS) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
- BinaryExpression r(BinaryOp::kEqual, lhs, nullptr);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, lhs, nullptr);
EXPECT_FALSE(r.IsValid());
}
TEST_F(BinaryExpressionTest, IsValid_Invalid_RHS) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
- BinaryExpression r(BinaryOp::kEqual, lhs, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, lhs, rhs);
EXPECT_FALSE(r.IsValid());
}
TEST_F(BinaryExpressionTest, IsValid_Binary_None) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
- BinaryExpression r(BinaryOp::kNone, lhs, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kNone, lhs, rhs);
EXPECT_FALSE(r.IsValid());
}
TEST_F(BinaryExpressionTest, ToStr) {
- auto* lhs = create<IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs = create<IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("rhs"), "rhs");
- BinaryExpression r(BinaryOp::kEqual, lhs, rhs);
+ BinaryExpression r(Source{}, BinaryOp::kEqual, lhs, rhs);
std::ostringstream out;
r.to_str(out, 2);
EXPECT_EQ(demangle(out.str()), R"( Binary[not set]{
diff --git a/src/ast/bitcast_expression.cc b/src/ast/bitcast_expression.cc
index aeca953..4dc5eb3 100644
--- a/src/ast/bitcast_expression.cc
+++ b/src/ast/bitcast_expression.cc
@@ -22,9 +22,6 @@
namespace tint {
namespace ast {
-BitcastExpression::BitcastExpression(type::Type* type, Expression* expr)
- : Base(), type_(type), expr_(expr) {}
-
BitcastExpression::BitcastExpression(const Source& source,
type::Type* type,
Expression* expr)
diff --git a/src/ast/bitcast_expression.h b/src/ast/bitcast_expression.h
index b846b73..5ef92b3 100644
--- a/src/ast/bitcast_expression.h
+++ b/src/ast/bitcast_expression.h
@@ -29,10 +29,6 @@
class BitcastExpression : public Castable<BitcastExpression, Expression> {
public:
/// Constructor
- /// @param type the type
- /// @param expr the expr
- BitcastExpression(type::Type* type, Expression* expr);
- /// Constructor
/// @param source the bitcast expression source
/// @param type the type
/// @param expr the expr
diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc
index ebf8ec0..21d8832 100644
--- a/src/ast/bitcast_expression_test.cc
+++ b/src/ast/bitcast_expression_test.cc
@@ -26,16 +26,18 @@
TEST_F(BitcastExpressionTest, Create) {
type::F32 f32;
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
- BitcastExpression exp(&f32, expr);
+ BitcastExpression exp(Source{}, &f32, expr);
ASSERT_EQ(exp.type(), &f32);
ASSERT_EQ(exp.expr(), expr);
}
TEST_F(BitcastExpressionTest, CreateWithSource) {
type::F32 f32;
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
BitcastExpression exp(Source{Source::Location{20, 2}}, &f32, expr);
auto src = exp.source();
@@ -45,46 +47,51 @@
TEST_F(BitcastExpressionTest, IsBitcast) {
type::F32 f32;
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
- BitcastExpression exp(&f32, expr);
+ BitcastExpression exp(Source{}, &f32, expr);
EXPECT_TRUE(exp.Is<BitcastExpression>());
}
TEST_F(BitcastExpressionTest, IsValid) {
type::F32 f32;
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
- BitcastExpression exp(&f32, expr);
+ BitcastExpression exp(Source{}, &f32, expr);
EXPECT_TRUE(exp.IsValid());
}
TEST_F(BitcastExpressionTest, IsValid_MissingType) {
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
- BitcastExpression exp(nullptr, expr);
+ BitcastExpression exp(Source{}, nullptr, expr);
EXPECT_FALSE(exp.IsValid());
}
TEST_F(BitcastExpressionTest, IsValid_MissingExpr) {
type::F32 f32;
- BitcastExpression exp(&f32, nullptr);
+ BitcastExpression exp(Source{}, &f32, nullptr);
EXPECT_FALSE(exp.IsValid());
}
TEST_F(BitcastExpressionTest, IsValid_InvalidExpr) {
type::F32 f32;
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
- BitcastExpression e(&f32, expr);
+ auto* expr =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
+ BitcastExpression e(Source{}, &f32, expr);
EXPECT_FALSE(e.IsValid());
}
TEST_F(BitcastExpressionTest, ToStr) {
type::F32 f32;
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
- BitcastExpression exp(&f32, expr);
+ BitcastExpression exp(Source{}, &f32, expr);
std::ostringstream out;
exp.to_str(out, 2);
diff --git a/src/ast/builder.h b/src/ast/builder.h
index 63e625c..b4c2620 100644
--- a/src/ast/builder.h
+++ b/src/ast/builder.h
@@ -206,37 +206,39 @@
/// @param name the identifier name
/// @return an IdentifierExpression with the given name
IdentifierExpression* Expr(const std::string& name) {
- return create<IdentifierExpression>(mod->RegisterSymbol(name), name);
+ return create<IdentifierExpression>(Source{}, mod->RegisterSymbol(name),
+ name);
}
/// @param name the identifier name
/// @return an IdentifierExpression with the given name
IdentifierExpression* Expr(const char* name) {
- return create<IdentifierExpression>(mod->RegisterSymbol(name), name);
+ return create<IdentifierExpression>(Source{}, mod->RegisterSymbol(name),
+ name);
}
/// @param value the boolean value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(bool value) {
- return create<ScalarConstructorExpression>(Literal(value));
+ return create<ScalarConstructorExpression>(Source{}, Literal(value));
}
/// @param value the float value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(f32 value) {
- return create<ScalarConstructorExpression>(Literal(value));
+ return create<ScalarConstructorExpression>(Source{}, Literal(value));
}
/// @param value the integer value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(i32 value) {
- return create<ScalarConstructorExpression>(Literal(value));
+ return create<ScalarConstructorExpression>(Source{}, Literal(value));
}
/// @param value the unsigned int value
/// @return a Scalar constructor for the given value
ScalarConstructorExpression* Expr(u32 value) {
- return create<ScalarConstructorExpression>(Literal(value));
+ return create<ScalarConstructorExpression>(Source{}, Literal(value));
}
/// Converts `arg` to an `Expression` using `Expr()`, then appends it to
@@ -303,7 +305,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* Construct(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.Of<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.Of<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param type the type to construct
@@ -313,7 +315,7 @@
template <typename... ARGS>
TypeConstructorExpression* Construct(type::Type* type, ARGS&&... args) {
return create<TypeConstructorExpression>(
- type, ExprList(std::forward<ARGS>(args)...));
+ Source{}, type, ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the vector constructor
@@ -322,7 +324,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* vec2(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.vec2<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.vec2<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the vector constructor
@@ -331,7 +333,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* vec3(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.vec3<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.vec3<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the vector constructor
@@ -340,7 +342,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* vec4(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.vec4<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.vec4<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -349,7 +351,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat2x2(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat2x2<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat2x2<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -358,7 +360,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat2x3(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat2x3<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat2x3<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -367,7 +369,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat2x4(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat2x4<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat2x4<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -376,7 +378,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat3x2(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat3x2<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat3x2<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -385,7 +387,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat3x3(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat3x3<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat3x3<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -394,7 +396,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat3x4(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat3x4<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat3x4<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -403,7 +405,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat4x2(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat4x2<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat4x2<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -412,7 +414,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat4x3(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat4x3<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat4x3<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the matrix constructor
@@ -421,7 +423,7 @@
template <typename T, typename... ARGS>
TypeConstructorExpression* mat4x4(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.mat4x4<T>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.mat4x4<T>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param args the arguments for the array constructor
@@ -430,7 +432,7 @@
template <typename T, int N = 0, typename... ARGS>
TypeConstructorExpression* array(ARGS&&... args) {
return create<TypeConstructorExpression>(
- ty.array<T, N>(), ExprList(std::forward<ARGS>(args)...));
+ Source{}, ty.array<T, N>(), ExprList(std::forward<ARGS>(args)...));
}
/// @param name the variable name
@@ -481,7 +483,8 @@
/// arguments of `args` converted to `Expression`s using `Expr()`.
template <typename... ARGS>
CallExpression Call(const std::string& func, ARGS&&... args) {
- return CallExpression{Expr(func), ExprList(std::forward<ARGS>(args)...)};
+ return CallExpression(Source{}, Expr(func),
+ ExprList(std::forward<ARGS>(args)...));
}
/// @param lhs the left hand argument to the addition operation
@@ -489,7 +492,7 @@
/// @returns a `BinaryExpression` summing the arguments `lhs` and `rhs`
template <typename LHS, typename RHS>
Expression* Add(LHS&& lhs, RHS&& rhs) {
- return create<BinaryExpression>(ast::BinaryOp::kAdd,
+ return create<BinaryExpression>(Source{}, ast::BinaryOp::kAdd,
Expr(std::forward<LHS>(lhs)),
Expr(std::forward<RHS>(rhs)));
}
@@ -499,7 +502,7 @@
/// @returns a `BinaryExpression` subtracting `rhs` from `lhs`
template <typename LHS, typename RHS>
Expression* Sub(LHS&& lhs, RHS&& rhs) {
- return create<BinaryExpression>(ast::BinaryOp::kSubtract,
+ return create<BinaryExpression>(Source{}, ast::BinaryOp::kSubtract,
Expr(std::forward<LHS>(lhs)),
Expr(std::forward<RHS>(rhs)));
}
@@ -509,8 +512,8 @@
/// @returns a `ArrayAccessorExpression` that indexes `arr` with `idx`
template <typename ARR, typename IDX>
Expression* Index(ARR&& arr, IDX&& idx) {
- return create<ArrayAccessorExpression>(Expr(std::forward<ARR>(arr)),
- Expr(std::forward<IDX>(idx)));
+ return create<ArrayAccessorExpression>(
+ Source{}, Expr(std::forward<ARR>(arr)), Expr(std::forward<IDX>(idx)));
}
/// Creates a new `Node` owned by the Module. When the Module is
diff --git a/src/ast/call_expression.cc b/src/ast/call_expression.cc
index 17b2acd..5a45fdf 100644
--- a/src/ast/call_expression.cc
+++ b/src/ast/call_expression.cc
@@ -22,9 +22,6 @@
namespace tint {
namespace ast {
-CallExpression::CallExpression(Expression* func, ExpressionList params)
- : Base(), func_(func), params_(params) {}
-
CallExpression::CallExpression(const Source& source,
Expression* func,
ExpressionList params)
diff --git a/src/ast/call_expression.h b/src/ast/call_expression.h
index faa8dcb..c5547e9 100644
--- a/src/ast/call_expression.h
+++ b/src/ast/call_expression.h
@@ -28,10 +28,6 @@
class CallExpression : public Castable<CallExpression, Expression> {
public:
/// Constructor
- /// @param func the function
- /// @param params the parameters
- CallExpression(Expression* func, ExpressionList params);
- /// Constructor
/// @param source the call expression source
/// @param func the function
/// @param params the parameters
diff --git a/src/ast/call_expression_test.cc b/src/ast/call_expression_test.cc
index 4b59395..08e8324 100644
--- a/src/ast/call_expression_test.cc
+++ b/src/ast/call_expression_test.cc
@@ -24,14 +24,15 @@
using CallExpressionTest = TestHelper;
TEST_F(CallExpressionTest, Creation) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
ExpressionList params;
- params.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("param1"), "param1"));
- params.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("param2"), "param2"));
+ params.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
+ params.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
- CallExpression stmt(func, params);
+ CallExpression stmt(Source{}, func, params);
EXPECT_EQ(stmt.func(), func);
const auto& vec = stmt.params();
@@ -41,7 +42,8 @@
}
TEST_F(CallExpressionTest, Creation_WithSource) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
CallExpression stmt(Source{Source::Location{20, 2}}, func, {});
auto src = stmt.source();
EXPECT_EQ(src.range.begin.line, 20u);
@@ -49,57 +51,64 @@
}
TEST_F(CallExpressionTest, IsCall) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
- CallExpression stmt(func, {});
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
+ CallExpression stmt(Source{}, func, {});
EXPECT_TRUE(stmt.Is<CallExpression>());
}
TEST_F(CallExpressionTest, IsValid) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
- CallExpression stmt(func, {});
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
+ CallExpression stmt(Source{}, func, {});
EXPECT_TRUE(stmt.IsValid());
}
TEST_F(CallExpressionTest, IsValid_MissingFunction) {
- CallExpression stmt(nullptr, {});
+ CallExpression stmt(Source{}, nullptr, {});
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(CallExpressionTest, IsValid_NullParam) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
ExpressionList params;
- params.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("param1"), "param1"));
+ params.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(nullptr);
- params.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("param2"), "param2"));
+ params.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
- CallExpression stmt(func, params);
+ CallExpression stmt(Source{}, func, params);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(CallExpressionTest, IsValid_InvalidFunction) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
+ auto* func =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
ExpressionList params;
- params.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("param1"), "param1"));
+ params.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
- CallExpression stmt(func, params);
+ CallExpression stmt(Source{}, func, params);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(CallExpressionTest, IsValid_InvalidParam) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
ExpressionList params;
- params.push_back(create<IdentifierExpression>(mod.RegisterSymbol(""), ""));
+ params.push_back(
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), ""));
- CallExpression stmt(func, params);
+ CallExpression stmt(Source{}, func, params);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(CallExpressionTest, ToStr_NoParams) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
- CallExpression stmt(func, {});
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
+ CallExpression stmt(Source{}, func, {});
std::ostringstream out;
stmt.to_str(out, 2);
EXPECT_EQ(demangle(out.str()), R"( Call[not set]{
@@ -111,14 +120,15 @@
}
TEST_F(CallExpressionTest, ToStr_WithParams) {
- auto* func = create<IdentifierExpression>(mod.RegisterSymbol("func"), "func");
+ auto* func = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("func"), "func");
ExpressionList params;
- params.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("param1"), "param1"));
- params.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("param2"), "param2"));
+ params.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
+ params.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
- CallExpression stmt(func, params);
+ CallExpression stmt(Source{}, func, params);
std::ostringstream out;
stmt.to_str(out, 2);
EXPECT_EQ(demangle(out.str()), R"( Call[not set]{
diff --git a/src/ast/call_statement_test.cc b/src/ast/call_statement_test.cc
index 44f3604..dae79dc 100644
--- a/src/ast/call_statement_test.cc
+++ b/src/ast/call_statement_test.cc
@@ -25,9 +25,11 @@
using CallStatementTest = TestHelper;
TEST_F(CallStatementTest, Creation) {
- auto* expr = create<CallExpression>(
- create<IdentifierExpression>(mod.RegisterSymbol("func"), "func"),
- ExpressionList{});
+ auto* expr =
+ create<CallExpression>(Source{},
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("func"), "func"),
+ ExpressionList{});
CallStatement c(expr);
EXPECT_EQ(c.expr(), expr);
@@ -39,9 +41,11 @@
}
TEST_F(CallStatementTest, IsValid) {
- CallStatement c(create<CallExpression>(
- create<IdentifierExpression>(mod.RegisterSymbol("func"), "func"),
- ExpressionList{}));
+ CallStatement c(
+ create<CallExpression>(Source{},
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("func"), "func"),
+ ExpressionList{}));
EXPECT_TRUE(c.IsValid());
}
@@ -51,15 +55,17 @@
}
TEST_F(CallStatementTest, IsValid_InvalidExpr) {
- CallExpression stmt(nullptr, {});
+ CallExpression stmt(Source{}, nullptr, {});
CallStatement c(&stmt);
EXPECT_FALSE(c.IsValid());
}
TEST_F(CallStatementTest, ToStr) {
- CallStatement c(create<CallExpression>(
- create<IdentifierExpression>(mod.RegisterSymbol("func"), "func"),
- ExpressionList{}));
+ CallStatement c(
+ create<CallExpression>(Source{},
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("func"), "func"),
+ ExpressionList{}));
std::ostringstream out;
c.to_str(out, 2);
diff --git a/src/ast/constructor_expression.cc b/src/ast/constructor_expression.cc
index 74ba721..76d7636 100644
--- a/src/ast/constructor_expression.cc
+++ b/src/ast/constructor_expression.cc
@@ -21,8 +21,6 @@
namespace tint {
namespace ast {
-ConstructorExpression::ConstructorExpression() = default;
-
ConstructorExpression::~ConstructorExpression() = default;
ConstructorExpression::ConstructorExpression(ConstructorExpression&&) = default;
diff --git a/src/ast/constructor_expression.h b/src/ast/constructor_expression.h
index 9e3e9f2..1b1b7bd 100644
--- a/src/ast/constructor_expression.h
+++ b/src/ast/constructor_expression.h
@@ -28,8 +28,6 @@
protected:
/// Constructor
- ConstructorExpression();
- /// Constructor
/// @param source the constructor source
explicit ConstructorExpression(const Source& source);
/// Move constructor
diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc
index 58a75af..633ae86 100644
--- a/src/ast/else_statement_test.cc
+++ b/src/ast/else_statement_test.cc
@@ -30,7 +30,7 @@
TEST_F(ElseStatementTest, Creation) {
type::Bool bool_type;
auto* cond = create<ScalarConstructorExpression>(
- create<BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -57,7 +57,7 @@
TEST_F(ElseStatementTest, HasCondition) {
type::Bool bool_type;
auto* cond = create<ScalarConstructorExpression>(
- create<BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<BoolLiteral>(Source{}, &bool_type, true));
ElseStatement e(cond, create<BlockStatement>());
EXPECT_TRUE(e.HasCondition());
}
@@ -90,7 +90,7 @@
}
TEST_F(ElseStatementTest, IsValid_InvalidCondition) {
- auto* cond = create<ScalarConstructorExpression>(nullptr);
+ auto* cond = create<ScalarConstructorExpression>(Source{}, nullptr);
ElseStatement e(cond, create<BlockStatement>());
EXPECT_FALSE(e.IsValid());
}
@@ -107,7 +107,7 @@
TEST_F(ElseStatementTest, ToStr) {
type::Bool bool_type;
auto* cond = create<ScalarConstructorExpression>(
- create<BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
diff --git a/src/ast/expression.cc b/src/ast/expression.cc
index d92067b..99eb1f9 100644
--- a/src/ast/expression.cc
+++ b/src/ast/expression.cc
@@ -19,8 +19,6 @@
namespace tint {
namespace ast {
-Expression::Expression() = default;
-
Expression::Expression(const Source& source) : Base(source) {}
Expression::Expression(Expression&&) = default;
diff --git a/src/ast/expression.h b/src/ast/expression.h
index 1d0807b..5809d2e 100644
--- a/src/ast/expression.h
+++ b/src/ast/expression.h
@@ -44,8 +44,6 @@
protected:
/// Constructor
- Expression();
- /// Constructor
/// @param source the source of the expression
explicit Expression(const Source& source);
/// Move constructor
diff --git a/src/ast/expression_test.cc b/src/ast/expression_test.cc
index 5fe168c..bf6bb74 100644
--- a/src/ast/expression_test.cc
+++ b/src/ast/expression_test.cc
@@ -24,7 +24,7 @@
class Expr : public Expression {
public:
- Expr() : Expression() {}
+ Expr() : Expression(Source{}) {}
Expr* Clone(CloneContext*) const override { return nullptr; }
bool IsValid() const override { return true; }
diff --git a/src/ast/identifier_expression.cc b/src/ast/identifier_expression.cc
index 04ae344..a38ea3f 100644
--- a/src/ast/identifier_expression.cc
+++ b/src/ast/identifier_expression.cc
@@ -22,9 +22,6 @@
namespace tint {
namespace ast {
-IdentifierExpression::IdentifierExpression(Symbol sym, const std::string& name)
- : Base(), sym_(sym), name_(name) {}
-
IdentifierExpression::IdentifierExpression(const Source& source,
Symbol sym,
const std::string& name)
diff --git a/src/ast/identifier_expression.h b/src/ast/identifier_expression.h
index 9fa2660..40750da 100644
--- a/src/ast/identifier_expression.h
+++ b/src/ast/identifier_expression.h
@@ -30,10 +30,6 @@
class IdentifierExpression : public Castable<IdentifierExpression, Expression> {
public:
/// Constructor
- /// @param sym the symbol for the identifier
- /// @param name the name
- explicit IdentifierExpression(Symbol sym, const std::string& name);
- /// Constructor
/// @param source the source
/// @param sym the symbol for the identifier
/// @param name the name
diff --git a/src/ast/identifier_expression_test.cc b/src/ast/identifier_expression_test.cc
index a81f9cd..70a03bb 100644
--- a/src/ast/identifier_expression_test.cc
+++ b/src/ast/identifier_expression_test.cc
@@ -23,7 +23,7 @@
using IdentifierExpressionTest = TestHelper;
TEST_F(IdentifierExpressionTest, Creation) {
- IdentifierExpression i(mod.RegisterSymbol("ident"), "ident");
+ IdentifierExpression i(Source{}, mod.RegisterSymbol("ident"), "ident");
EXPECT_EQ(i.symbol(), Symbol(1));
EXPECT_EQ(i.name(), "ident");
}
@@ -40,17 +40,17 @@
}
TEST_F(IdentifierExpressionTest, IsIdentifier) {
- IdentifierExpression i(mod.RegisterSymbol("ident"), "ident");
+ IdentifierExpression i(Source{}, mod.RegisterSymbol("ident"), "ident");
EXPECT_TRUE(i.Is<IdentifierExpression>());
}
TEST_F(IdentifierExpressionTest, IsValid) {
- IdentifierExpression i(mod.RegisterSymbol("ident"), "ident");
+ IdentifierExpression i(Source{}, mod.RegisterSymbol("ident"), "ident");
EXPECT_TRUE(i.IsValid());
}
TEST_F(IdentifierExpressionTest, ToStr) {
- IdentifierExpression i(mod.RegisterSymbol("ident"), "ident");
+ IdentifierExpression i(Source{}, mod.RegisterSymbol("ident"), "ident");
std::ostringstream out;
i.to_str(out, 2);
EXPECT_EQ(demangle(out.str()), R"( Identifier[not set]{ident}
diff --git a/src/ast/if_statement_test.cc b/src/ast/if_statement_test.cc
index 3314e9d..b7814e4 100644
--- a/src/ast/if_statement_test.cc
+++ b/src/ast/if_statement_test.cc
@@ -25,7 +25,8 @@
using IfStatementTest = TestHelper;
TEST_F(IfStatementTest, Creation) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -43,7 +44,8 @@
}
TEST_F(IfStatementTest, IsValid) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -52,18 +54,19 @@
}
TEST_F(IfStatementTest, IsValid_WithElseStatements) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
- IfStatement stmt(
- Source{}, cond, body,
- {
- create<ElseStatement>(create<IdentifierExpression>(
- mod.RegisterSymbol("Ident"), "Ident"),
- create<BlockStatement>()),
- create<ElseStatement>(create<BlockStatement>()),
- });
+ IfStatement stmt(Source{}, cond, body,
+ {
+ create<ElseStatement>(
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("Ident"), "Ident"),
+ create<BlockStatement>()),
+ create<ElseStatement>(create<BlockStatement>()),
+ });
EXPECT_TRUE(stmt.IsValid());
}
@@ -76,7 +79,8 @@
}
TEST_F(IfStatementTest, IsValid_InvalidCondition) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
+ auto* cond =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -85,7 +89,8 @@
}
TEST_F(IfStatementTest, IsValid_NullBodyStatement) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
body->append(nullptr);
@@ -95,7 +100,8 @@
}
TEST_F(IfStatementTest, IsValid_InvalidBodyStatement) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
body->append(create<IfStatement>(Source{}, nullptr, create<BlockStatement>(),
@@ -106,7 +112,26 @@
}
TEST_F(IfStatementTest, IsValid_NullElseStatement) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
+ auto* body = create<BlockStatement>();
+ body->append(create<DiscardStatement>());
+
+ IfStatement stmt(Source{}, cond, body,
+ {
+ create<ElseStatement>(
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("Ident"), "Ident"),
+ create<BlockStatement>()),
+ create<ElseStatement>(create<BlockStatement>()),
+ nullptr,
+ });
+ EXPECT_FALSE(stmt.IsValid());
+}
+
+TEST_F(IfStatementTest, IsValid_InvalidElseStatement) {
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -114,30 +139,15 @@
Source{}, cond, body,
{
create<ElseStatement>(create<IdentifierExpression>(
- mod.RegisterSymbol("Ident"), "Ident"),
+ Source{}, mod.RegisterSymbol(""), ""),
create<BlockStatement>()),
- create<ElseStatement>(create<BlockStatement>()),
- nullptr,
});
EXPECT_FALSE(stmt.IsValid());
}
-TEST_F(IfStatementTest, IsValid_InvalidElseStatement) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
- auto* body = create<BlockStatement>();
- body->append(create<DiscardStatement>());
-
- IfStatement stmt(Source{}, cond, body,
- {
- create<ElseStatement>(create<IdentifierExpression>(
- mod.RegisterSymbol(""), ""),
- create<BlockStatement>()),
- });
- EXPECT_FALSE(stmt.IsValid());
-}
-
TEST_F(IfStatementTest, IsValid_MultipleElseWiththoutCondition) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -150,23 +160,25 @@
}
TEST_F(IfStatementTest, IsValid_ElseNotLast) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
- IfStatement stmt(
- Source{}, cond, body,
- {
- create<ElseStatement>(create<BlockStatement>()),
- create<ElseStatement>(create<IdentifierExpression>(
- mod.RegisterSymbol("ident"), "ident"),
- create<BlockStatement>()),
- });
+ IfStatement stmt(Source{}, cond, body,
+ {
+ create<ElseStatement>(create<BlockStatement>()),
+ create<ElseStatement>(
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident"),
+ create<BlockStatement>()),
+ });
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(IfStatementTest, ToStr) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -186,7 +198,8 @@
}
TEST_F(IfStatementTest, ToStr_WithElseStatements) {
- auto* cond = create<IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("cond"), "cond");
auto* body = create<BlockStatement>();
body->append(create<DiscardStatement>());
@@ -197,14 +210,14 @@
else_body->append(create<DiscardStatement>());
else_body->append(create<DiscardStatement>());
- IfStatement stmt(
- Source{}, cond, body,
- {
- create<ElseStatement>(create<IdentifierExpression>(
- mod.RegisterSymbol("ident"), "ident"),
- else_if_body),
- create<ElseStatement>(else_body),
- });
+ IfStatement stmt(Source{}, cond, body,
+ {
+ create<ElseStatement>(
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident"),
+ else_if_body),
+ create<ElseStatement>(else_body),
+ });
std::ostringstream out;
stmt.to_str(out, 2);
diff --git a/src/ast/member_accessor_expression.cc b/src/ast/member_accessor_expression.cc
index 34f8726..6b60b35 100644
--- a/src/ast/member_accessor_expression.cc
+++ b/src/ast/member_accessor_expression.cc
@@ -22,10 +22,6 @@
namespace tint {
namespace ast {
-MemberAccessorExpression::MemberAccessorExpression(Expression* structure,
- IdentifierExpression* member)
- : Base(), struct_(structure), member_(member) {}
-
MemberAccessorExpression::MemberAccessorExpression(const Source& source,
Expression* structure,
IdentifierExpression* member)
diff --git a/src/ast/member_accessor_expression.h b/src/ast/member_accessor_expression.h
index 172c308..982fc66 100644
--- a/src/ast/member_accessor_expression.h
+++ b/src/ast/member_accessor_expression.h
@@ -30,10 +30,6 @@
: public Castable<MemberAccessorExpression, Expression> {
public:
/// Constructor
- /// @param structure the structure
- /// @param member the member
- MemberAccessorExpression(Expression* structure, IdentifierExpression* member);
- /// Constructor
/// @param source the member accessor expression source
/// @param structure the structure
/// @param member the member
diff --git a/src/ast/member_accessor_expression_test.cc b/src/ast/member_accessor_expression_test.cc
index 3985ce1..95a4f91 100644
--- a/src/ast/member_accessor_expression_test.cc
+++ b/src/ast/member_accessor_expression_test.cc
@@ -26,21 +26,21 @@
using MemberAccessorExpressionTest = TestHelper;
TEST_F(MemberAccessorExpressionTest, Creation) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol("structure"),
- "structure");
- auto* mem =
- create<IdentifierExpression>(mod.RegisterSymbol("member"), "member");
+ auto* str = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("structure"), "structure");
+ auto* mem = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("member"), "member");
- MemberAccessorExpression stmt(str, mem);
+ MemberAccessorExpression stmt(Source{}, str, mem);
EXPECT_EQ(stmt.structure(), str);
EXPECT_EQ(stmt.member(), mem);
}
TEST_F(MemberAccessorExpressionTest, Creation_WithSource) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol("structure"),
- "structure");
- auto* mem =
- create<IdentifierExpression>(mod.RegisterSymbol("member"), "member");
+ auto* str = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("structure"), "structure");
+ auto* mem = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("member"), "member");
MemberAccessorExpression stmt(Source{Source::Location{20, 2}}, str, mem);
auto src = stmt.source();
@@ -49,66 +49,68 @@
}
TEST_F(MemberAccessorExpressionTest, IsMemberAccessor) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol("structure"),
- "structure");
- auto* mem =
- create<IdentifierExpression>(mod.RegisterSymbol("member"), "member");
+ auto* str = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("structure"), "structure");
+ auto* mem = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("member"), "member");
- MemberAccessorExpression stmt(str, mem);
+ MemberAccessorExpression stmt(Source{}, str, mem);
EXPECT_TRUE(stmt.Is<MemberAccessorExpression>());
}
TEST_F(MemberAccessorExpressionTest, IsValid) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol("structure"),
- "structure");
- auto* mem =
- create<IdentifierExpression>(mod.RegisterSymbol("member"), "member");
+ auto* str = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("structure"), "structure");
+ auto* mem = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("member"), "member");
- MemberAccessorExpression stmt(str, mem);
+ MemberAccessorExpression stmt(Source{}, str, mem);
EXPECT_TRUE(stmt.IsValid());
}
TEST_F(MemberAccessorExpressionTest, IsValid_NullStruct) {
- auto* mem =
- create<IdentifierExpression>(mod.RegisterSymbol("member"), "member");
+ auto* mem = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("member"), "member");
- MemberAccessorExpression stmt(nullptr, mem);
+ MemberAccessorExpression stmt(Source{}, nullptr, mem);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(MemberAccessorExpressionTest, IsValid_InvalidStruct) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
- auto* mem =
- create<IdentifierExpression>(mod.RegisterSymbol("member"), "member");
+ auto* str =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
+ auto* mem = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("member"), "member");
- MemberAccessorExpression stmt(str, mem);
+ MemberAccessorExpression stmt(Source{}, str, mem);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(MemberAccessorExpressionTest, IsValid_NullMember) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol("structure"),
- "structure");
+ auto* str = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("structure"), "structure");
- MemberAccessorExpression stmt(str, nullptr);
+ MemberAccessorExpression stmt(Source{}, str, nullptr);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(MemberAccessorExpressionTest, IsValid_InvalidMember) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol("structure"),
- "structure");
- auto* mem = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
+ auto* str = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("structure"), "structure");
+ auto* mem =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
- MemberAccessorExpression stmt(str, mem);
+ MemberAccessorExpression stmt(Source{}, str, mem);
EXPECT_FALSE(stmt.IsValid());
}
TEST_F(MemberAccessorExpressionTest, ToStr) {
- auto* str = create<IdentifierExpression>(mod.RegisterSymbol("structure"),
- "structure");
- auto* mem =
- create<IdentifierExpression>(mod.RegisterSymbol("member"), "member");
+ auto* str = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("structure"), "structure");
+ auto* mem = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("member"), "member");
- MemberAccessorExpression stmt(str, mem);
+ MemberAccessorExpression stmt(Source{}, str, mem);
std::ostringstream out;
stmt.to_str(out, 2);
EXPECT_EQ(demangle(out.str()), R"( MemberAccessor[not set]{
diff --git a/src/ast/return_statement_test.cc b/src/ast/return_statement_test.cc
index c7d46b0..221082d 100644
--- a/src/ast/return_statement_test.cc
+++ b/src/ast/return_statement_test.cc
@@ -26,7 +26,8 @@
using ReturnStatementTest = TestHelper;
TEST_F(ReturnStatementTest, Creation) {
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
ReturnStatement r(Source{}, expr);
EXPECT_EQ(r.value(), expr);
@@ -50,7 +51,8 @@
}
TEST_F(ReturnStatementTest, HasValue_WithValue) {
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
ReturnStatement r(Source{}, expr);
EXPECT_TRUE(r.has_value());
}
@@ -61,19 +63,22 @@
}
TEST_F(ReturnStatementTest, IsValid_WithValue) {
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
ReturnStatement r(Source{}, expr);
EXPECT_TRUE(r.IsValid());
}
TEST_F(ReturnStatementTest, IsValid_InvalidValue) {
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
+ auto* expr =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
ReturnStatement r(Source{}, expr);
EXPECT_FALSE(r.IsValid());
}
TEST_F(ReturnStatementTest, ToStr_WithValue) {
- auto* expr = create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<IdentifierExpression>(Source{},
+ mod.RegisterSymbol("expr"), "expr");
ReturnStatement r(Source{}, expr);
std::ostringstream out;
r.to_str(out, 2);
diff --git a/src/ast/scalar_constructor_expression.cc b/src/ast/scalar_constructor_expression.cc
index ba127e8..7a1e5ff 100644
--- a/src/ast/scalar_constructor_expression.cc
+++ b/src/ast/scalar_constructor_expression.cc
@@ -22,9 +22,6 @@
namespace tint {
namespace ast {
-ScalarConstructorExpression::ScalarConstructorExpression(Literal* literal)
- : literal_(literal) {}
-
ScalarConstructorExpression::ScalarConstructorExpression(const Source& source,
Literal* litearl)
: Base(source), literal_(litearl) {}
diff --git a/src/ast/scalar_constructor_expression.h b/src/ast/scalar_constructor_expression.h
index 5a3fd65..ee7e835 100644
--- a/src/ast/scalar_constructor_expression.h
+++ b/src/ast/scalar_constructor_expression.h
@@ -29,9 +29,6 @@
: public Castable<ScalarConstructorExpression, ConstructorExpression> {
public:
/// Constructor
- /// @param literal the const literal
- explicit ScalarConstructorExpression(Literal* literal);
- /// Constructor
/// @param source the constructor source
/// @param literal the const literal
ScalarConstructorExpression(const Source& source, Literal* literal);
diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc
index cdb62f4..4f648c3 100644
--- a/src/ast/scalar_constructor_expression_test.cc
+++ b/src/ast/scalar_constructor_expression_test.cc
@@ -27,7 +27,7 @@
TEST_F(ScalarConstructorExpressionTest, Creation) {
type::Bool bool_type;
auto* b = create<BoolLiteral>(Source{}, &bool_type, true);
- ScalarConstructorExpression c(b);
+ ScalarConstructorExpression c(Source{}, b);
EXPECT_EQ(c.literal(), b);
}
@@ -43,19 +43,19 @@
TEST_F(ScalarConstructorExpressionTest, IsValid) {
type::Bool bool_type;
auto* b = create<BoolLiteral>(Source{}, &bool_type, true);
- ScalarConstructorExpression c(b);
+ ScalarConstructorExpression c(Source{}, b);
EXPECT_TRUE(c.IsValid());
}
TEST_F(ScalarConstructorExpressionTest, IsValid_MissingLiteral) {
- ScalarConstructorExpression c(nullptr);
+ ScalarConstructorExpression c(Source{}, nullptr);
EXPECT_FALSE(c.IsValid());
}
TEST_F(ScalarConstructorExpressionTest, ToStr) {
type::Bool bool_type;
auto* b = create<BoolLiteral>(Source{}, &bool_type, true);
- ScalarConstructorExpression c(b);
+ ScalarConstructorExpression c(Source{}, b);
std::ostringstream out;
c.to_str(out, 2);
EXPECT_EQ(out.str(), R"( ScalarConstructor[not set]{true}
diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc
index 4123237..e0746f0 100644
--- a/src/ast/switch_statement_test.cc
+++ b/src/ast/switch_statement_test.cc
@@ -34,8 +34,8 @@
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(Source{}, &i32, 1));
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
CaseStatementList body;
auto* case_stmt = create<CaseStatement>(lit, create<BlockStatement>());
body.push_back(case_stmt);
@@ -47,8 +47,8 @@
}
TEST_F(SwitchStatementTest, Creation_WithSource) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
SwitchStatement stmt(Source{Source::Location{20, 2}}, ident,
CaseStatementList());
@@ -63,8 +63,8 @@
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
CaseStatementList body;
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
@@ -78,8 +78,8 @@
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
CaseStatementList body;
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
@@ -106,7 +106,8 @@
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
- auto* ident = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
+ auto* ident =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
CaseStatementList body;
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
@@ -120,8 +121,8 @@
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
CaseStatementList body;
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
body.push_back(nullptr);
@@ -131,8 +132,8 @@
}
TEST_F(SwitchStatementTest, IsValid_Invalid_BodyStatement) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
auto* case_body = create<BlockStatement>();
case_body->append(nullptr);
@@ -145,8 +146,8 @@
}
TEST_F(SwitchStatementTest, ToStr_Empty) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
SwitchStatement stmt(ident, {});
std::ostringstream out;
@@ -165,8 +166,8 @@
CaseSelectorList lit;
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
CaseStatementList body;
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
diff --git a/src/ast/type_constructor_expression.cc b/src/ast/type_constructor_expression.cc
index 6710023..e704de0 100644
--- a/src/ast/type_constructor_expression.cc
+++ b/src/ast/type_constructor_expression.cc
@@ -22,10 +22,6 @@
namespace tint {
namespace ast {
-TypeConstructorExpression::TypeConstructorExpression(type::Type* type,
- ExpressionList values)
- : Base(), type_(type), values_(std::move(values)) {}
-
TypeConstructorExpression::TypeConstructorExpression(const Source& source,
type::Type* type,
ExpressionList values)
diff --git a/src/ast/type_constructor_expression.h b/src/ast/type_constructor_expression.h
index 7f239dc..3863adc 100644
--- a/src/ast/type_constructor_expression.h
+++ b/src/ast/type_constructor_expression.h
@@ -29,10 +29,6 @@
: public Castable<TypeConstructorExpression, ConstructorExpression> {
public:
/// Constructor
- /// @param type the type
- /// @param values the values
- TypeConstructorExpression(type::Type* type, ExpressionList values);
- /// Constructor
/// @param source the constructor source
/// @param type the type
/// @param values the constructor values
diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc
index 3fbf937..f40139a 100644
--- a/src/ast/type_constructor_expression_test.cc
+++ b/src/ast/type_constructor_expression_test.cc
@@ -32,10 +32,10 @@
TEST_F(TypeConstructorExpressionTest, Creation) {
type::F32 f32;
ExpressionList expr;
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr"));
- TypeConstructorExpression t(&f32, expr);
+ TypeConstructorExpression t(Source{}, &f32, expr);
EXPECT_EQ(t.type(), &f32);
ASSERT_EQ(t.values().size(), 1u);
EXPECT_EQ(t.values()[0], expr[0]);
@@ -44,8 +44,8 @@
TEST_F(TypeConstructorExpressionTest, Creation_WithSource) {
type::F32 f32;
ExpressionList expr;
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr"));
TypeConstructorExpression t(Source{Source::Location{20, 2}}, &f32, expr);
auto src = t.source();
@@ -56,20 +56,20 @@
TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) {
type::F32 f32;
ExpressionList expr;
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr"));
- TypeConstructorExpression t(&f32, expr);
+ TypeConstructorExpression t(Source{}, &f32, expr);
EXPECT_TRUE(t.Is<TypeConstructorExpression>());
}
TEST_F(TypeConstructorExpressionTest, IsValid) {
type::F32 f32;
ExpressionList expr;
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr"));
- TypeConstructorExpression t(&f32, expr);
+ TypeConstructorExpression t(Source{}, &f32, expr);
EXPECT_TRUE(t.IsValid());
}
@@ -77,36 +77,37 @@
type::F32 f32;
ExpressionList expr;
- TypeConstructorExpression t(&f32, expr);
+ TypeConstructorExpression t(Source{}, &f32, expr);
EXPECT_TRUE(t.IsValid());
}
TEST_F(TypeConstructorExpressionTest, IsValid_NullType) {
ExpressionList expr;
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr"));
- TypeConstructorExpression t(nullptr, expr);
+ TypeConstructorExpression t(Source{}, nullptr, expr);
EXPECT_FALSE(t.IsValid());
}
TEST_F(TypeConstructorExpressionTest, IsValid_NullValue) {
type::F32 f32;
ExpressionList expr;
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr"));
expr.push_back(nullptr);
- TypeConstructorExpression t(&f32, expr);
+ TypeConstructorExpression t(Source{}, &f32, expr);
EXPECT_FALSE(t.IsValid());
}
TEST_F(TypeConstructorExpressionTest, IsValid_InvalidValue) {
type::F32 f32;
ExpressionList expr;
- expr.push_back(create<IdentifierExpression>(mod.RegisterSymbol(""), ""));
+ expr.push_back(
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), ""));
- TypeConstructorExpression t(&f32, expr);
+ TypeConstructorExpression t(Source{}, &f32, expr);
EXPECT_FALSE(t.IsValid());
}
@@ -114,14 +115,14 @@
type::F32 f32;
type::Vector vec(&f32, 3);
ExpressionList expr;
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr_1"), "expr_1"));
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr_2"), "expr_2"));
- expr.push_back(
- create<IdentifierExpression>(mod.RegisterSymbol("expr_3"), "expr_3"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr_1"), "expr_1"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr_2"), "expr_2"));
+ expr.push_back(create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr_3"), "expr_3"));
- TypeConstructorExpression t(&vec, expr);
+ TypeConstructorExpression t(Source{}, &vec, expr);
std::ostringstream out;
t.to_str(out, 2);
EXPECT_EQ(demangle(out.str()), R"( TypeConstructor[not set]{
diff --git a/src/ast/unary_op_expression.cc b/src/ast/unary_op_expression.cc
index 53d1762..a472ff9 100644
--- a/src/ast/unary_op_expression.cc
+++ b/src/ast/unary_op_expression.cc
@@ -22,9 +22,6 @@
namespace tint {
namespace ast {
-UnaryOpExpression::UnaryOpExpression(UnaryOp op, Expression* expr)
- : Base(), op_(op), expr_(expr) {}
-
UnaryOpExpression::UnaryOpExpression(const Source& source,
UnaryOp op,
Expression* expr)
diff --git a/src/ast/unary_op_expression.h b/src/ast/unary_op_expression.h
index 4fbefd5..5ec3dcf 100644
--- a/src/ast/unary_op_expression.h
+++ b/src/ast/unary_op_expression.h
@@ -29,10 +29,6 @@
class UnaryOpExpression : public Castable<UnaryOpExpression, Expression> {
public:
/// Constructor
- /// @param op the op
- /// @param expr the expr
- UnaryOpExpression(UnaryOp op, Expression* expr);
- /// Constructor
/// @param source the unary op expression source
/// @param op the op
/// @param expr the expr
diff --git a/src/ast/unary_op_expression_test.cc b/src/ast/unary_op_expression_test.cc
index 532d8cb..10b45ff 100644
--- a/src/ast/unary_op_expression_test.cc
+++ b/src/ast/unary_op_expression_test.cc
@@ -26,17 +26,17 @@
using UnaryOpExpressionTest = TestHelper;
TEST_F(UnaryOpExpressionTest, Creation) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
- UnaryOpExpression u(UnaryOp::kNot, ident);
+ UnaryOpExpression u(Source{}, UnaryOp::kNot, ident);
EXPECT_EQ(u.op(), UnaryOp::kNot);
EXPECT_EQ(u.expr(), ident);
}
TEST_F(UnaryOpExpressionTest, Creation_WithSource) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
UnaryOpExpression u(Source{Source::Location{20, 2}}, UnaryOp::kNot, ident);
auto src = u.source();
EXPECT_EQ(src.range.begin.line, 20u);
@@ -44,34 +44,35 @@
}
TEST_F(UnaryOpExpressionTest, IsUnaryOp) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
- UnaryOpExpression u(UnaryOp::kNot, ident);
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
+ UnaryOpExpression u(Source{}, UnaryOp::kNot, ident);
EXPECT_TRUE(u.Is<UnaryOpExpression>());
}
TEST_F(UnaryOpExpressionTest, IsValid) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
- UnaryOpExpression u(UnaryOp::kNot, ident);
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
+ UnaryOpExpression u(Source{}, UnaryOp::kNot, ident);
EXPECT_TRUE(u.IsValid());
}
TEST_F(UnaryOpExpressionTest, IsValid_NullExpression) {
- UnaryOpExpression u(UnaryOp::kNot, nullptr);
+ UnaryOpExpression u(Source{}, UnaryOp::kNot, nullptr);
EXPECT_FALSE(u.IsValid());
}
TEST_F(UnaryOpExpressionTest, IsValid_InvalidExpression) {
- auto* ident = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
- UnaryOpExpression u(UnaryOp::kNot, ident);
+ auto* ident =
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), "");
+ UnaryOpExpression u(Source{}, UnaryOp::kNot, ident);
EXPECT_FALSE(u.IsValid());
}
TEST_F(UnaryOpExpressionTest, ToStr) {
- auto* ident =
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
- UnaryOpExpression u(UnaryOp::kNot, ident);
+ auto* ident = create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ident"), "ident");
+ UnaryOpExpression u(Source{}, UnaryOp::kNot, ident);
std::ostringstream out;
u.to_str(out, 2);
EXPECT_EQ(demangle(out.str()), R"( UnaryOp[not set]{
diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc
index ac95d69..5fb2a26 100644
--- a/src/ast/variable_test.cc
+++ b/src/ast/variable_test.cc
@@ -84,7 +84,8 @@
StorageClass::kNone,
&t,
false,
- create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident"),
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol("ident"),
+ "ident"),
ast::VariableDecorationList{}};
EXPECT_TRUE(v.IsValid());
}
@@ -115,7 +116,7 @@
StorageClass::kNone,
&t,
false,
- create<IdentifierExpression>(mod.RegisterSymbol(""), ""),
+ create<IdentifierExpression>(Source{}, mod.RegisterSymbol(""), ""),
ast::VariableDecorationList{}};
EXPECT_FALSE(v.IsValid());
}
@@ -162,13 +163,14 @@
TEST_F(VariableTest, Decorated_to_str) {
type::F32 t;
- auto* var = create<Variable>(
- Source{}, "my_var", StorageClass::kFunction, &t, false,
- create<IdentifierExpression>(mod.RegisterSymbol("expr"), "expr"),
- VariableDecorationList{
- create<BindingDecoration>(2, Source{}),
- create<SetDecoration>(1, Source{}),
- });
+ auto* var =
+ create<Variable>(Source{}, "my_var", StorageClass::kFunction, &t, false,
+ create<IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr"),
+ VariableDecorationList{
+ create<BindingDecoration>(2, Source{}),
+ create<SetDecoration>(1, Source{}),
+ });
std::ostringstream out;
var->to_str(out, 2);
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index 337a705..6600f73 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -99,9 +99,9 @@
ast::FunctionDecorationList decorations = {}) {
auto* body = create<ast::BlockStatement>();
auto* ident_expr = create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(callee), callee);
- auto* call_expr =
- create<ast::CallExpression>(ident_expr, ast::ExpressionList());
+ Source{}, mod()->RegisterSymbol(callee), callee);
+ auto* call_expr = create<ast::CallExpression>(Source{}, ident_expr,
+ ast::ExpressionList());
body->append(create<ast::CallStatement>(call_expr));
body->append(create<ast::ReturnStatement>(Source{}));
return create<ast::Function>(Source{}, mod()->RegisterSymbol(caller),
@@ -153,8 +153,10 @@
std::string in, out;
std::tie(in, out) = inout;
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod()->RegisterSymbol(out), out),
- create<ast::IdentifierExpression>(mod()->RegisterSymbol(in), in)));
+ create<ast::IdentifierExpression>(Source{},
+ mod()->RegisterSymbol(out), out),
+ create<ast::IdentifierExpression>(Source{}, mod()->RegisterSymbol(in),
+ in)));
}
body->append(create<ast::ReturnStatement>(Source{}));
return create<ast::Function>(Source{}, mod()->RegisterSymbol(name), name,
@@ -180,13 +182,15 @@
std::string in, out;
std::tie(in, out) = inout;
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod()->RegisterSymbol(out), out),
- create<ast::IdentifierExpression>(mod()->RegisterSymbol(in), in)));
+ create<ast::IdentifierExpression>(Source{},
+ mod()->RegisterSymbol(out), out),
+ create<ast::IdentifierExpression>(Source{}, mod()->RegisterSymbol(in),
+ in)));
}
auto* ident_expr = create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(callee), callee);
- auto* call_expr =
- create<ast::CallExpression>(ident_expr, ast::ExpressionList());
+ Source{}, mod()->RegisterSymbol(callee), callee);
+ auto* call_expr = create<ast::CallExpression>(Source{}, ident_expr,
+ ast::ExpressionList());
body->append(create<ast::CallStatement>(call_expr));
body->append(create<ast::ReturnStatement>(Source{}));
return create<ast::Function>(Source{}, mod()->RegisterSymbol(caller),
@@ -207,8 +211,8 @@
T* val) {
ast::Expression* constructor = nullptr;
if (val) {
- constructor =
- create<ast::ScalarConstructorExpression>(MakeLiteral(type, val));
+ constructor = create<ast::ScalarConstructorExpression>(
+ Source{}, MakeLiteral(type, val));
}
auto* var = create<ast::Variable>(
Source{}, // source
@@ -445,13 +449,13 @@
std::string member_name = StructMemberName(member_idx, member_type);
body->append(create<ast::AssignmentStatement>(
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("local" + member_name),
+ Source{}, mod()->RegisterSymbol("local" + member_name),
"local" + member_name),
- create<ast::MemberAccessorExpression>(
+ create<ast::MemberAccessorExpression>(Source{},
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(struct_name), struct_name),
+ Source{}, mod()->RegisterSymbol(struct_name), struct_name),
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(member_name), member_name))));
+ Source{}, mod()->RegisterSymbol(member_name), member_name))));
}
body->append(create<ast::ReturnStatement>(Source{}));
@@ -588,19 +592,21 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(texture_name), texture_name));
+ Source{}, mod()->RegisterSymbol(texture_name), texture_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(sampler_name), sampler_name));
+ Source{}, mod()->RegisterSymbol(sampler_name), sampler_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(coords_name), coords_name));
+ Source{}, mod()->RegisterSymbol(coords_name), coords_name));
auto* call_expr = create<ast::CallExpression>(
+ Source{},
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("textureSample"), "textureSample"),
+ Source{}, mod()->RegisterSymbol("textureSample"), "textureSample"),
call_params);
body->append(create<ast::AssignmentStatement>(
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("sampler_result"), "sampler_result"),
+ Source{}, mod()->RegisterSymbol("sampler_result"),
+ "sampler_result"),
call_expr));
body->append(create<ast::ReturnStatement>(Source{}));
@@ -642,21 +648,23 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(texture_name), texture_name));
+ Source{}, mod()->RegisterSymbol(texture_name), texture_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(sampler_name), sampler_name));
+ Source{}, mod()->RegisterSymbol(sampler_name), sampler_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(coords_name), coords_name));
+ Source{}, mod()->RegisterSymbol(coords_name), coords_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(array_index), array_index));
+ Source{}, mod()->RegisterSymbol(array_index), array_index));
auto* call_expr = create<ast::CallExpression>(
+ Source{},
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("textureSample"), "textureSample"),
+ Source{}, mod()->RegisterSymbol("textureSample"), "textureSample"),
call_params);
body->append(create<ast::AssignmentStatement>(
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("sampler_result"), "sampler_result"),
+ Source{}, mod()->RegisterSymbol("sampler_result"),
+ "sampler_result"),
call_expr));
body->append(create<ast::ReturnStatement>(Source{}));
@@ -699,22 +707,24 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(texture_name), texture_name));
+ Source{}, mod()->RegisterSymbol(texture_name), texture_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(sampler_name), sampler_name));
+ Source{}, mod()->RegisterSymbol(sampler_name), sampler_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(coords_name), coords_name));
+ Source{}, mod()->RegisterSymbol(coords_name), coords_name));
call_params.push_back(create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(depth_name), depth_name));
+ Source{}, mod()->RegisterSymbol(depth_name), depth_name));
auto* call_expr = create<ast::CallExpression>(
+ Source{},
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("textureSampleCompare"),
+ Source{}, mod()->RegisterSymbol("textureSampleCompare"),
"textureSampleCompare"),
call_params);
body->append(create<ast::AssignmentStatement>(
create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("sampler_result"), "sampler_result"),
+ Source{}, mod()->RegisterSymbol("sampler_result"),
+ "sampler_result"),
call_expr));
body->append(create<ast::ReturnStatement>(Source{}));
@@ -1538,9 +1548,9 @@
auto AddFuncCall = [&](ast::BlockStatement* body, const std::string& callee) {
auto* ident_expr = create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(callee), callee);
- auto* call_expr =
- create<ast::CallExpression>(ident_expr, ast::ExpressionList());
+ Source{}, mod()->RegisterSymbol(callee), callee);
+ auto* call_expr = create<ast::CallExpression>(Source{}, ident_expr,
+ ast::ExpressionList());
body->append(create<ast::CallStatement>(call_expr));
};
auto* body = create<ast::BlockStatement>();
@@ -1686,9 +1696,9 @@
auto AddFuncCall = [&](ast::BlockStatement* body, const std::string& callee) {
auto* ident_expr = create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(callee), callee);
- auto* call_expr =
- create<ast::CallExpression>(ident_expr, ast::ExpressionList());
+ Source{}, mod()->RegisterSymbol(callee), callee);
+ auto* call_expr = create<ast::CallExpression>(Source{}, ident_expr,
+ ast::ExpressionList());
body->append(create<ast::CallStatement>(call_expr));
};
auto* body = create<ast::BlockStatement>();
@@ -1861,9 +1871,9 @@
auto AddFuncCall = [&](ast::BlockStatement* body, const std::string& callee) {
auto* ident_expr = create<ast::IdentifierExpression>(
- mod()->RegisterSymbol(callee), callee);
- auto* call_expr =
- create<ast::CallExpression>(ident_expr, ast::ExpressionList());
+ Source{}, mod()->RegisterSymbol(callee), callee);
+ auto* call_expr = create<ast::CallExpression>(Source{}, ident_expr,
+ ast::ExpressionList());
body->append(create<ast::CallStatement>(call_expr));
};
auto* body = create<ast::BlockStatement>();
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index 17b9ede..cd2cb54 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -684,7 +684,7 @@
const auto& top = statements_stack_.back();
auto* cond = create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(guard_name), guard_name);
+ Source{}, ast_module_.RegisterSymbol(guard_name), guard_name);
auto* body = create<ast::BlockStatement>();
AddStatement(
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
@@ -1881,8 +1881,8 @@
auto name = namer_.Name(id);
return TypedExpression{
parser_impl_.ConvertType(def_use_mgr_->GetDef(id)->type_id()),
- create<ast::IdentifierExpression>(ast_module_.RegisterSymbol(name),
- name)};
+ create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(name), name)};
}
if (singly_used_values_.count(id)) {
auto expr = std::move(singly_used_values_[id]);
@@ -1902,9 +1902,10 @@
case SpvOpVariable: {
// This occurs for module-scope variables.
auto name = namer_.Name(inst->result_id());
- return TypedExpression{parser_impl_.ConvertType(inst->type_id()),
- create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(name), name)};
+ return TypedExpression{
+ parser_impl_.ConvertType(inst->type_id()),
+ create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(name), name)};
}
default:
break;
@@ -2571,7 +2572,7 @@
// Signal an exit from the branch.
return create<ast::AssignmentStatement>(
create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(flow_guard), flow_guard),
+ Source{}, ast_module_.RegisterSymbol(flow_guard), flow_guard),
MakeFalse(Source{}));
}
@@ -2727,7 +2728,7 @@
auto expr = MakeExpression(assignment.value);
AddStatement(create<ast::AssignmentStatement>(
create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(var_name), var_name),
+ Source{}, ast_module_.RegisterSymbol(var_name), var_name),
expr.expr));
}
}
@@ -2763,8 +2764,8 @@
auto name = namer_.Name(result_id);
// Emit an assignment of the expression to the hoisted variable.
AddStatement(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(ast_module_.RegisterSymbol(name),
- namer_.Name(result_id)),
+ create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(name), namer_.Name(result_id)),
ast_expr.expr));
return true;
}
@@ -2854,10 +2855,11 @@
}
case SpvOpPhi: {
// Emit a read from the associated state variable.
- TypedExpression expr{parser_impl_.ConvertType(inst.type_id()),
- create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(def_info->phi_var),
- def_info->phi_var)};
+ TypedExpression expr{
+ parser_impl_.ConvertType(inst.type_id()),
+ create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(def_info->phi_var),
+ def_info->phi_var)};
return EmitConstDefOrWriteToHoistedVar(inst, expr);
}
case SpvOpFunctionCall:
@@ -2891,8 +2893,8 @@
if (binary_op != ast::BinaryOp::kNone) {
auto arg0 = MakeOperand(inst, 0);
auto arg1 = MakeOperand(inst, 1);
- auto* binary_expr =
- create<ast::BinaryExpression>(binary_op, arg0.expr, arg1.expr);
+ auto* binary_expr = create<ast::BinaryExpression>(Source{}, binary_op,
+ arg0.expr, arg1.expr);
TypedExpression result{ast_type, binary_expr};
return parser_impl_.RectifyForcedResultType(result, inst, arg0.type);
}
@@ -2900,7 +2902,8 @@
auto unary_op = ast::UnaryOp::kNegation;
if (GetUnaryOp(opcode, &unary_op)) {
auto arg0 = MakeOperand(inst, 0);
- auto* unary_expr = create<ast::UnaryOpExpression>(unary_op, arg0.expr);
+ auto* unary_expr =
+ create<ast::UnaryOpExpression>(Source{}, unary_op, arg0.expr);
TypedExpression result{ast_type, unary_expr};
return parser_impl_.RectifyForcedResultType(result, inst, arg0.type);
}
@@ -2909,11 +2912,13 @@
if (unary_builtin_name != nullptr) {
ast::ExpressionList params;
params.emplace_back(MakeOperand(inst, 0).expr);
- return {ast_type, create<ast::CallExpression>(
- create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(unary_builtin_name),
- unary_builtin_name),
- std::move(params))};
+ return {ast_type,
+ create<ast::CallExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(unary_builtin_name),
+ unary_builtin_name),
+ std::move(params))};
}
const auto intrinsic = GetIntrinsic(opcode);
@@ -2927,17 +2932,17 @@
if (opcode == SpvOpBitcast) {
return {ast_type, create<ast::BitcastExpression>(
- ast_type, MakeOperand(inst, 0).expr)};
+ Source{}, ast_type, MakeOperand(inst, 0).expr)};
}
auto negated_op = NegatedFloatCompare(opcode);
if (negated_op != ast::BinaryOp::kNone) {
auto arg0 = MakeOperand(inst, 0);
auto arg1 = MakeOperand(inst, 1);
- auto* binary_expr =
- create<ast::BinaryExpression>(negated_op, arg0.expr, arg1.expr);
- auto* negated_expr =
- create<ast::UnaryOpExpression>(ast::UnaryOp::kNot, binary_expr);
+ auto* binary_expr = create<ast::BinaryExpression>(Source{}, negated_op,
+ arg0.expr, arg1.expr);
+ auto* negated_expr = create<ast::UnaryOpExpression>(
+ Source{}, ast::UnaryOp::kNot, binary_expr);
return {ast_type, negated_expr};
}
@@ -2956,7 +2961,7 @@
operands.emplace_back(MakeOperand(inst, iarg).expr);
}
return {ast_type, create<ast::TypeConstructorExpression>(
- ast_type, std::move(operands))};
+ Source{}, ast_type, std::move(operands))};
}
if (opcode == SpvOpCompositeExtract) {
@@ -3013,8 +3018,8 @@
return {};
}
- auto* func =
- create<ast::IdentifierExpression>(ast_module_.RegisterSymbol(name), name);
+ auto* func = create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(name), name);
ast::ExpressionList operands;
ast::type::Type* first_operand_type = nullptr;
// All parameters to GLSL.std.450 extended instructions are IDs.
@@ -3026,7 +3031,7 @@
operands.emplace_back(operand.expr);
}
auto* ast_type = parser_impl_.ConvertType(inst.type_id());
- auto* call = create<ast::CallExpression>(func, std::move(operands));
+ auto* call = create<ast::CallExpression>(Source{}, func, std::move(operands));
TypedExpression call_expr{ast_type, call};
return parser_impl_.RectifyForcedResultType(call_expr, inst,
first_operand_type);
@@ -3040,20 +3045,20 @@
}
const char* names[] = {"x", "y", "z", "w"};
return create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(names[i & 3]), names[i & 3]);
+ Source{}, ast_module_.RegisterSymbol(names[i & 3]), names[i & 3]);
}
ast::IdentifierExpression* FunctionEmitter::PrefixSwizzle(uint32_t n) {
switch (n) {
case 1:
- return create<ast::IdentifierExpression>(ast_module_.RegisterSymbol("x"),
- "x");
+ return create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol("x"), "x");
case 2:
- return create<ast::IdentifierExpression>(ast_module_.RegisterSymbol("xy"),
- "xy");
+ return create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol("xy"), "xy");
case 3:
return create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol("xyz"), "xyz");
+ Source{}, ast_module_.RegisterSymbol("xyz"), "xyz");
default:
break;
}
@@ -3125,7 +3130,7 @@
auto name = namer_.Name(base_id);
current_expr.expr = create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name), name);
current_expr.type = parser_impl_.ConvertType(ptr_ty_id);
}
}
@@ -3174,11 +3179,11 @@
<< " is too big. Max handled index is " << kMaxVectorLen - 1;
}
next_expr = create<ast::MemberAccessorExpression>(
- current_expr.expr, Swizzle(uint32_t(index_const_val)));
+ Source{}, current_expr.expr, Swizzle(uint32_t(index_const_val)));
} else {
// Non-constant index. Use array syntax
next_expr = create<ast::ArrayAccessorExpression>(
- current_expr.expr, MakeOperand(inst, index).expr);
+ Source{}, current_expr.expr, MakeOperand(inst, index).expr);
}
// All vector components are the same type.
pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0);
@@ -3186,18 +3191,18 @@
case SpvOpTypeMatrix:
// Use array syntax.
next_expr = create<ast::ArrayAccessorExpression>(
- current_expr.expr, MakeOperand(inst, index).expr);
+ Source{}, current_expr.expr, MakeOperand(inst, index).expr);
// All matrix components are the same type.
pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0);
break;
case SpvOpTypeArray:
next_expr = create<ast::ArrayAccessorExpression>(
- current_expr.expr, MakeOperand(inst, index).expr);
+ Source{}, current_expr.expr, MakeOperand(inst, index).expr);
pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0);
break;
case SpvOpTypeRuntimeArray:
next_expr = create<ast::ArrayAccessorExpression>(
- current_expr.expr, MakeOperand(inst, index).expr);
+ Source{}, current_expr.expr, MakeOperand(inst, index).expr);
pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0);
break;
case SpvOpTypeStruct: {
@@ -3218,10 +3223,10 @@
auto name =
namer_.GetMemberName(pointee_type_id, uint32_t(index_const_val));
auto* member_access = create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name), name);
- next_expr = create<ast::MemberAccessorExpression>(current_expr.expr,
- member_access);
+ next_expr = create<ast::MemberAccessorExpression>(
+ Source{}, current_expr.expr, member_access);
pointee_type_id = pointee_type_inst->GetSingleWordInOperand(
static_cast<uint32_t>(index_const_val));
break;
@@ -3251,12 +3256,13 @@
// this as ever-deeper nested indexing expressions. Start off with an
// expression for the composite, and then bury that inside nested indexing
// expressions.
+ auto source = GetSourceForInst(inst);
TypedExpression current_expr(MakeOperand(inst, 0));
- auto make_index = [this](uint32_t literal) {
+ auto make_index = [this, source](uint32_t literal) {
auto* type = create<ast::type::U32>();
return create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, type, literal));
+ source, create<ast::UintLiteral>(source, type, literal));
};
const auto composite = inst.GetSingleWordInOperand(0);
@@ -3291,8 +3297,8 @@
Fail() << "internal error: swizzle index " << index_val
<< " is too big. Max handled index is " << kMaxVectorLen - 1;
}
- next_expr = create<ast::MemberAccessorExpression>(current_expr.expr,
- Swizzle(index_val));
+ next_expr = create<ast::MemberAccessorExpression>(
+ Source{}, current_expr.expr, Swizzle(index_val));
// All vector components are the same type.
current_type_id = current_type_inst->GetSingleWordInOperand(0);
break;
@@ -3311,8 +3317,8 @@
<< " is too big. Max handled index is " << kMaxVectorLen - 1;
}
// Use array syntax.
- next_expr = create<ast::ArrayAccessorExpression>(current_expr.expr,
- make_index(index_val));
+ next_expr = create<ast::ArrayAccessorExpression>(
+ Source{}, current_expr.expr, make_index(index_val));
// All matrix components are the same type.
current_type_id = current_type_inst->GetSingleWordInOperand(0);
break;
@@ -3321,8 +3327,8 @@
// The array size could be a spec constant, and so it's not always
// statically checkable. Instead, rely on a runtime index clamp
// or runtime check to keep this safe.
- next_expr = create<ast::ArrayAccessorExpression>(current_expr.expr,
- make_index(index_val));
+ next_expr = create<ast::ArrayAccessorExpression>(
+ Source{}, current_expr.expr, make_index(index_val));
current_type_id = current_type_inst->GetSingleWordInOperand(0);
break;
case SpvOpTypeRuntimeArray:
@@ -3338,10 +3344,10 @@
}
auto name = namer_.GetMemberName(current_type_id, uint32_t(index_val));
auto* member_access = create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(name), name);
+ Source{}, ast_module_.RegisterSymbol(name), name);
- next_expr = create<ast::MemberAccessorExpression>(current_expr.expr,
- member_access);
+ next_expr = create<ast::MemberAccessorExpression>(
+ Source{}, current_expr.expr, member_access);
current_type_id = current_type_inst->GetSingleWordInOperand(index_val);
break;
}
@@ -3358,13 +3364,13 @@
ast::Expression* FunctionEmitter::MakeTrue(const Source& source) const {
return create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(source, parser_impl_.Bool(), true));
+ source, create<ast::BoolLiteral>(source, parser_impl_.Bool(), true));
}
ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const {
ast::type::Bool bool_type;
return create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
+ source, create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
}
TypedExpression FunctionEmitter::MakeVectorShuffle(
@@ -3382,6 +3388,7 @@
// Generate an ast::TypeConstructor expression.
// Assume the literal indices are valid, and there is a valid number of them.
+ auto source = GetSourceForInst(inst);
ast::type::Vector* result_type =
parser_impl_.ConvertType(inst.type_id())->As<ast::type::Vector>();
ast::ExpressionList values;
@@ -3389,12 +3396,12 @@
const auto index = inst.GetSingleWordInOperand(i);
if (index < vec0_len) {
values.emplace_back(create<ast::MemberAccessorExpression>(
- MakeExpression(vec0_id).expr, Swizzle(index)));
+ source, MakeExpression(vec0_id).expr, Swizzle(index)));
} else if (index < vec0_len + vec1_len) {
const auto sub_index = index - vec0_len;
assert(sub_index < kMaxVectorLen);
values.emplace_back(create<ast::MemberAccessorExpression>(
- MakeExpression(vec1_id).expr, Swizzle(sub_index)));
+ source, MakeExpression(vec1_id).expr, Swizzle(sub_index)));
} else if (index == 0xFFFFFFFF) {
// By rule, this maps to OpUndef. Instead, make it zero.
values.emplace_back(parser_impl_.MakeNullValue(result_type->type()));
@@ -3405,7 +3412,7 @@
}
}
return {result_type,
- create<ast::TypeConstructorExpression>(result_type, values)};
+ create<ast::TypeConstructorExpression>(source, result_type, values)};
}
bool FunctionEmitter::RegisterLocallyDefinedValues() {
@@ -3706,27 +3713,29 @@
ast::ExpressionList params;
params.push_back(arg_expr.expr);
- TypedExpression result{expr_type, create<ast::TypeConstructorExpression>(
- expr_type, std::move(params))};
+ TypedExpression result{
+ expr_type, create<ast::TypeConstructorExpression>(Source{}, expr_type,
+ std::move(params))};
if (requested_type == expr_type) {
return result;
}
- return {requested_type,
- create<ast::BitcastExpression>(requested_type, result.expr)};
+ return {requested_type, create<ast::BitcastExpression>(
+ Source{}, requested_type, result.expr)};
}
bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) {
// We ignore function attributes such as Inline, DontInline, Pure, Const.
auto name = namer_.Name(inst.GetSingleWordInOperand(0));
- auto* function =
- create<ast::IdentifierExpression>(ast_module_.RegisterSymbol(name), name);
+ auto* function = create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(name), name);
ast::ExpressionList params;
for (uint32_t iarg = 1; iarg < inst.NumInOperands(); ++iarg) {
params.emplace_back(MakeOperand(inst, iarg).expr);
}
- auto* call_expr = create<ast::CallExpression>(function, std::move(params));
+ auto* call_expr =
+ create<ast::CallExpression>(Source{}, function, std::move(params));
auto* result_type = parser_impl_.ConvertType(inst.type_id());
if (!result_type) {
return Fail() << "internal error: no mapped type result of call: "
@@ -3746,8 +3755,8 @@
std::ostringstream ss;
ss << intrinsic;
auto name = ss.str();
- auto* ident =
- create<ast::IdentifierExpression>(ast_module_.RegisterSymbol(name), name);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, ast_module_.RegisterSymbol(name), name);
ident->set_intrinsic(intrinsic);
ast::ExpressionList params;
@@ -3759,7 +3768,8 @@
}
params.emplace_back(operand.expr);
}
- auto* call_expr = create<ast::CallExpression>(ident, std::move(params));
+ auto* call_expr =
+ create<ast::CallExpression>(Source{}, ident, std::move(params));
auto* result_type = parser_impl_.ConvertType(inst.type_id());
if (!result_type) {
Fail() << "internal error: no mapped type result of call: "
@@ -3790,9 +3800,9 @@
// The condition goes last.
params.push_back(condition.expr);
return {operand1.type,
- create<ast::CallExpression>(
+ create<ast::CallExpression>(Source{},
create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol("select"), "select"),
+ Source{}, ast_module_.RegisterSymbol("select"), "select"),
std::move(params))};
}
return {};
@@ -3818,7 +3828,7 @@
}
auto name = namer_.Name(image->result_id());
params.push_back(create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(name), name));
+ Source{}, ast_module_.RegisterSymbol(name), name));
if (IsSampledImageAccess(inst.opcode())) {
// Form the sampler operand.
@@ -3830,7 +3840,7 @@
}
auto param_name = namer_.Name(sampler->result_id());
params.push_back(create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(param_name), param_name));
+ Source{}, ast_module_.RegisterSymbol(param_name), param_name));
}
ast::type::Pointer* texture_ptr_type =
@@ -3937,7 +3947,7 @@
if (texture_type->Is<ast::type::DepthTexture>()) {
// Convert it to a signed integer type.
lod_operand = create<ast::TypeConstructorExpression>(
- create<ast::type::I32>(), ast::ExpressionList{lod_operand});
+ Source{}, create<ast::type::I32>(), ast::ExpressionList{lod_operand});
}
params.push_back(lod_operand);
image_operands_mask ^= SpvImageOperandsLodMask;
@@ -3970,8 +3980,9 @@
}
auto* ident = create<ast::IdentifierExpression>(
- ast_module_.RegisterSymbol(builtin_name), builtin_name);
- auto* call_expr = create<ast::CallExpression>(ident, std::move(params));
+ Source{}, ast_module_.RegisterSymbol(builtin_name), builtin_name);
+ auto* call_expr =
+ create<ast::CallExpression>(Source{}, ident, std::move(params));
if (inst.type_id() != 0) {
// It returns a value.
@@ -3996,7 +4007,7 @@
if (expected_component_type != result_component_type) {
// This occurs if one is signed integer and the other is unsigned integer,
// or vice versa. Perform a bitcast.
- value = create<ast::BitcastExpression>(result_type, call_expr);
+ value = create<ast::BitcastExpression>(Source{}, result_type, call_expr);
}
EmitConstDefOrWriteToHoistedVar(inst, {result_type, value});
@@ -4112,14 +4123,14 @@
// array component. Use a vector swizzle to get the first `num_axes`
// components.
result.push_back(create<ast::MemberAccessorExpression>(
- raw_coords.expr, PrefixSwizzle(num_axes)));
+ Source{}, raw_coords.expr, PrefixSwizzle(num_axes)));
// Now get the array index.
ast::Expression* array_index = create<ast::MemberAccessorExpression>(
- raw_coords.expr, Swizzle(num_axes));
+ Source{}, raw_coords.expr, Swizzle(num_axes));
// Convert it to a signed integer type.
result.push_back(create<ast::TypeConstructorExpression>(
- create<ast::type::I32>(), ast::ExpressionList{array_index}));
+ Source{}, create<ast::type::I32>(), ast::ExpressionList{array_index}));
} else {
if (num_coords_supplied == num_coords_required) {
// Pass the value through.
@@ -4128,7 +4139,7 @@
// There are more coordinates supplied than needed. So the source type is
// a vector. Use a vector swizzle to get the first `num_axes` components.
result.push_back(create<ast::MemberAccessorExpression>(
- raw_coords.expr, PrefixSwizzle(num_axes)));
+ Source{}, raw_coords.expr, PrefixSwizzle(num_axes)));
}
}
return result;
@@ -4173,7 +4184,7 @@
// higher-numbered components.
auto* texel_prefix = (src_count == dest_count)
? texel.expr
- : create<ast::MemberAccessorExpression>(
+ : create<ast::MemberAccessorExpression>(Source{},
texel.expr, PrefixSwizzle(dest_count));
if (!(dest_type->is_float_scalar_or_vector() ||
@@ -4216,7 +4227,7 @@
return texel_prefix;
}
// We must do a bitcast conversion.
- return create<ast::BitcastExpression>(dest_type, texel_prefix);
+ return create<ast::BitcastExpression>(Source{}, dest_type, texel_prefix);
}
TypedExpression FunctionEmitter::ToI32(TypedExpression value) {
@@ -4224,7 +4235,7 @@
return value;
}
return {i32_, create<ast::TypeConstructorExpression>(
- i32_, ast::ExpressionList{value.expr})};
+ Source{}, i32_, ast::ExpressionList{value.expr})};
}
FunctionEmitter::FunctionDeclaration::FunctionDeclaration() = default;
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index 9ef2d36..f7e2c31 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -1031,27 +1031,31 @@
case SpvOpSpecConstantTrue:
case SpvOpSpecConstantFalse: {
ast_type = ConvertType(inst.type_id());
- ast_expr =
- create<ast::ScalarConstructorExpression>(create<ast::BoolLiteral>(
- Source{}, ast_type, inst.opcode() == SpvOpSpecConstantTrue));
+ ast_expr = create<ast::ScalarConstructorExpression>(
+ Source{},
+ create<ast::BoolLiteral>(Source{}, ast_type,
+ inst.opcode() == SpvOpSpecConstantTrue));
break;
}
case SpvOpSpecConstant: {
ast_type = ConvertType(inst.type_id());
const uint32_t literal_value = inst.GetSingleWordInOperand(0);
if (ast_type->Is<ast::type::I32>()) {
- ast_expr =
- create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
- Source{}, ast_type, static_cast<int32_t>(literal_value)));
+ ast_expr = create<ast::ScalarConstructorExpression>(
+ Source{},
+ create<ast::SintLiteral>(Source{}, ast_type,
+ static_cast<int32_t>(literal_value)));
} else if (ast_type->Is<ast::type::U32>()) {
- ast_expr =
- create<ast::ScalarConstructorExpression>(create<ast::UintLiteral>(
- Source{}, ast_type, static_cast<uint32_t>(literal_value)));
+ ast_expr = create<ast::ScalarConstructorExpression>(
+ Source{},
+ create<ast::UintLiteral>(Source{}, ast_type,
+ static_cast<uint32_t>(literal_value)));
} else if (ast_type->Is<ast::type::F32>()) {
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<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, ast_type, float_value));
} else {
return Fail() << " invalid result type for OpSpecConstant "
@@ -1323,25 +1327,29 @@
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
if (ast_type->Is<ast::type::U32>()) {
return {ast_type,
- create<ast::ScalarConstructorExpression>(create<ast::UintLiteral>(
- source, ast_type, spirv_const->GetU32()))};
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(source, ast_type,
+ spirv_const->GetU32()))};
}
if (ast_type->Is<ast::type::I32>()) {
return {ast_type,
- create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
- source, ast_type, spirv_const->GetS32()))};
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(source, ast_type,
+ spirv_const->GetS32()))};
}
if (ast_type->Is<ast::type::F32>()) {
return {ast_type,
- create<ast::ScalarConstructorExpression>(create<ast::FloatLiteral>(
- source, ast_type, spirv_const->GetFloat()))};
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(source, ast_type,
+ spirv_const->GetFloat()))};
}
if (ast_type->Is<ast::type::Bool>()) {
const bool value = spirv_const->AsNullConstant()
? false
: spirv_const->AsBoolConstant()->value();
- return {ast_type, create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(source, ast_type, value))};
+ return {ast_type,
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::BoolLiteral>(source, ast_type, value))};
}
auto* spirv_composite_const = spirv_const->AsCompositeConstant();
if (spirv_composite_const != nullptr) {
@@ -1367,7 +1375,7 @@
ast_components.emplace_back(ast_component.expr);
}
return {original_ast_type,
- create<ast::TypeConstructorExpression>(original_ast_type,
+ create<ast::TypeConstructorExpression>(Source{}, original_ast_type,
std::move(ast_components))};
}
auto* spirv_null_const = spirv_const->AsNullConstant();
@@ -1395,26 +1403,26 @@
if (type->Is<ast::type::Bool>()) {
return create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, type, false));
+ Source{}, create<ast::BoolLiteral>(Source{}, type, false));
}
if (type->Is<ast::type::U32>()) {
return create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, type, 0u));
+ Source{}, create<ast::UintLiteral>(Source{}, type, 0u));
}
if (type->Is<ast::type::I32>()) {
return create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, type, 0));
+ Source{}, create<ast::SintLiteral>(Source{}, type, 0));
}
if (type->Is<ast::type::F32>()) {
return create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, type, 0.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, type, 0.0f));
}
if (const auto* vec_ty = type->As<ast::type::Vector>()) {
ast::ExpressionList ast_components;
for (size_t i = 0; i < vec_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(vec_ty->type()));
}
- return create<ast::TypeConstructorExpression>(type,
+ return create<ast::TypeConstructorExpression>(Source{}, type,
std::move(ast_components));
}
if (const auto* mat_ty = type->As<ast::type::Matrix>()) {
@@ -1425,7 +1433,7 @@
for (size_t i = 0; i < mat_ty->columns(); ++i) {
ast_components.emplace_back(MakeNullValue(column_ty));
}
- return create<ast::TypeConstructorExpression>(type,
+ return create<ast::TypeConstructorExpression>(Source{}, type,
std::move(ast_components));
}
if (auto* arr_ty = type->As<ast::type::Array>()) {
@@ -1433,7 +1441,7 @@
for (size_t i = 0; i < arr_ty->size(); ++i) {
ast_components.emplace_back(MakeNullValue(arr_ty->type()));
}
- return create<ast::TypeConstructorExpression>(original_type,
+ return create<ast::TypeConstructorExpression>(Source{}, original_type,
std::move(ast_components));
}
if (auto* struct_ty = type->As<ast::type::Struct>()) {
@@ -1441,7 +1449,7 @@
for (auto* member : struct_ty->impl()->members()) {
ast_components.emplace_back(MakeNullValue(member->type()));
}
- return create<ast::TypeConstructorExpression>(original_type,
+ return create<ast::TypeConstructorExpression>(Source{}, original_type,
std::move(ast_components));
}
Fail() << "can't make null value for type: " << type->type_name();
@@ -1481,13 +1489,14 @@
if (unsigned_ty != nullptr) {
// Conversion is required.
return {unsigned_ty,
- create<ast::BitcastExpression>(unsigned_ty, expr.expr)};
+ create<ast::BitcastExpression>(Source{}, unsigned_ty, expr.expr)};
}
} else if (requires_signed) {
auto* signed_ty = signed_type_for_[type];
if (signed_ty != nullptr) {
// Conversion is required.
- return {signed_ty, create<ast::BitcastExpression>(signed_ty, expr.expr)};
+ return {signed_ty,
+ create<ast::BitcastExpression>(Source{}, signed_ty, expr.expr)};
}
}
// We should not reach here.
@@ -1555,7 +1564,8 @@
if ((forced_result_ty == nullptr) || (forced_result_ty == expr.type)) {
return expr;
}
- return {expr.type, create<ast::BitcastExpression>(expr.type, expr.expr)};
+ return {expr.type,
+ create<ast::BitcastExpression>(Source{}, expr.type, expr.expr)};
}
bool ParserImpl::EmitFunctions() {
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 8098051..7061875 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -2028,7 +2028,8 @@
return create<ast::CallStatement>(create<ast::CallExpression>(
source,
- create<ast::IdentifierExpression>(module_.RegisterSymbol(name), name),
+ create<ast::IdentifierExpression>(Source{}, module_.RegisterSymbol(name),
+ name),
std::move(params)));
}
diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc
index a5b53f2..d68da7c 100644
--- a/src/transform/bound_array_accessors.cc
+++ b/src/transform/bound_array_accessors.cc
@@ -131,22 +131,23 @@
cast_expr.push_back(ctx->Clone(expr->idx_expr()));
ast::ExpressionList params;
- params.push_back(
- ctx->mod->create<ast::TypeConstructorExpression>(u32, cast_expr));
+ params.push_back(ctx->mod->create<ast::TypeConstructorExpression>(
+ Source{}, u32, cast_expr));
params.push_back(ctx->mod->create<ast::ScalarConstructorExpression>(
- ctx->mod->create<ast::UintLiteral>(Source{}, u32, size - 1)));
+ Source{}, ctx->mod->create<ast::UintLiteral>(Source{}, u32, size - 1)));
auto* call_expr = ctx->mod->create<ast::CallExpression>(
+ Source{},
ctx->mod->create<ast::IdentifierExpression>(
- ctx->mod->RegisterSymbol("min"), "min"),
+ Source{}, ctx->mod->RegisterSymbol("min"), "min"),
std::move(params));
call_expr->set_result_type(u32);
idx_expr = call_expr;
}
- auto* arr = ctx->Clone(expr->array());
- return ctx->mod->create<ast::ArrayAccessorExpression>(arr, idx_expr);
+ return ctx->mod->create<ast::ArrayAccessorExpression>(
+ ctx->Clone(expr->source()), ctx->Clone(expr->array()), idx_expr);
}
} // namespace transform
diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc
index ac07d6f..14d79e2 100644
--- a/src/transform/emit_vertex_point_size.cc
+++ b/src/transform/emit_vertex_point_size.cc
@@ -65,7 +65,7 @@
mod->AddGlobalVariable(pointsize_var);
// Build the AST expression & statement for assigning pointsize one.
- auto* one = mod->create<ast::ScalarConstructorExpression>(
+ auto* one = mod->create<ast::ScalarConstructorExpression>(Source{},
mod->create<ast::FloatLiteral>(Source{}, f32, 1.0f));
auto* pointsize_ident = mod->create<ast::IdentifierExpression>(
Source{}, mod->RegisterSymbol(kPointSizeVar), kPointSizeVar);
diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc
index ee75a77..5f1e026 100644
--- a/src/transform/first_index_offset.cc
+++ b/src/transform/first_index_offset.cc
@@ -252,15 +252,16 @@
ast::Variable* buffer_var,
ast::Module* mod) {
auto* buffer = mod->create<ast::IdentifierExpression>(
- mod->RegisterSymbol(buffer_var->name()), buffer_var->name());
+ Source{}, mod->RegisterSymbol(buffer_var->name()), buffer_var->name());
auto* constructor = mod->create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd,
+ Source{}, ast::BinaryOp::kAdd,
mod->create<ast::IdentifierExpression>(
- mod->RegisterSymbol(kIndexOffsetPrefix + original_name),
+ Source{}, mod->RegisterSymbol(kIndexOffsetPrefix + original_name),
kIndexOffsetPrefix + original_name),
mod->create<ast::MemberAccessorExpression>(
- buffer, mod->create<ast::IdentifierExpression>(
- mod->RegisterSymbol(field_name), field_name)));
+ Source{}, buffer,
+ mod->create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(field_name), field_name)));
auto* var =
mod->create<ast::Variable>(Source{}, // source
original_name, // name
diff --git a/src/transform/first_index_offset_test.cc b/src/transform/first_index_offset_test.cc
index 3813819..0ac7cfc 100644
--- a/src/transform/first_index_offset_test.cc
+++ b/src/transform/first_index_offset_test.cc
@@ -74,8 +74,9 @@
void Build() override {
AddBuiltinInput("vert_idx", ast::Builtin::kVertexIdx);
AddFunction("test")->body()->append(create<ast::ReturnStatement>(
- Source{}, create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vert_idx"), "vert_idx")));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("vert_idx"), "vert_idx")));
}
};
@@ -116,8 +117,9 @@
void Build() override {
AddBuiltinInput("vert_idx", ast::Builtin::kVertexIdx);
AddFunction("test")->body()->append(create<ast::ReturnStatement>(
- Source{}, create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vert_idx"), "vert_idx")));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("vert_idx"), "vert_idx")));
}
};
@@ -193,8 +195,9 @@
void Build() override {
AddBuiltinInput("inst_idx", ast::Builtin::kInstanceIdx);
AddFunction("test")->body()->append(create<ast::ReturnStatement>(
- Source{}, create<ast::IdentifierExpression>(
- mod->RegisterSymbol("inst_idx"), "inst_idx")));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("inst_idx"), "inst_idx")));
}
};
@@ -347,13 +350,15 @@
AddBuiltinInput("vert_idx", ast::Builtin::kVertexIdx);
ast::Function* func1 = AddFunction("func1");
func1->body()->append(create<ast::ReturnStatement>(
- Source{}, create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vert_idx"), "vert_idx")));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("vert_idx"), "vert_idx")));
ast::Function* func2 = AddFunction("func2");
func2->body()->append(create<ast::ReturnStatement>(
Source{}, create<ast::CallExpression>(
+ Source{},
create<ast::IdentifierExpression>(
- mod->RegisterSymbol("func1"), "func1"),
+ Source{}, mod->RegisterSymbol("func1"), "func1"),
ast::ExpressionList{})));
}
};
diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc
index 8fa3949..96f7588 100644
--- a/src/transform/vertex_pulling.cc
+++ b/src/transform/vertex_pulling.cc
@@ -326,13 +326,13 @@
: instance_index_name;
// Identifier to index by
auto* index_identifier = mod->create<ast::IdentifierExpression>(
- mod->RegisterSymbol(name), name);
+ Source{}, mod->RegisterSymbol(name), name);
// An expression for the start of the read in the buffer in bytes
auto* pos_value = mod->create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd,
+ Source{}, ast::BinaryOp::kAdd,
mod->create<ast::BinaryExpression>(
- ast::BinaryOp::kMultiply, index_identifier,
+ Source{}, ast::BinaryOp::kMultiply, index_identifier,
GenUint(static_cast<uint32_t>(buffer_layout.array_stride))),
GenUint(static_cast<uint32_t>(attribute_desc.offset)));
@@ -342,8 +342,8 @@
block->append(set_pos_expr);
block->append(mod->create<ast::AssignmentStatement>(
- mod->create<ast::IdentifierExpression>(mod->RegisterSymbol(v->name()),
- v->name()),
+ mod->create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(v->name()), v->name()),
AccessByFormat(i, attribute_desc.format)));
}
}
@@ -353,12 +353,12 @@
ast::Expression* VertexPulling::State::GenUint(uint32_t value) {
return mod->create<ast::ScalarConstructorExpression>(
- mod->create<ast::UintLiteral>(Source{}, GetU32Type(), value));
+ Source{}, mod->create<ast::UintLiteral>(Source{}, GetU32Type(), value));
}
ast::Expression* VertexPulling::State::CreatePullingPositionIdent() {
return mod->create<ast::IdentifierExpression>(
- mod->RegisterSymbol(kPullingPosVarName), kPullingPosVarName);
+ Source{}, mod->RegisterSymbol(kPullingPosVarName), kPullingPosVarName);
}
ast::Expression* VertexPulling::State::AccessByFormat(uint32_t buffer,
@@ -397,26 +397,29 @@
// base case.
auto vbuf_name = GetVertexBufferName(buffer);
return mod->create<ast::ArrayAccessorExpression>(
+ Source{},
mod->create<ast::MemberAccessorExpression>(
- mod->create<ast::IdentifierExpression>(mod->RegisterSymbol(vbuf_name),
- vbuf_name),
+ Source{},
mod->create<ast::IdentifierExpression>(
- mod->RegisterSymbol(kStructBufferName), kStructBufferName)),
- mod->create<ast::BinaryExpression>(ast::BinaryOp::kDivide, pos,
+ Source{}, mod->RegisterSymbol(vbuf_name), vbuf_name),
+ mod->create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(kStructBufferName),
+ kStructBufferName)),
+ mod->create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kDivide, pos,
GenUint(4)));
}
ast::Expression* VertexPulling::State::AccessI32(uint32_t buffer,
ast::Expression* pos) {
// as<T> reinterprets bits
- return mod->create<ast::BitcastExpression>(GetI32Type(),
+ return mod->create<ast::BitcastExpression>(Source{}, GetI32Type(),
AccessU32(buffer, pos));
}
ast::Expression* VertexPulling::State::AccessF32(uint32_t buffer,
ast::Expression* pos) {
// as<T> reinterprets bits
- return mod->create<ast::BitcastExpression>(GetF32Type(),
+ return mod->create<ast::BitcastExpression>(Source{}, GetF32Type(),
AccessU32(buffer, pos));
}
@@ -448,13 +451,14 @@
for (uint32_t i = 0; i < count; ++i) {
// Offset read position by element_stride for each component
auto* cur_pos = mod->create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd, CreatePullingPositionIdent(),
+ Source{}, ast::BinaryOp::kAdd, CreatePullingPositionIdent(),
GenUint(element_stride * i));
expr_list.push_back(AccessPrimitive(buffer, cur_pos, base_format));
}
return mod->create<ast::TypeConstructorExpression>(
- mod->create<ast::type::Vector>(base_type, count), std::move(expr_list));
+ Source{}, mod->create<ast::type::Vector>(base_type, count),
+ std::move(expr_list));
}
ast::type::Type* VertexPulling::State::GetU32Type() {
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index 9386c1d..db2bed6 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -128,9 +128,9 @@
ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
ast::AssignmentStatement assign(lhs, rhs);
@@ -147,9 +147,9 @@
ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(lhs, rhs));
@@ -170,9 +170,9 @@
ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
ast::BlockStatement block;
block.append(create<ast::AssignmentStatement>(lhs, rhs));
@@ -189,16 +189,17 @@
ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(lhs, rhs));
- ast::ElseStatement stmt(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)),
- body);
+ ast::ElseStatement stmt(
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)),
+ body);
EXPECT_TRUE(td()->DetermineResultType(&stmt));
ASSERT_NE(stmt.condition()->result_type(), nullptr);
@@ -214,30 +215,31 @@
ast::type::F32 f32;
auto* else_lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* else_rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::AssignmentStatement>(else_lhs, else_rhs));
auto* else_stmt = create<ast::ElseStatement>(
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)),
else_body);
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(lhs, rhs));
- ast::IfStatement stmt(Source{},
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)),
- body, ast::ElseStatementList{else_stmt});
+ ast::IfStatement stmt(
+ Source{},
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)),
+ body, ast::ElseStatementList{else_stmt});
EXPECT_TRUE(td()->DetermineResultType(&stmt));
ASSERT_NE(stmt.condition()->result_type(), nullptr);
@@ -257,17 +259,17 @@
ast::type::F32 f32;
auto* body_lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body_rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(body_lhs, body_rhs));
auto* continuing_lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* continuing_rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
auto* continuing = create<ast::BlockStatement>();
continuing->append(
@@ -290,7 +292,7 @@
ast::type::I32 i32;
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
ast::ReturnStatement ret(Source{}, cond);
@@ -310,9 +312,9 @@
ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(lhs, rhs));
@@ -323,9 +325,10 @@
ast::CaseStatementList cases;
cases.push_back(create<ast::CaseStatement>(lit, body));
- ast::SwitchStatement stmt(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)),
- cases);
+ ast::SwitchStatement stmt(
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)),
+ cases);
EXPECT_TRUE(td()->DetermineResultType(&stmt)) << td()->error();
ASSERT_NE(stmt.condition()->result_type(), nullptr);
@@ -351,8 +354,9 @@
ast::ExpressionList call_params;
auto* expr = create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_func"),
- "my_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_func"), "my_func"),
call_params);
ast::CallStatement call(expr);
@@ -367,6 +371,7 @@
ast::type::F32 f32;
ast::ExpressionList call_params;
auto* call_expr = create<ast::CallExpression>(
+ Source{},
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}},
mod->RegisterSymbol("func"), "func"),
call_params);
@@ -400,6 +405,7 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
auto* init = var->constructor();
@@ -420,6 +426,7 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
auto* init = var->constructor();
@@ -444,7 +451,7 @@
ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{});
auto* idx = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* var =
create<ast::Variable>(Source{}, // source
"my_var", // name
@@ -458,9 +465,11 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::ArrayAccessorExpression acc(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"),
- idx);
+ ast::ArrayAccessorExpression acc(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_var"),
+ "my_var"),
+ idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
@@ -476,7 +485,7 @@
ast::type::Alias aary(mod->RegisterSymbol("myarrty"), "myarrty", &ary);
auto* idx = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* var =
create<ast::Variable>(Source{}, // source
"my_var", // name
@@ -490,9 +499,11 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::ArrayAccessorExpression acc(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"),
- idx);
+ ast::ArrayAccessorExpression acc(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_var"),
+ "my_var"),
+ idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
@@ -507,7 +518,7 @@
ast::type::Array ary(&f32, 3, ast::ArrayDecorationList{});
auto* idx = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* var =
create<ast::Variable>(Source{}, // source
"my_var", // name
@@ -521,9 +532,11 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::ArrayAccessorExpression acc(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"),
- idx);
+ ast::ArrayAccessorExpression acc(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_var"),
+ "my_var"),
+ idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
EXPECT_TRUE(acc.result_type()->Is<ast::type::F32>())
@@ -536,7 +549,7 @@
ast::type::Matrix mat(&f32, 3, 2);
auto* idx = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* var =
create<ast::Variable>(Source{}, // source
"my_var", // name
@@ -550,9 +563,11 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::ArrayAccessorExpression acc(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"),
- idx);
+ ast::ArrayAccessorExpression acc(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_var"),
+ "my_var"),
+ idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
@@ -568,9 +583,9 @@
ast::type::Matrix mat(&f32, 3, 2);
auto* idx1 = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* idx2 = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1));
auto* var =
create<ast::Variable>(Source{}, // source
"my_var", // name
@@ -585,9 +600,11 @@
EXPECT_TRUE(td()->Determine());
ast::ArrayAccessorExpression acc(
+ Source{},
create<ast::ArrayAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_var"),
- "my_var"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"),
idx1),
idx2);
@@ -605,7 +622,7 @@
ast::type::Vector vec(&f32, 3);
auto* idx = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* var =
create<ast::Variable>(Source{}, // source
"my_var", // name
@@ -619,9 +636,11 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::ArrayAccessorExpression acc(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"),
- idx);
+ ast::ArrayAccessorExpression acc(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_var"),
+ "my_var"),
+ idx);
EXPECT_TRUE(td()->DetermineResultType(&acc));
ASSERT_NE(acc.result_type(), nullptr);
ASSERT_TRUE(acc.result_type()->Is<ast::type::Pointer>());
@@ -633,8 +652,9 @@
TEST_F(TypeDeterminerTest, Expr_Bitcast) {
ast::type::F32 f32;
ast::BitcastExpression bitcast(
- &f32,
- create<ast::IdentifierExpression>(mod->RegisterSymbol("name"), "name"));
+ Source{}, &f32,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("name"),
+ "name"));
ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32, false,
nullptr, ast::VariableDecorationList{});
@@ -658,9 +678,11 @@
EXPECT_TRUE(td()->Determine());
ast::ExpressionList call_params;
- ast::CallExpression call(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_func"), "my_func"),
- call_params);
+ ast::CallExpression call(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_func"), "my_func"),
+ call_params);
EXPECT_TRUE(td()->DetermineResultType(&call));
ASSERT_NE(call.result_type(), nullptr);
EXPECT_TRUE(call.result_type()->Is<ast::type::F32>());
@@ -680,13 +702,15 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
auto* param = call_params.back();
- ast::CallExpression call(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_func"), "my_func"),
- call_params);
+ ast::CallExpression call(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_func"), "my_func"),
+ call_params);
EXPECT_TRUE(td()->DetermineResultType(&call));
ASSERT_NE(param->result_type(), nullptr);
EXPECT_TRUE(param->result_type()->Is<ast::type::F32>());
@@ -700,11 +724,12 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
- ast::CallExpression call(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("round"), "round"),
- call_params);
+ ast::CallExpression call(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("round"), "round"),
+ call_params);
EXPECT_TRUE(td()->DetermineResultType(&call));
ASSERT_NE(call.result_type(), nullptr);
@@ -715,9 +740,9 @@
ast::type::F32 f32;
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("name"), "name"));
- ast::TypeConstructorExpression cast(&f32, params);
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("name"), "name"));
+ ast::TypeConstructorExpression cast(Source{}, &f32, params);
ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32, false,
nullptr, ast::VariableDecorationList{});
@@ -731,7 +756,7 @@
TEST_F(TypeDeterminerTest, Expr_Constructor_Scalar) {
ast::type::F32 f32;
ast::ScalarConstructorExpression s(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
EXPECT_TRUE(td()->DetermineResultType(&s));
ASSERT_NE(s.result_type(), nullptr);
@@ -744,13 +769,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- ast::TypeConstructorExpression tc(&vec, vals);
+ ast::TypeConstructorExpression tc(Source{}, &vec, vals);
EXPECT_TRUE(td()->DetermineResultType(&tc));
ASSERT_NE(tc.result_type(), nullptr);
@@ -775,7 +800,8 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::IdentifierExpression ident(mod->RegisterSymbol("my_var"), "my_var");
+ ast::IdentifierExpression ident(Source{}, mod->RegisterSymbol("my_var"),
+ "my_var");
EXPECT_TRUE(td()->DetermineResultType(&ident));
ASSERT_NE(ident.result_type(), nullptr);
EXPECT_TRUE(ident.result_type()->Is<ast::type::Pointer>());
@@ -799,7 +825,8 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::IdentifierExpression ident(mod->RegisterSymbol("my_var"), "my_var");
+ ast::IdentifierExpression ident(Source{}, mod->RegisterSymbol("my_var"),
+ "my_var");
EXPECT_TRUE(td()->DetermineResultType(&ident));
ASSERT_NE(ident.result_type(), nullptr);
EXPECT_TRUE(ident.result_type()->Is<ast::type::F32>());
@@ -809,7 +836,7 @@
ast::type::F32 f32;
auto* my_var = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var");
+ Source{}, mod->RegisterSymbol("my_var"), "my_var");
auto* var =
create<ast::Variable>(Source{}, // source
@@ -823,8 +850,8 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
body->append(create<ast::AssignmentStatement>(
- my_var, create<ast::IdentifierExpression>(mod->RegisterSymbol("my_var"),
- "my_var")));
+ my_var, create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_var"), "my_var")));
ast::Function f(Source{}, mod->RegisterSymbol("my_func"), "my_func", {}, &f32,
body, ast::FunctionDecorationList{});
@@ -839,7 +866,7 @@
ast::type::F32 f32;
auto* my_var = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var");
+ Source{}, mod->RegisterSymbol("my_var"), "my_var");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(
@@ -852,8 +879,8 @@
ast::VariableDecorationList{}))); // decorations
body->append(create<ast::AssignmentStatement>(
- my_var, create<ast::IdentifierExpression>(mod->RegisterSymbol("my_var"),
- "my_var")));
+ my_var, create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_var"), "my_var")));
ast::Function f(Source{}, mod->RegisterSymbol("myfunc"), "my_func", {}, &f32,
body, ast::FunctionDecorationList{});
@@ -873,7 +900,7 @@
ast::type::Pointer ptr(&f32, ast::StorageClass::kFunction);
auto* my_var = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var");
+ Source{}, mod->RegisterSymbol("my_var"), "my_var");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(
@@ -886,8 +913,8 @@
ast::VariableDecorationList{}))); // decorations
body->append(create<ast::AssignmentStatement>(
- my_var, create<ast::IdentifierExpression>(mod->RegisterSymbol("my_var"),
- "my_var")));
+ my_var, create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_var"), "my_var")));
ast::Function f(Source{}, mod->RegisterSymbol("my_func"), "my_func", {}, &f32,
body, ast::FunctionDecorationList{});
@@ -914,14 +941,15 @@
// Register the function
EXPECT_TRUE(td()->Determine());
- ast::IdentifierExpression ident(mod->RegisterSymbol("my_func"), "my_func");
+ ast::IdentifierExpression ident(Source{}, mod->RegisterSymbol("my_func"),
+ "my_func");
EXPECT_TRUE(td()->DetermineResultType(&ident));
ASSERT_NE(ident.result_type(), nullptr);
EXPECT_TRUE(ident.result_type()->Is<ast::type::F32>());
}
TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) {
- ast::IdentifierExpression a(mod->RegisterSymbol("a"), "a");
+ ast::IdentifierExpression a(Source{}, mod->RegisterSymbol("a"), "a");
EXPECT_FALSE(td()->DetermineResultType(&a));
}
@@ -978,25 +1006,25 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("out_var"),
- "out_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("in_var"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("out_var"), "out_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("in_var"),
"in_var")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("wg_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("wg_var"),
"wg_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("wg_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("wg_var"),
"wg_var")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("sb_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("sb_var"),
"sb_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("sb_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("sb_var"),
"sb_var")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("priv_var"),
- "priv_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("priv_var"),
- "priv_var")));
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("priv_var"), "priv_var"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("priv_var"), "priv_var")));
auto* func =
create<ast::Function>(Source{}, mod->RegisterSymbol("my_func"), "my_func",
params, &f32, body, ast::FunctionDecorationList{});
@@ -1067,25 +1095,25 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("out_var"),
- "out_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("in_var"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("out_var"), "out_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("in_var"),
"in_var")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("wg_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("wg_var"),
"wg_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("wg_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("wg_var"),
"wg_var")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("sb_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("sb_var"),
"sb_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("sb_var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("sb_var"),
"sb_var")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("priv_var"),
- "priv_var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("priv_var"),
- "priv_var")));
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("priv_var"), "priv_var"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("priv_var"), "priv_var")));
ast::VariableList params;
auto* func =
create<ast::Function>(Source{}, mod->RegisterSymbol("my_func"), "my_func",
@@ -1095,11 +1123,12 @@
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("out_var"),
- "out_var"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("out_var"), "out_var"),
create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_func"),
- "my_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_func"), "my_func"),
ast::ExpressionList{})));
auto* func2 =
create<ast::Function>(Source{}, mod->RegisterSymbol("func"), "func",
@@ -1134,9 +1163,10 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f))));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f))));
ast::VariableList params;
auto* func =
@@ -1183,11 +1213,11 @@
EXPECT_TRUE(td()->Determine());
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_struct"), "my_struct");
+ Source{}, mod->RegisterSymbol("my_struct"), "my_struct");
auto* mem_ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("second_member"), "second_member");
+ Source{}, mod->RegisterSymbol("second_member"), "second_member");
- ast::MemberAccessorExpression mem(ident, mem_ident);
+ ast::MemberAccessorExpression mem(Source{}, ident, mem_ident);
EXPECT_TRUE(td()->DetermineResultType(&mem));
ASSERT_NE(mem.result_type(), nullptr);
ASSERT_TRUE(mem.result_type()->Is<ast::type::Pointer>());
@@ -1225,11 +1255,11 @@
EXPECT_TRUE(td()->Determine());
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_struct"), "my_struct");
+ Source{}, mod->RegisterSymbol("my_struct"), "my_struct");
auto* mem_ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("second_member"), "second_member");
+ Source{}, mod->RegisterSymbol("second_member"), "second_member");
- ast::MemberAccessorExpression mem(ident, mem_ident);
+ ast::MemberAccessorExpression mem(Source{}, ident, mem_ident);
EXPECT_TRUE(td()->DetermineResultType(&mem));
ASSERT_NE(mem.result_type(), nullptr);
ASSERT_TRUE(mem.result_type()->Is<ast::type::Pointer>());
@@ -1255,12 +1285,12 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- auto* ident = create<ast::IdentifierExpression>(mod->RegisterSymbol("my_vec"),
- "my_vec");
- auto* swizzle =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("xy"), "xy");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_vec"), "my_vec");
+ auto* swizzle = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("xy"), "xy");
- ast::MemberAccessorExpression mem(ident, swizzle);
+ ast::MemberAccessorExpression mem(Source{}, ident, swizzle);
EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error();
ASSERT_NE(mem.result_type(), nullptr);
ASSERT_TRUE(mem.result_type()->Is<ast::type::Vector>());
@@ -1286,12 +1316,12 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- auto* ident = create<ast::IdentifierExpression>(mod->RegisterSymbol("my_vec"),
- "my_vec");
- auto* swizzle =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("x"), "x");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("my_vec"), "my_vec");
+ auto* swizzle = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("x"), "x");
- ast::MemberAccessorExpression mem(ident, swizzle);
+ ast::MemberAccessorExpression mem(Source{}, ident, swizzle);
EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error();
ASSERT_NE(mem.result_type(), nullptr);
ASSERT_TRUE(mem.result_type()->Is<ast::type::Pointer>());
@@ -1359,21 +1389,25 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("c"), "c");
- auto* mem_ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("mem"), "mem");
- auto* foo_ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("foo"), "foo");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("c"), "c");
+ auto* mem_ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("mem"), "mem");
+ auto* foo_ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("foo"), "foo");
auto* idx = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 0));
- auto* swizzle =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("yx"), "yx");
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 0));
+ auto* swizzle = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("yx"), "yx");
ast::MemberAccessorExpression mem(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
- create<ast::MemberAccessorExpression>(ident, mem_ident), idx),
+ Source{},
+ create<ast::MemberAccessorExpression>(Source{}, ident, mem_ident),
+ idx),
foo_ident),
swizzle);
EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error();
@@ -1404,9 +1438,11 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(
- op, create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"));
+ ast::BinaryExpression expr(Source{}, op,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1432,9 +1468,11 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(
- op, create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"));
+ ast::BinaryExpression expr(Source{}, op,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1476,9 +1514,11 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(
- op, create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"));
+ ast::BinaryExpression expr(Source{}, op,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1504,9 +1544,11 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(
- op, create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"));
+ ast::BinaryExpression expr(Source{}, op,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1541,9 +1583,11 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(
- op, create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"));
+ ast::BinaryExpression expr(Source{}, op,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1569,9 +1613,11 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(
- op, create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"));
+ ast::BinaryExpression expr(Source{}, op,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1607,10 +1653,11 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(
- ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("val"), "val"));
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("val"), "val"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1643,11 +1690,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vector"), "vector"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("scalar"), "scalar"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("vector"),
+ "vector"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("scalar"),
+ "scalar"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1685,11 +1733,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("scalar"), "scalar"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vector"), "vector"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("scalar"),
+ "scalar"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("vector"),
+ "vector"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1718,11 +1767,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vector"), "vector"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vector"), "vector"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("vector"),
+ "vector"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("vector"),
+ "vector"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1760,11 +1810,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("matrix"), "matrix"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("scalar"), "scalar"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("matrix"),
+ "matrix"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("scalar"),
+ "scalar"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1802,11 +1853,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("scalar"), "scalar"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("matrix"), "matrix"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("scalar"),
+ "scalar"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("matrix"),
+ "matrix"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1845,11 +1897,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("matrix"), "matrix"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vector"), "vector"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("matrix"),
+ "matrix"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("vector"),
+ "vector"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1888,11 +1941,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("vector"), "vector"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("matrix"), "matrix"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("vector"),
+ "vector"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("matrix"),
+ "matrix"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1931,11 +1985,12 @@
// Register the global
ASSERT_TRUE(td()->Determine()) << td()->error();
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply,
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("mat4x3"), "mat4x3"),
- create<ast::IdentifierExpression>(
- mod->RegisterSymbol("mat3x4"), "mat3x4"));
+ ast::BinaryExpression expr(
+ Source{}, ast::BinaryOp::kMultiply,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("mat4x3"),
+ "mat4x3"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("mat3x4"),
+ "mat3x4"));
ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error();
ASSERT_NE(expr.result_type(), nullptr);
@@ -1967,12 +2022,13 @@
EXPECT_TRUE(td()->Determine());
ast::ExpressionList call_params;
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"), "ident"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
@@ -1999,12 +2055,13 @@
EXPECT_TRUE(td()->Determine());
ast::ExpressionList call_params;
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"), "ident"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
EXPECT_TRUE(td()->DetermineResultType(&expr));
ASSERT_NE(expr.result_type(), nullptr);
@@ -2026,9 +2083,10 @@
EXPECT_TRUE(td()->Determine());
ast::ExpressionList call_params;
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
EXPECT_FALSE(td()->DetermineResultType(&expr));
EXPECT_EQ(td()->error(), "incorrect number of parameters for " + name);
}
@@ -2063,13 +2121,14 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("ident1"), "ident1"));
+ Source{}, mod->RegisterSymbol("ident1"), "ident1"));
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("ident2"), "ident2"));
+ Source{}, mod->RegisterSymbol("ident2"), "ident2"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
EXPECT_FALSE(td()->DetermineResultType(&expr));
EXPECT_EQ(td()->error(), "incorrect number of parameters for " + name);
}
@@ -2104,11 +2163,12 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2140,11 +2200,12 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2176,11 +2237,12 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2205,9 +2267,10 @@
mod->AddGlobalVariable(var);
ast::ExpressionList call_params;
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2232,13 +2295,14 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2308,8 +2372,8 @@
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
mod->AddGlobalVariable(var);
- call_params->push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol(name), name));
+ call_params->push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol(name), name));
}
std::unique_ptr<ast::type::Type> subtype(Texture type) {
@@ -2342,8 +2406,9 @@
add_call_param("lod", &i32, &call_params);
ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("textureLoad"),
- "textureLoad"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("textureLoad"), "textureLoad"),
call_params);
EXPECT_TRUE(td()->Determine());
@@ -2422,8 +2487,9 @@
add_call_param("lod", &i32, &call_params);
ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("textureLoad"),
- "textureLoad"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("textureLoad"), "textureLoad"),
call_params);
EXPECT_TRUE(td()->Determine());
@@ -2475,13 +2541,14 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("dot"), "dot"),
- call_params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("dot"), "dot"),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2517,15 +2584,17 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("my_var"), "my_var"));
+ Source{}, mod->RegisterSymbol("my_var"), "my_var"));
call_params.push_back(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("bool_var"), "bool_var"));
+ Source{}, mod->RegisterSymbol("bool_var"), "bool_var"));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("select"), "select"),
- call_params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("select"),
+ "select"),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2554,12 +2623,14 @@
mod->AddGlobalVariable(var);
ast::ExpressionList call_params;
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v"), "v"));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("select"), "select"),
- call_params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("select"),
+ "select"),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2583,18 +2654,20 @@
mod->AddGlobalVariable(var);
ast::ExpressionList call_params;
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"));
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"));
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"));
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v"), "v"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v"), "v"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v"), "v"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v"), "v"));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("select"), "select"),
- call_params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("select"),
+ "select"),
+ call_params);
// Register the variable
EXPECT_TRUE(td()->Determine());
@@ -2628,14 +2701,15 @@
mod->AddGlobalVariable(var2);
ast::ExpressionList call_params;
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v3"), "v3"));
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v2"), "v2"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v3"), "v3"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v2"), "v2"));
ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("outerProduct"),
- "outerProduct"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("outerProduct"), "outerProduct"),
call_params);
// Register the variable
@@ -2667,12 +2741,13 @@
mod->AddGlobalVariable(var2);
ast::ExpressionList call_params;
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v2"), "v2"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v2"), "v2"));
ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("outerProduct"),
- "outerProduct"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("outerProduct"), "outerProduct"),
call_params);
// Register the variable
@@ -2697,16 +2772,17 @@
mod->AddGlobalVariable(var2);
ast::ExpressionList call_params;
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v2"), "v2"));
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v2"), "v2"));
- call_params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v2"), "v2"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v2"), "v2"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v2"), "v2"));
+ call_params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v2"), "v2"));
ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("outerProduct"),
- "outerProduct"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("outerProduct"), "outerProduct"),
call_params);
// Register the variable
@@ -2736,8 +2812,10 @@
// Register the global
EXPECT_TRUE(td()->Determine());
- ast::UnaryOpExpression der(op, create<ast::IdentifierExpression>(
- mod->RegisterSymbol("ident"), "ident"));
+ ast::UnaryOpExpression der(
+ Source{}, op,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("ident"),
+ "ident"));
EXPECT_TRUE(td()->DetermineResultType(&der));
ASSERT_NE(der.result_type(), nullptr);
ASSERT_TRUE(der.result_type()->Is<ast::type::Vector>());
@@ -2838,7 +2916,8 @@
TEST_P(IntrinsicDataTest, Lookup) {
auto param = GetParam();
- ast::IdentifierExpression ident(mod->RegisterSymbol(param.name), param.name);
+ ast::IdentifierExpression ident(Source{}, mod->RegisterSymbol(param.name),
+ param.name);
EXPECT_TRUE(td()->SetIntrinsicIfNeeded(&ident));
EXPECT_EQ(ident.intrinsic(), param.intrinsic);
EXPECT_TRUE(ident.IsIntrinsic());
@@ -2919,8 +2998,8 @@
IntrinsicData{"trunc", ast::Intrinsic::kTrunc}));
TEST_F(TypeDeterminerTest, IntrinsicNotSetIfNotMatched) {
- ast::IdentifierExpression ident(mod->RegisterSymbol("not_intrinsic"),
- "not_intrinsic");
+ ast::IdentifierExpression ident(
+ Source{}, mod->RegisterSymbol("not_intrinsic"), "not_intrinsic");
EXPECT_FALSE(td()->SetIntrinsicIfNeeded(&ident));
EXPECT_EQ(ident.intrinsic(), ast::Intrinsic::kNone);
EXPECT_FALSE(ident.IsIntrinsic());
@@ -2934,12 +3013,12 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -2954,19 +3033,20 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -2981,11 +3061,11 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -2999,8 +3079,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -3013,15 +3093,15 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -3063,12 +3143,12 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3083,19 +3163,20 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3110,12 +3191,12 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, -11)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, -11)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3130,19 +3211,20 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3157,12 +3239,12 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3177,19 +3259,20 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1.0f)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1.0f)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3.0f)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3204,11 +3287,11 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, false)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, false)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3222,8 +3305,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -3236,15 +3319,15 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -3261,14 +3344,14 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error();
- auto* ident = create<ast::IdentifierExpression>(mod->RegisterSymbol("length"),
- "length");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("length"), "length");
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3281,19 +3364,20 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
- auto* ident = create<ast::IdentifierExpression>(mod->RegisterSymbol("length"),
- "length");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("length"), "length");
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3305,11 +3389,11 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
- auto* ident = create<ast::IdentifierExpression>(mod->RegisterSymbol("length"),
- "length");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("length"), "length");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3320,9 +3404,9 @@
TEST_F(TypeDeterminerTest, ImportData_Length_Error_NoParams) {
ast::ExpressionList params;
- auto* ident = create<ast::IdentifierExpression>(mod->RegisterSymbol("length"),
- "length");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("length"), "length");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3333,15 +3417,15 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- auto* ident = create<ast::IdentifierExpression>(mod->RegisterSymbol("length"),
- "length");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("length"), "length");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3356,14 +3440,14 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3378,28 +3462,30 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3414,13 +3500,13 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3434,8 +3520,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -3448,11 +3534,11 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -3468,25 +3554,27 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec2, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec3, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec2, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec3, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3501,20 +3589,21 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3527,15 +3616,15 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -3555,14 +3644,14 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
+ Source{}, mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3575,28 +3664,30 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
+ Source{}, mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3608,13 +3699,13 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol("distance"), "distance");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3626,8 +3717,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol("distance"), "distance");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3638,11 +3729,11 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol("distance"), "distance");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3656,25 +3747,27 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec2, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec3, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec2, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec3, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol("distance"), "distance");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), "mismatched parameter types for distance");
@@ -3686,20 +3779,21 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol("distance"), "distance");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), "mismatched parameter types for distance");
@@ -3709,15 +3803,15 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("distance"), "distance");
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol("distance"), "distance");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3730,28 +3824,30 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("cross"), "cross");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("cross"), "cross");
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3764,13 +3860,13 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("cross"), "cross");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("cross"), "cross");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3783,27 +3879,29 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("cross"), "cross");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("cross"), "cross");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3812,9 +3910,9 @@
TEST_F(TypeDeterminerTest, ImportData_Cross_Error_MissingParams) {
ast::ExpressionList params;
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("cross"), "cross");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("cross"), "cross");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3827,18 +3925,19 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("cross"), "cross");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("cross"), "cross");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3851,36 +3950,39 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_3;
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_3));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_3));
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("cross"), "cross");
- ast::CallExpression call(ident, params);
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("cross"), "cross");
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3895,16 +3997,16 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3919,37 +4021,40 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_3;
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_3));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_3));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -3964,15 +4069,15 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -3986,8 +4091,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4000,11 +4105,11 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4017,13 +4122,13 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4039,34 +4144,37 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_3;
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec2, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec3, vals_2));
- params.push_back(create<ast::TypeConstructorExpression>(&vec3, vals_3));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec2, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec3, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec3, vals_3));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4081,22 +4189,23 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4109,17 +4218,17 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4144,16 +4253,16 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4168,37 +4277,40 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_3;
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_3));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_3));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4213,16 +4325,16 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4237,37 +4349,40 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList vals_3;
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_3));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_3));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4282,16 +4397,16 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4306,37 +4421,40 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3)));
ast::ExpressionList vals_3;
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_3));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_3));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4351,15 +4469,15 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, false)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, false)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4373,8 +4491,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4387,11 +4505,11 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4404,13 +4522,13 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4426,34 +4544,37 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals_3;
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals_3.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec2, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec3, vals_2));
- params.push_back(create<ast::TypeConstructorExpression>(&vec3, vals_3));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec2, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec3, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec3, vals_3));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4468,22 +4589,23 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4496,17 +4618,17 @@
ast::type::F32 f32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4527,12 +4649,12 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4547,19 +4669,20 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4574,11 +4697,11 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4592,8 +4715,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4606,15 +4729,15 @@
ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4637,14 +4760,14 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4658,14 +4781,14 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4679,14 +4802,14 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4701,28 +4824,30 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4738,28 +4863,30 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4775,28 +4902,30 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4811,13 +4940,13 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, false)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, false)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4831,8 +4960,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4845,11 +4974,11 @@
ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4865,25 +4994,27 @@
ast::ExpressionList vals_1;
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_1.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
ast::ExpressionList vals_2;
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals_2.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList params;
- params.push_back(create<ast::TypeConstructorExpression>(&vec2, vals_1));
- params.push_back(create<ast::TypeConstructorExpression>(&vec3, vals_2));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec2, vals_1));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec3, vals_2));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4898,20 +5029,21 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
- params.push_back(create<ast::TypeConstructorExpression>(&vec, vals));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
+ params.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, vals));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(),
@@ -4924,15 +5056,15 @@
ast::type::I32 i32;
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -4963,13 +5095,13 @@
ASSERT_TRUE(td()->Determine()) << td()->error();
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var"));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol("determinant"), "determinant");
+ Source{}, mod->RegisterSymbol("determinant"), "determinant");
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error();
ASSERT_NE(ident->result_type(), nullptr);
@@ -4997,12 +5129,12 @@
ASSERT_TRUE(td()->Determine()) << td()->error();
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var"));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect type for ") + param.name +
@@ -5015,8 +5147,8 @@
ast::ExpressionList params;
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -5043,14 +5175,14 @@
ASSERT_TRUE(td()->Determine()) << td()->error();
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"));
- params.push_back(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var"));
auto* ident = create<ast::IdentifierExpression>(
- mod->RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ Source{}, mod->RegisterSymbol(param.name), param.name);
+ ast::CallExpression call(Source{}, ident, params);
EXPECT_FALSE(td()->DetermineResultType(&call));
EXPECT_EQ(td()->error(), std::string("incorrect number of parameters for ") +
@@ -5084,38 +5216,43 @@
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("second"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("second"),
"second"),
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b"),
- ast::ExpressionList{})));
+ create<ast::CallExpression>(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("b"), "b"),
+ ast::ExpressionList{})));
auto* func_c =
create<ast::Function>(Source{}, mod->RegisterSymbol("c"), "c", params,
&f32, body, ast::FunctionDecorationList{});
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("first"), "first"),
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("c"), "c"),
- ast::ExpressionList{})));
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("first"),
+ "first"),
+ create<ast::CallExpression>(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("c"), "c"),
+ ast::ExpressionList{})));
auto* func_a =
create<ast::Function>(Source{}, mod->RegisterSymbol("a"), "a", params,
&f32, body, ast::FunctionDecorationList{});
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("call_a"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("call_a"),
"call_a"),
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"),
- ast::ExpressionList{})));
+ create<ast::CallExpression>(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ ast::ExpressionList{})));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("call_b"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("call_b"),
"call_b"),
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b"),
- ast::ExpressionList{})));
+ create<ast::CallExpression>(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("b"), "b"),
+ ast::ExpressionList{})));
auto* ep_1 = create<ast::Function>(
Source{}, mod->RegisterSymbol("ep_1"), "ep_1", params, &f32, body,
ast::FunctionDecorationList{
@@ -5124,11 +5261,12 @@
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("call_c"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("call_c"),
"call_c"),
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("c"), "c"),
- ast::ExpressionList{})));
+ create<ast::CallExpression>(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("c"), "c"),
+ ast::ExpressionList{})));
auto* ep_2 = create<ast::Function>(
Source{}, mod->RegisterSymbol("ep_2"), "ep_2", params, &f32, body,
ast::FunctionDecorationList{
@@ -5475,7 +5613,7 @@
param.buildSamplerVariable(this);
auto* ident = Expr(param.function);
- ast::CallExpression call{ident, param.args(this)};
+ ast::CallExpression call{Source{}, ident, param.args(this)};
ASSERT_TRUE(td()->Determine()) << td()->error();
ASSERT_TRUE(td()->DetermineResultType(&call)) << td()->error();
diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc
index 087ba48..4076fba 100644
--- a/src/validator/validator_control_block_test.cc
+++ b/src/validator/validator_control_block_test.cc
@@ -50,6 +50,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &f32, 3.14f)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -84,11 +85,12 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList csl;
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
ast::CaseStatementList body;
@@ -122,12 +124,13 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
ast::CaseStatementList switch_body;
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList default_csl_1;
auto* block_default_1 = create<ast::BlockStatement>();
@@ -172,12 +175,13 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
ast::CaseStatementList switch_body;
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList csl;
csl.push_back(create<ast::UintLiteral>(Source{}, &u32, 1));
@@ -215,12 +219,13 @@
&u32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::UintLiteral>(Source{}, &u32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
ast::CaseStatementList switch_body;
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList csl;
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, -1));
@@ -257,12 +262,13 @@
&u32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::UintLiteral>(Source{}, &u32, 3)), // constructor
ast::VariableDecorationList{}); // decorations
ast::CaseStatementList switch_body;
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList csl_1;
csl_1.push_back(create<ast::UintLiteral>(Source{}, &u32, 0));
@@ -305,12 +311,13 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
ast::CaseStatementList switch_body;
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList csl_1;
csl_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
@@ -353,11 +360,12 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList default_csl;
auto* block_default = create<ast::BlockStatement>();
block_default->append(
@@ -390,11 +398,12 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList default_csl;
auto* block_default = create<ast::BlockStatement>();
ast::CaseStatementList body;
@@ -430,11 +439,12 @@
&my_int, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &u32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* cond =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
ast::CaseSelectorList default_csl;
auto* block_default = create<ast::BlockStatement>();
ast::CaseStatementList body;
diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc
index b581bcb..2078a1a 100644
--- a/src/validator/validator_function_test.cc
+++ b/src/validator/validator_function_test.cc
@@ -46,6 +46,7 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -94,6 +95,7 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -155,7 +157,7 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* return_expr = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
return_expr));
@@ -179,7 +181,7 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* return_expr = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
return_expr));
@@ -205,7 +207,7 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* return_expr = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
auto* func =
@@ -215,7 +217,7 @@
ast::VariableList params_copy;
auto* body_copy = create<ast::BlockStatement>();
auto* return_expr_copy = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
body_copy->append(create<ast::ReturnStatement>(Source{}, return_expr_copy));
auto* func_copy = create<ast::Function>(
@@ -237,7 +239,8 @@
ast::ExpressionList call_params;
auto* call_expr = create<ast::CallExpression>(
Source{Source::Location{12, 34}},
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("func"), "func"),
+ create<ast::IdentifierExpression>(Source{}, mod()->RegisterSymbol("func"),
+ "func"),
call_params);
ast::VariableList params0;
auto* body0 = create<ast::BlockStatement>();
@@ -259,7 +262,8 @@
ast::ExpressionList call_params;
auto* call_expr = create<ast::CallExpression>(
Source{Source::Location{12, 34}},
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("func"), "func"),
+ create<ast::IdentifierExpression>(Source{}, mod()->RegisterSymbol("func"),
+ "func"),
call_params);
auto* var =
create<ast::Variable>(Source{}, // source
@@ -274,7 +278,7 @@
auto* body0 = create<ast::BlockStatement>();
body0->append(create<ast::VariableDeclStatement>(var));
auto* return_expr = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
body0->append(create<ast::ReturnStatement>(Source{}, return_expr));
auto* func0 = create<ast::Function>(Source{}, mod()->RegisterSymbol("func"),
@@ -293,7 +297,7 @@
ast::type::I32 i32;
ast::VariableList params;
auto* return_expr = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 0));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 0));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc
index 982f4e5..a3cac0e 100644
--- a/src/validator/validator_test.cc
+++ b/src/validator/validator_test.cc
@@ -65,9 +65,9 @@
ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1));
- auto* rhs = create<ast::IdentifierExpression>(mod()->RegisterSymbol("my_var"),
- "my_var");
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1));
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("my_var"), "my_var");
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
// TODO(sarahM0): Invalidate assignment to scalar.
@@ -83,7 +83,7 @@
auto* lhs = create<ast::IdentifierExpression>(
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* assign = create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs);
@@ -101,7 +101,7 @@
auto* lhs = create<ast::IdentifierExpression>(
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
@@ -123,13 +123,14 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
td()->RegisterVariableForTesting(var);
@@ -154,13 +155,14 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
td()->RegisterVariableForTesting(var);
@@ -188,13 +190,14 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -223,12 +226,13 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
ast::BlockStatement block;
block.append(create<ast::VariableDeclStatement>(var));
@@ -324,6 +328,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
ast::VariableDecorationList{})); // decorations
@@ -331,7 +336,7 @@
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"),
"not_global_var");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
@@ -363,13 +368,14 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
ast::VariableDecorationList{})); // decorations
auto* lhs = create<ast::IdentifierExpression>(
- mod()->RegisterSymbol("global_var"), "global_var");
+ Source{}, mod()->RegisterSymbol("global_var"), "global_var");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
ast::VariableList params;
@@ -402,19 +408,20 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{}); // decorations
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* lhs = create<ast::IdentifierExpression>(
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
auto* outer_body = create<ast::BlockStatement>();
outer_body->append(
@@ -442,17 +449,18 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{}); // decorations
auto* lhs = create<ast::IdentifierExpression>(
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
@@ -479,6 +487,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
ast::VariableDecorationList{}); // decorations
mod()->AddGlobalVariable(var0);
@@ -490,6 +499,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
ast::VariableDecorationList{}); // decorations
mod()->AddGlobalVariable(var1);
@@ -510,6 +520,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
ast::VariableDecorationList{}); // decorations
mod()->AddGlobalVariable(var0);
@@ -521,6 +532,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
ast::VariableDecorationList{}); // decorations
mod()->AddGlobalVariable(var1);
@@ -543,13 +555,14 @@
&i32, // type
true, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -580,6 +593,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
ast::VariableDecorationList{}); // decorations
mod()->AddGlobalVariable(global_var);
@@ -591,6 +605,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{}); // decorations
ast::VariableList params;
@@ -624,6 +639,7 @@
&i32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -634,6 +650,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -667,12 +684,13 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{}); // decorations
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -683,6 +701,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -711,6 +730,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -721,12 +741,13 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{}); // decorations
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var));
@@ -753,6 +774,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -763,6 +785,7 @@
&void_type, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 1.0)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -810,10 +833,10 @@
ast::VariableDecorationList{}); // decorations
td()->RegisterVariableForTesting(var);
- auto* lhs =
- create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
diff --git a/src/writer/append_vector.cc b/src/writer/append_vector.cc
index 0436c6f..6a629b2 100644
--- a/src/writer/append_vector.cc
+++ b/src/writer/append_vector.cc
@@ -55,7 +55,7 @@
}
// Cast scalar to the vector element type
- ast::TypeConstructorExpression scalar_cast(packed_el_ty, {scalar});
+ ast::TypeConstructorExpression scalar_cast(Source{}, packed_el_ty, {scalar});
scalar_cast.set_result_type(packed_el_ty);
ast::type::Vector packed_ty(packed_el_ty, packed_size);
@@ -74,7 +74,8 @@
packed.emplace_back(scalar);
}
- ast::TypeConstructorExpression constructor{&packed_ty, std::move(packed)};
+ ast::TypeConstructorExpression constructor{Source{}, &packed_ty,
+ std::move(packed)};
constructor.set_result_type(&packed_ty);
return callback(&constructor);
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index 209f94a..baefa5f 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -780,7 +780,7 @@
auto emit_vector_appended_with_i32_zero = [&](tint::ast::Expression* vector) {
auto* i32 = module_->create<ast::type::I32>();
ast::SintLiteral zero_lit(Source{}, i32, 0);
- ast::ScalarConstructorExpression zero(&zero_lit);
+ ast::ScalarConstructorExpression zero(Source{}, &zero_lit);
zero.set_result_type(i32);
return AppendVector(vector, &zero,
[&](ast::TypeConstructorExpression* packed) {
diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc
index d0a6885..74c2ac1 100644
--- a/src/writer/hlsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc
@@ -32,23 +32,23 @@
TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) {
ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(Source{}, &i32, 5);
- auto* idx = create<ast::ScalarConstructorExpression>(lit);
- auto* ary =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
+ auto* idx = create<ast::ScalarConstructorExpression>(Source{}, lit);
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ary"), "ary");
- ast::ArrayAccessorExpression expr(ary, idx);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx);
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "ary[5]");
}
TEST_F(HlslGeneratorImplTest_Expression, EmitArrayAccessor) {
- auto* ary =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("idx"), "idx");
- ast::ArrayAccessorExpression expr(ary, idx);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx);
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "ary[idx]");
diff --git a/src/writer/hlsl/generator_impl_assign_test.cc b/src/writer/hlsl/generator_impl_assign_test.cc
index 0b89944..46e08bb 100644
--- a/src/writer/hlsl/generator_impl_assign_test.cc
+++ b/src/writer/hlsl/generator_impl_assign_test.cc
@@ -28,10 +28,10 @@
using HlslGeneratorImplTest_Assign = TestHelper;
TEST_F(HlslGeneratorImplTest_Assign, Emit_Assign) {
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("rhs"), "rhs");
ast::AssignmentStatement assign(lhs, rhs);
gen.increment_indent();
diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc
index 5ab8160..b32ae91 100644
--- a/src/writer/hlsl/generator_impl_binary_test.cc
+++ b/src/writer/hlsl/generator_impl_binary_test.cc
@@ -79,15 +79,15 @@
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* left =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("left"), "left");
- auto* right =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("right"), "right");
+ auto* left = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("left"), "left");
+ auto* right = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("right"), "right");
td.RegisterVariableForTesting(left_var);
td.RegisterVariableForTesting(right_var);
- ast::BinaryExpression expr(params.op, left, right);
+ ast::BinaryExpression expr(Source{}, params.op, left, right);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -115,15 +115,15 @@
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* left =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("left"), "left");
- auto* right =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("right"), "right");
+ auto* left = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("left"), "left");
+ auto* right = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("right"), "right");
td.RegisterVariableForTesting(left_var);
td.RegisterVariableForTesting(right_var);
- ast::BinaryExpression expr(params.op, left, right);
+ ast::BinaryExpression expr(Source{}, params.op, left, right);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -151,15 +151,15 @@
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* left =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("left"), "left");
- auto* right =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("right"), "right");
+ auto* left = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("left"), "left");
+ auto* right = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("right"), "right");
td.RegisterVariableForTesting(left_var);
td.RegisterVariableForTesting(right_var);
- ast::BinaryExpression expr(params.op, left, right);
+ ast::BinaryExpression expr(Source{}, params.op, left, right);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -191,19 +191,20 @@
ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ });
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
EXPECT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -217,18 +218,18 @@
ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ auto* rhs = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
EXPECT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -249,14 +250,14 @@
false, // is_const
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mat"), "mat");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
EXPECT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -276,13 +277,13 @@
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mat"), "mat");
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
EXPECT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -302,21 +303,21 @@
false, // is_const
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mat"), "mat");
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ auto* rhs = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
EXPECT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -339,19 +340,19 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- auto* lhs = create<ast::TypeConstructorExpression>(&vec3, vals);
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ auto* lhs = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mat"), "mat");
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
EXPECT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -371,14 +372,14 @@
false, // is_const
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mat"), "mat");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mat"), "mat");
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
EXPECT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -386,12 +387,12 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Logical_And) {
- auto* left =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("left"), "left");
- auto* right =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("right"), "right");
+ auto* left = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("left"), "left");
+ auto* right = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("right"), "right");
- ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, left, right);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kLogicalAnd, left, right);
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "(_tint_tmp)");
@@ -404,15 +405,19 @@
TEST_F(HlslGeneratorImplTest_Binary, Logical_Multi) {
// (a && b) || (c || d)
- auto* a = create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a");
- auto* b = create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b");
- auto* c = create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c");
- auto* d = create<ast::IdentifierExpression>(mod.RegisterSymbol("d"), "d");
+ auto* a =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"), "a");
+ auto* b =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"), "b");
+ auto* c =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"), "c");
+ auto* d =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"), "d");
ast::BinaryExpression expr(
- ast::BinaryOp::kLogicalOr,
- create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, a, b),
- create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, c, d));
+ Source{}, ast::BinaryOp::kLogicalOr,
+ create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kLogicalAnd, a, b),
+ create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kLogicalOr, c, d));
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "(_tint_tmp_0)");
@@ -432,12 +437,12 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Logical_Or) {
- auto* left =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("left"), "left");
- auto* right =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("right"), "right");
+ auto* left = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("left"), "left");
+ auto* right = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("right"), "right");
- ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, left, right);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kLogicalOr, left, right);
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "(_tint_tmp)");
@@ -462,36 +467,39 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
Source{}, create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))));
auto* else_stmt = create<ast::ElseStatement>(body);
body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
Source{}, create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* else_if_stmt = create<ast::ElseStatement>(
create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr,
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c")),
+ Source{}, ast::BinaryOp::kLogicalOr,
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"),
+ "c")),
body);
body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
Source{}, create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))));
- ast::IfStatement expr(
- Source{},
- create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalAnd,
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
- body,
- {
- else_if_stmt,
- else_stmt,
- });
+ ast::IfStatement expr(Source{},
+ create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kLogicalAnd,
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("a"), "a"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("b"), "b")),
+ body,
+ {
+ else_if_stmt,
+ else_stmt,
+ });
ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error();
EXPECT_EQ(result(), R"(bool _tint_tmp = a;
@@ -516,15 +524,19 @@
TEST_F(HlslGeneratorImplTest_Binary, Return_WithLogical) {
// return (a && b) || c;
- auto* a = create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a");
- auto* b = create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b");
- auto* c = create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c");
+ auto* a =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"), "a");
+ auto* b =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"), "b");
+ auto* c =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"), "c");
- ast::ReturnStatement expr(
- Source{},
- create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr,
- create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, a, b), c));
+ ast::ReturnStatement expr(Source{},
+ create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kLogicalOr,
+ create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kLogicalAnd, a, b),
+ c));
ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error();
EXPECT_EQ(result(), R"(bool _tint_tmp = a;
@@ -541,16 +553,21 @@
TEST_F(HlslGeneratorImplTest_Binary, Assign_WithLogical) {
// a = (b || c) && d;
- auto* a = create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a");
- auto* b = create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b");
- auto* c = create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c");
- auto* d = create<ast::IdentifierExpression>(mod.RegisterSymbol("d"), "d");
+ auto* a =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"), "a");
+ auto* b =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"), "b");
+ auto* c =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"), "c");
+ auto* d =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"), "d");
ast::AssignmentStatement expr(
- a,
- create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalAnd,
- create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, b, c), d));
+ a, create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kLogicalAnd,
+ create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kLogicalOr,
+ b, c),
+ d));
ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error();
EXPECT_EQ(result(), R"(bool _tint_tmp = b;
@@ -569,21 +586,25 @@
// var a : bool = (b && c) || d;
ast::type::Bool bool_type;
- auto* b = create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b");
- auto* c = create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c");
- auto* d = create<ast::IdentifierExpression>(mod.RegisterSymbol("d"), "d");
+ auto* b =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"), "b");
+ auto* c =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"), "c");
+ auto* d =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"), "d");
- auto* var = create<ast::Variable>(
- Source{}, // source
- "a", // name
- ast::StorageClass::kFunction, // storage_class
- &bool_type, // type
- false, // is_const
- create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr,
- create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, b, c),
- d), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var =
+ create<ast::Variable>(Source{}, // source
+ "a", // name
+ ast::StorageClass::kFunction, // storage_class
+ &bool_type, // type
+ false, // is_const
+ create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kLogicalOr,
+ create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kLogicalAnd, b, c),
+ d), // constructor
+ ast::VariableDecorationList{}); // decorations
ast::VariableDeclStatement expr(var);
@@ -604,14 +625,19 @@
// as<i32>(a && (b || c))
ast::type::I32 i32;
- auto* a = create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a");
- auto* b = create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b");
- auto* c = create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c");
+ auto* a =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"), "a");
+ auto* b =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"), "b");
+ auto* c =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"), "c");
- ast::BitcastExpression expr(&i32, create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalAnd, a,
- create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr, b, c)));
+ ast::BitcastExpression expr(
+ Source{}, &i32,
+ create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kLogicalAnd, a,
+ create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kLogicalOr, b,
+ c)));
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
EXPECT_EQ(pre_result(), R"(bool _tint_tmp = a;
@@ -638,26 +664,34 @@
ast::ExpressionList params;
params.push_back(create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalAnd,
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")));
+ Source{}, ast::BinaryOp::kLogicalAnd,
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"), "a"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b")));
params.push_back(create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr,
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"), "d")));
+ Source{}, ast::BinaryOp::kLogicalOr,
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"), "c"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
+ "d")));
params.push_back(create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalAnd,
+ Source{}, ast::BinaryOp::kLogicalAnd,
create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr,
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c")),
+ Source{}, ast::BinaryOp::kLogicalOr,
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("c"),
+ "c")),
create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr,
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"), "d"))));
+ Source{}, ast::BinaryOp::kLogicalOr,
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
+ "d"))));
ast::CallStatement expr(create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
params));
ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error();
diff --git a/src/writer/hlsl/generator_impl_bitcast_test.cc b/src/writer/hlsl/generator_impl_bitcast_test.cc
index a95de59..88181b2 100644
--- a/src/writer/hlsl/generator_impl_bitcast_test.cc
+++ b/src/writer/hlsl/generator_impl_bitcast_test.cc
@@ -31,8 +31,9 @@
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
ast::type::F32 f32;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id");
- ast::BitcastExpression bitcast(&f32, id);
+ auto* id = create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("id"), "id");
+ ast::BitcastExpression bitcast(Source{}, &f32, id);
ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error();
EXPECT_EQ(result(), "asfloat(id)");
@@ -40,8 +41,9 @@
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
ast::type::I32 i32;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id");
- ast::BitcastExpression bitcast(&i32, id);
+ auto* id = create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("id"), "id");
+ ast::BitcastExpression bitcast(Source{}, &i32, id);
ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error();
EXPECT_EQ(result(), "asint(id)");
@@ -49,8 +51,9 @@
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
ast::type::U32 u32;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id");
- ast::BitcastExpression bitcast(&u32, id);
+ auto* id = create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("id"), "id");
+ ast::BitcastExpression bitcast(Source{}, &u32, id);
ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error();
EXPECT_EQ(result(), "asuint(id)");
diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc
index 14f9791..60b9c22 100644
--- a/src/writer/hlsl/generator_impl_call_test.cc
+++ b/src/writer/hlsl/generator_impl_call_test.cc
@@ -32,9 +32,9 @@
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
ast::type::Void void_type;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
- ast::CallExpression call(id, {});
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
+ ast::CallExpression call(Source{}, id, {});
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{},
@@ -48,14 +48,14 @@
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
ast::type::Void void_type;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
- ast::CallExpression call(id, params);
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
+ ast::CallExpression call(Source{}, id, params);
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{},
@@ -69,14 +69,14 @@
TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) {
ast::type::Void void_type;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
- ast::CallStatement call(create<ast::CallExpression>(id, params));
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
+ ast::CallStatement call(create<ast::CallExpression>(Source{}, id, params));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{},
diff --git a/src/writer/hlsl/generator_impl_cast_test.cc b/src/writer/hlsl/generator_impl_cast_test.cc
index b53f3e0..23671ed 100644
--- a/src/writer/hlsl/generator_impl_cast_test.cc
+++ b/src/writer/hlsl/generator_impl_cast_test.cc
@@ -32,10 +32,10 @@
ast::type::F32 f32;
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("id"), "id"));
- ast::TypeConstructorExpression cast(&f32, params);
+ ast::TypeConstructorExpression cast(Source{}, &f32, params);
ASSERT_TRUE(gen.EmitExpression(pre, out, &cast)) << gen.error();
EXPECT_EQ(result(), "float(id)");
@@ -46,10 +46,10 @@
ast::type::Vector vec3(&f32, 3);
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("id"), "id"));
- ast::TypeConstructorExpression cast(&vec3, params);
+ ast::TypeConstructorExpression cast(Source{}, &vec3, params);
ASSERT_TRUE(gen.EmitExpression(pre, out, &cast)) << gen.error();
EXPECT_EQ(result(), "float3(id)");
diff --git a/src/writer/hlsl/generator_impl_constructor_test.cc b/src/writer/hlsl/generator_impl_constructor_test.cc
index 0cb4ba0..ba46d8e 100644
--- a/src/writer/hlsl/generator_impl_constructor_test.cc
+++ b/src/writer/hlsl/generator_impl_constructor_test.cc
@@ -38,7 +38,7 @@
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
ast::type::Bool bool_type;
auto* lit = create<ast::BoolLiteral>(Source{}, &bool_type, false);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "false");
@@ -47,7 +47,7 @@
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) {
ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "-12345");
@@ -56,7 +56,7 @@
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) {
ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 56779);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "56779u");
@@ -67,7 +67,7 @@
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto* lit = create<ast::FloatLiteral>(Source{}, &f32,
static_cast<float>((1 << 30) - 4));
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "1073741824.0f");
@@ -78,9 +78,9 @@
auto* lit = create<ast::FloatLiteral>(Source{}, &f32, -1.2e-5);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&f32, values);
+ ast::TypeConstructorExpression expr(Source{}, &f32, values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "float(-0.000012f)");
@@ -91,9 +91,9 @@
auto* lit = create<ast::BoolLiteral>(Source{}, &b, true);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&b, values);
+ ast::TypeConstructorExpression expr(Source{}, &b, values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "bool(true)");
@@ -104,9 +104,9 @@
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&i32, values);
+ ast::TypeConstructorExpression expr(Source{}, &i32, values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "int(-12345)");
@@ -117,9 +117,9 @@
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 12345);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&u32, values);
+ ast::TypeConstructorExpression expr(Source{}, &u32, values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "uint(12345u)");
@@ -133,11 +133,11 @@
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32, 2.f);
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32, 3.f);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- ast::TypeConstructorExpression expr(&vec, values);
+ ast::TypeConstructorExpression expr(Source{}, &vec, values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "float3(1.0f, 2.0f, 3.0f)");
@@ -148,7 +148,7 @@
ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
- ast::TypeConstructorExpression expr(&vec, values);
+ ast::TypeConstructorExpression expr(Source{}, &vec, values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(), "float3(0.0f)");
@@ -173,14 +173,15 @@
static_cast<float>(3 + (i * 2)));
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- mat_values.push_back(create<ast::TypeConstructorExpression>(&vec, values));
+ mat_values.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values));
}
- ast::TypeConstructorExpression expr(&mat, mat_values);
+ ast::TypeConstructorExpression expr(Source{}, &mat, mat_values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
@@ -206,14 +207,15 @@
static_cast<float>(3 + (i * 3)));
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- ary_values.push_back(create<ast::TypeConstructorExpression>(&vec, values));
+ ary_values.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values));
}
- ast::TypeConstructorExpression expr(&ary, ary_values);
+ ast::TypeConstructorExpression expr(Source{}, &ary, ary_values);
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
EXPECT_EQ(result(),
diff --git a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc
index b25ae35..a61d366 100644
--- a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc
+++ b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc
@@ -84,11 +84,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body,
@@ -157,11 +161,15 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body,
@@ -230,11 +238,15 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
@@ -302,11 +314,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
@@ -371,11 +387,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
@@ -435,11 +455,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
@@ -506,11 +530,14 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
+ "x"))));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &void_type, body,
diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc
index ff3bd55..619b7ec 100644
--- a/src/writer/hlsl/generator_impl_function_test.cc
+++ b/src/writer/hlsl/generator_impl_function_test.cc
@@ -171,8 +171,10 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params,
@@ -241,11 +243,14 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
+ "x"))));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params,
@@ -305,9 +310,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
"x")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -377,12 +383,14 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("uniforms"),
- "uniforms"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord")),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("uniforms"), "uniforms"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord")),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
"x")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -458,9 +466,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
"b")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -532,9 +541,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
"b")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -601,12 +611,15 @@
ast::VariableList params;
auto* assign = create<ast::AssignmentStatement>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b")),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
auto* body = create<ast::BlockStatement>();
body->append(assign);
@@ -694,14 +707,18 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("param"), "param")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("val"),
+ "val"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("param"),
+ "param")));
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("foo"), "foo")));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -710,14 +727,16 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("sub_func"),
- "sub_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
expr)));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func_1 = create<ast::Function>(
@@ -788,8 +807,8 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod.RegisterSymbol("param"), "param")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param"), "param")));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -798,14 +817,16 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("sub_func"),
- "sub_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
expr)));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func_1 = create<ast::Function>(
@@ -884,14 +905,17 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
+ "x"))));
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod.RegisterSymbol("param"), "param")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param"), "param")));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -900,14 +924,16 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("sub_func"),
- "sub_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
expr)));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func_1 = create<ast::Function>(
@@ -977,11 +1003,12 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{}, create<ast::MemberAccessorExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("x"), "x"))));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -990,19 +1017,20 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- auto* var =
- create<ast::Variable>(Source{}, // source
- "v", // name
- ast::StorageClass::kFunction, // storage_class
- &f32, // type
- false, // is_const
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(
- mod.RegisterSymbol("sub_func"), "sub_func"),
- expr), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var = create<ast::Variable>(
+ Source{}, // source
+ "v", // name
+ ast::StorageClass::kFunction, // storage_class
+ &f32, // type
+ false, // is_const
+ create<ast::CallExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
+ expr), // constructor
+ ast::VariableDecorationList{}); // decorations
body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -1069,11 +1097,12 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{}, create<ast::MemberAccessorExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("x"), "x"))));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -1082,19 +1111,20 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- auto* var =
- create<ast::Variable>(Source{}, // source
- "v", // name
- ast::StorageClass::kFunction, // storage_class
- &f32, // type
- false, // is_const
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(
- mod.RegisterSymbol("sub_func"), "sub_func"),
- expr), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var = create<ast::Variable>(
+ Source{}, // source
+ "v", // name
+ ast::StorageClass::kFunction, // storage_class
+ &f32, // type
+ false, // is_const
+ create<ast::CallExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
+ expr), // constructor
+ ast::VariableDecorationList{}); // decorations
body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -1148,9 +1178,10 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
auto* list = create<ast::BlockStatement>();
list->append(create<ast::ReturnStatement>(Source{}));
@@ -1158,11 +1189,11 @@
body->append(create<ast::IfStatement>(
Source{},
create<ast::BinaryExpression>(
- ast::BinaryOp::kEqual,
+ Source{}, ast::BinaryOp::kEqual,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))),
list, ast::ElseStatementList{}));
body->append(create<ast::ReturnStatement>(Source{}));
@@ -1356,9 +1387,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -1384,9 +1416,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
diff --git a/src/writer/hlsl/generator_impl_identifier_test.cc b/src/writer/hlsl/generator_impl_identifier_test.cc
index c573ec4..52fd804 100644
--- a/src/writer/hlsl/generator_impl_identifier_test.cc
+++ b/src/writer/hlsl/generator_impl_identifier_test.cc
@@ -24,14 +24,15 @@
using HlslGeneratorImplTest_Identifier = TestHelper;
TEST_F(HlslGeneratorImplTest_Identifier, EmitIdentifierExpression) {
- ast::IdentifierExpression i(mod.RegisterSymbol("foo"), "foo");
+ ast::IdentifierExpression i(Source{}, mod.RegisterSymbol("foo"), "foo");
ASSERT_TRUE(gen.EmitExpression(pre, out, &i)) << gen.error();
EXPECT_EQ(result(), "foo");
}
TEST_F(HlslGeneratorImplTest_Identifier,
EmitIdentifierExpression_Single_WithCollision) {
- ast::IdentifierExpression i(mod.RegisterSymbol("virtual"), "virtual");
+ ast::IdentifierExpression i(Source{}, mod.RegisterSymbol("virtual"),
+ "virtual");
ASSERT_TRUE(gen.EmitExpression(pre, out, &i)) << gen.error();
EXPECT_EQ(result(), "virtual_tint_0");
}
diff --git a/src/writer/hlsl/generator_impl_if_test.cc b/src/writer/hlsl/generator_impl_if_test.cc
index 9d4845f..6da8512 100644
--- a/src/writer/hlsl/generator_impl_if_test.cc
+++ b/src/writer/hlsl/generator_impl_if_test.cc
@@ -27,8 +27,8 @@
using HlslGeneratorImplTest_If = TestHelper;
TEST_F(HlslGeneratorImplTest_If, Emit_If) {
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
@@ -44,12 +44,12 @@
TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) {
auto* else_cond = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("else_cond"), "else_cond");
+ Source{}, mod.RegisterSymbol("else_cond"), "else_cond");
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::ReturnStatement>(Source{}));
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
@@ -73,8 +73,8 @@
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::ReturnStatement>(Source{}));
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
@@ -94,7 +94,7 @@
TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) {
auto* else_cond = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("else_cond"), "else_cond");
+ Source{}, mod.RegisterSymbol("else_cond"), "else_cond");
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::ReturnStatement>(Source{}));
@@ -102,8 +102,8 @@
auto* else_body_2 = create<ast::BlockStatement>();
else_body_2->append(create<ast::ReturnStatement>(Source{}));
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc
index 47b1ec2..882c4d7 100644
--- a/src/writer/hlsl/generator_impl_import_test.cc
+++ b/src/writer/hlsl/generator_impl_import_test.cc
@@ -54,11 +54,11 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name);
- ast::CallExpression expr(ident, params);
+ Source{}, mod.RegisterSymbol(param.name), param.name);
+ ast::CallExpression expr(Source{}, ident, params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error();
@@ -100,11 +100,13 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error();
@@ -122,13 +124,15 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error();
@@ -153,28 +157,32 @@
ast::ExpressionList params;
params.push_back(create<ast::TypeConstructorExpression>(
- &vec, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.f)),
- }));
+ Source{}, &vec,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.f)),
+ }));
params.push_back(create<ast::TypeConstructorExpression>(
- &vec, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 4.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 5.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 6.f)),
- }));
+ Source{}, &vec,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 4.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 5.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 6.f)),
+ }));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error();
@@ -194,13 +202,15 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error();
@@ -219,15 +229,17 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.f)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error();
@@ -253,15 +265,17 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error();
@@ -285,12 +299,13 @@
ast::VariableDecorationList{}); // decorations
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("var"), "var"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("var"), "var"));
ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("determinant"),
- "determinant"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("determinant"), "determinant"),
params);
mod.AddGlobalVariable(var);
diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc
index 375aa9b..ca670fc 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc
@@ -93,14 +93,15 @@
ast::VariableDecorationList{}); // decorations
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("a"), "a"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("b"), "b"));
ast::CallExpression call(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("outer_product"),
- "outer_product"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("outer_product"), "outer_product"),
params);
td.RegisterVariableForTesting(a);
@@ -127,13 +128,14 @@
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
- ast::CallExpression call(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("dot"), "dot"),
- params);
+ ast::CallExpression call(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("dot"), "dot"),
+ params);
ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec,
false, nullptr, ast::VariableDecorationList{});
diff --git a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
index 42f3b0f..b5607d2 100644
--- a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
+++ b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc
@@ -272,7 +272,7 @@
param.buildTextureVariable(this);
param.buildSamplerVariable(this);
- ast::CallExpression call{Expr(param.function), param.args(this)};
+ ast::CallExpression call{Source{}, Expr(param.function), param.args(this)};
ASSERT_TRUE(td.Determine()) << td.error();
ASSERT_TRUE(td.DetermineResultType(&call)) << td.error();
diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc
index 25b4a63..6afc947 100644
--- a/src/writer/hlsl/generator_impl_loop_test.cc
+++ b/src/writer/hlsl/generator_impl_loop_test.cc
@@ -86,10 +86,10 @@
body = create<ast::BlockStatement>();
body->append(inner);
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("rhs"), "rhs");
continuing = create<ast::BlockStatement>();
continuing->append(create<ast::AssignmentStatement>(lhs, rhs));
@@ -153,6 +153,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.4)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -167,10 +168,10 @@
nullptr, // constructor
ast::VariableDecorationList{}))); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("rhs"), "rhs");
auto* continuing = create<ast::BlockStatement>();
continuing->append(create<ast::AssignmentStatement>(lhs, rhs));
diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc
index 055b679..f689fb6 100644
--- a/src/writer/hlsl/generator_impl_member_accessor_test.cc
+++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc
@@ -66,12 +66,12 @@
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* str =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("str"), "str");
- auto* mem =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mem"), "mem");
+ auto* str = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("str"), "str");
+ auto* mem = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mem"), "mem");
- ast::MemberAccessorExpression expr(str, mem);
+ ast::MemberAccessorExpression expr(Source{}, str, mem);
td.RegisterVariableForTesting(str_var);
gen.register_global(str_var);
@@ -118,8 +118,11 @@
ast::VariableDecorationList{}); // decorations
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -168,8 +171,11 @@
ast::VariableDecorationList{}); // decorations
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -230,9 +236,13 @@
ast::VariableDecorationList{}); // decorations
auto* lhs = create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
- auto* rhs = create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b");
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"));
+ auto* rhs =
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"), "b");
ast::AssignmentStatement assign(lhs, rhs);
@@ -293,10 +303,13 @@
ast::VariableDecorationList{}); // decorations
auto* lhs = create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
- auto* rhs =
- create<ast::TypeConstructorExpression>(&mat, ast::ExpressionList{});
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"));
+ auto* rhs = create<ast::TypeConstructorExpression>(Source{}, &mat,
+ ast::ExpressionList{});
ast::AssignmentStatement assign(lhs, rhs);
@@ -354,8 +367,11 @@
ast::VariableDecorationList{}); // decorations
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -411,8 +427,11 @@
ast::VariableDecorationList{}); // decorations
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -460,8 +479,11 @@
ast::VariableDecorationList{}); // decorations
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -513,15 +535,19 @@
ast::VariableDecorationList{}); // decorations
ast::ArrayAccessorExpression expr(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("a"), "a")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -569,11 +595,15 @@
ast::VariableDecorationList{}); // decorations
ast::ArrayAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a")),
+ Source{},
+ create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -621,19 +651,23 @@
ast::VariableDecorationList{}); // decorations
ast::ArrayAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a")),
+ Source{},
+ create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a")),
create<ast::BinaryExpression>(
- ast::BinaryOp::kSubtract,
+ Source{}, ast::BinaryOp::kSubtract,
create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd,
+ Source{}, ast::BinaryOp::kAdd,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 4))),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 4))),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))));
td.RegisterVariableForTesting(coord_var);
gen.register_global(coord_var);
@@ -689,10 +723,13 @@
ASSERT_TRUE(td.Determine()) << td.error();
auto* lhs = create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f));
ast::AssignmentStatement assign(lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&assign));
@@ -743,13 +780,17 @@
ASSERT_TRUE(td.Determine()) << td.error();
auto* lhs = create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a")),
+ Source{},
+ create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
ast::AssignmentStatement assign(lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error();
@@ -801,10 +842,13 @@
ASSERT_TRUE(td.Determine()) << td.error();
auto* lhs = create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("a"),
+ "a"));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
ast::AssignmentStatement assign(lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&assign));
@@ -858,8 +902,11 @@
ASSERT_TRUE(td.Determine()) << td.error();
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"));
ASSERT_TRUE(td.DetermineResultType(&expr));
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -914,14 +961,17 @@
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32, 2.f);
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32, 3.f);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
auto* lhs = create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
- auto* rhs = create<ast::TypeConstructorExpression>(&fvec3, values);
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("data"),
+ "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"));
+ auto* rhs = create<ast::TypeConstructorExpression>(Source{}, &fvec3, values);
ast::AssignmentStatement assign(lhs, rhs);
@@ -995,14 +1045,19 @@
ASSERT_TRUE(td.Determine()) << td.error();
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("c"), "c")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"));
ASSERT_TRUE(td.DetermineResultType(&expr));
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -1073,17 +1128,23 @@
ASSERT_TRUE(td.Determine()) << td.error();
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
- "c")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("c"), "c")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("xy"), "xy"));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b")),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("xy"),
+ "xy"));
ASSERT_TRUE(td.DetermineResultType(&expr));
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -1153,17 +1214,23 @@
ASSERT_TRUE(td.Determine()) << td.error();
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
- "c")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("c"), "c")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("g"), "g"));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b")),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("g"),
+ "g"));
ASSERT_TRUE(td.DetermineResultType(&expr));
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -1232,18 +1299,23 @@
ASSERT_TRUE(td.Determine()) << td.error();
ast::ArrayAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
- "c")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("c"), "c")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
ASSERT_TRUE(td.DetermineResultType(&expr));
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
@@ -1312,24 +1384,29 @@
ASSERT_TRUE(td.Determine()) << td.error();
auto* lhs = create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("c"), "c")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b"));
auto* lit1 = create<ast::FloatLiteral>(Source{}, &f32, 1.f);
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32, 2.f);
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32, 3.f);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- auto* rhs = create<ast::TypeConstructorExpression>(&fvec3, values);
+ auto* rhs = create<ast::TypeConstructorExpression>(Source{}, &fvec3, values);
ast::AssignmentStatement assign(lhs, rhs);
@@ -1402,20 +1479,26 @@
ASSERT_TRUE(td.Determine()) << td.error();
auto* lhs = create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
- "c")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("c"), "c")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("y"), "y"));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
+ "b")),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("y"),
+ "y"));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &i32, 1.f));
+ Source{}, create<ast::FloatLiteral>(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 cae5bd3..bb2287b 100644
--- a/src/writer/hlsl/generator_impl_module_constant_test.cc
+++ b/src/writer/hlsl/generator_impl_module_constant_test.cc
@@ -38,20 +38,21 @@
ast::ExpressionList exprs;
exprs.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
exprs.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
exprs.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* var = create<ast::Variable>(
- Source{}, // source
- "pos", // name
- ast::StorageClass::kNone, // storage_class
- &ary, // type
- true, // is_const
- create<ast::TypeConstructorExpression>(&ary, exprs), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var =
+ create<ast::Variable>(Source{}, // source
+ "pos", // name
+ ast::StorageClass::kNone, // storage_class
+ &ary, // type
+ true, // is_const
+ create<ast::TypeConstructorExpression>(
+ Source{}, &ary, exprs), // constructor
+ ast::VariableDecorationList{}); // decorations
ASSERT_TRUE(gen.EmitProgramConstVariable(out, var)) << gen.error();
EXPECT_EQ(result(), "static const float pos[3] = {1.0f, 2.0f, 3.0f};\n");
@@ -67,6 +68,7 @@
&f32, // type
true, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)), // constructor
ast::VariableDecorationList{
// decorations
diff --git a/src/writer/hlsl/generator_impl_return_test.cc b/src/writer/hlsl/generator_impl_return_test.cc
index 0b54dc0..a13ef1b 100644
--- a/src/writer/hlsl/generator_impl_return_test.cc
+++ b/src/writer/hlsl/generator_impl_return_test.cc
@@ -36,8 +36,8 @@
}
TEST_F(HlslGeneratorImplTest_Return, Emit_ReturnWithValue) {
- auto* expr =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr");
ast::ReturnStatement r(Source{}, expr);
gen.increment_indent();
diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc
index 9456dff..e2b053d 100644
--- a/src/writer/hlsl/generator_impl_switch_test.cc
+++ b/src/writer/hlsl/generator_impl_switch_test.cc
@@ -48,8 +48,8 @@
body.push_back(case_stmt);
body.push_back(def);
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
ast::SwitchStatement s(cond, body);
gen.increment_indent();
diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc
index c93304a..b7bb46a 100644
--- a/src/writer/hlsl/generator_impl_test.cc
+++ b/src/writer/hlsl/generator_impl_test.cc
@@ -56,7 +56,7 @@
TEST_F(HlslGeneratorImplTest, NameConflictWith_InputStructName) {
ASSERT_EQ(gen.generate_name("func_main_in"), "func_main_in");
- ast::IdentifierExpression ident(mod.RegisterSymbol("func_main_in"),
+ ast::IdentifierExpression ident(Source{}, mod.RegisterSymbol("func_main_in"),
"func_main_in");
ASSERT_TRUE(gen.EmitIdentifier(pre, out, &ident));
EXPECT_EQ(result(), "func_main_in_0");
diff --git a/src/writer/hlsl/generator_impl_unary_op_test.cc b/src/writer/hlsl/generator_impl_unary_op_test.cc
index 8a87e93..6ab97a5 100644
--- a/src/writer/hlsl/generator_impl_unary_op_test.cc
+++ b/src/writer/hlsl/generator_impl_unary_op_test.cc
@@ -37,9 +37,9 @@
TEST_P(HlslUnaryOpTest, Emit) {
auto params = GetParam();
- auto* expr =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
- ast::UnaryOpExpression op(params.op, expr);
+ auto* expr = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr");
+ ast::UnaryOpExpression op(Source{}, params.op, expr);
ASSERT_TRUE(gen.EmitExpression(pre, out, &op)) << gen.error();
EXPECT_EQ(result(), std::string(params.name) + "(expr)");
diff --git a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
index a360918..469725f 100644
--- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc
@@ -128,7 +128,7 @@
TEST_F(HlslGeneratorImplTest_VariableDecl,
Emit_VariableDeclStatement_Initializer_Private) {
auto* ident = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("initializer"), "initializer");
+ Source{}, mod.RegisterSymbol("initializer"), "initializer");
ast::type::F32 f32;
auto* var =
@@ -152,7 +152,8 @@
ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
- auto* zero_vec = create<ast::TypeConstructorExpression>(&vec, values);
+ auto* zero_vec =
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values);
auto* var =
create<ast::Variable>(Source{}, // source
@@ -175,7 +176,8 @@
ast::type::Matrix mat(&f32, 3, 2);
ast::ExpressionList values;
- auto* zero_mat = create<ast::TypeConstructorExpression>(&mat, values);
+ auto* zero_mat =
+ create<ast::TypeConstructorExpression>(Source{}, &mat, values);
auto* var =
create<ast::Variable>(Source{}, // source
diff --git a/src/writer/msl/generator_impl_array_accessor_test.cc b/src/writer/msl/generator_impl_array_accessor_test.cc
index 41da259..f354506 100644
--- a/src/writer/msl/generator_impl_array_accessor_test.cc
+++ b/src/writer/msl/generator_impl_array_accessor_test.cc
@@ -34,23 +34,23 @@
TEST_F(MslGeneratorImplTest, EmitExpression_ArrayAccessor) {
ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(Source{}, &i32, 5);
- auto* idx = create<ast::ScalarConstructorExpression>(lit);
- auto* ary =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
+ auto* idx = create<ast::ScalarConstructorExpression>(Source{}, lit);
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ary"), "ary");
- ast::ArrayAccessorExpression expr(ary, idx);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx);
ASSERT_TRUE(gen.EmitExpression(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "ary[5]");
}
TEST_F(MslGeneratorImplTest, EmitArrayAccessor) {
- auto* ary =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("idx"), "idx");
- ast::ArrayAccessorExpression expr(ary, idx);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx);
ASSERT_TRUE(gen.EmitArrayAccessor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "ary[idx]");
diff --git a/src/writer/msl/generator_impl_assign_test.cc b/src/writer/msl/generator_impl_assign_test.cc
index 44df0fa..9fcdddf 100644
--- a/src/writer/msl/generator_impl_assign_test.cc
+++ b/src/writer/msl/generator_impl_assign_test.cc
@@ -30,10 +30,10 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_Assign) {
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("rhs"), "rhs");
ast::AssignmentStatement assign(lhs, rhs);
gen.increment_indent();
diff --git a/src/writer/msl/generator_impl_binary_test.cc b/src/writer/msl/generator_impl_binary_test.cc
index dc378bd..3b83f86 100644
--- a/src/writer/msl/generator_impl_binary_test.cc
+++ b/src/writer/msl/generator_impl_binary_test.cc
@@ -38,12 +38,12 @@
TEST_P(MslBinaryTest, Emit) {
auto params = GetParam();
- auto* left =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("left"), "left");
- auto* right =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("right"), "right");
+ auto* left = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("left"), "left");
+ auto* right = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("right"), "right");
- ast::BinaryExpression expr(params.op, left, right);
+ ast::BinaryExpression expr(Source{}, params.op, left, right);
ASSERT_TRUE(gen.EmitExpression(&expr)) << gen.error();
EXPECT_EQ(gen.result(), params.result);
diff --git a/src/writer/msl/generator_impl_bitcast_test.cc b/src/writer/msl/generator_impl_bitcast_test.cc
index bba7e43..13f4c7f 100644
--- a/src/writer/msl/generator_impl_bitcast_test.cc
+++ b/src/writer/msl/generator_impl_bitcast_test.cc
@@ -31,8 +31,9 @@
TEST_F(MslGeneratorImplTest, EmitExpression_Bitcast) {
ast::type::F32 f32;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id");
- ast::BitcastExpression bitcast(&f32, id);
+ auto* id = create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("id"), "id");
+ ast::BitcastExpression bitcast(Source{}, &f32, id);
ASSERT_TRUE(gen.EmitExpression(&bitcast)) << gen.error();
EXPECT_EQ(gen.result(), "as_type<float>(id)");
diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc
index 897a819..5562381 100644
--- a/src/writer/msl/generator_impl_call_test.cc
+++ b/src/writer/msl/generator_impl_call_test.cc
@@ -34,9 +34,9 @@
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
ast::type::Void void_type;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
- ast::CallExpression call(id, {});
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
+ ast::CallExpression call(Source{}, id, {});
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{},
@@ -50,14 +50,14 @@
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
ast::type::Void void_type;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
- ast::CallExpression call(id, params);
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
+ ast::CallExpression call(Source{}, id, params);
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{},
@@ -71,14 +71,14 @@
TEST_F(MslGeneratorImplTest, EmitStatement_Call) {
ast::type::Void void_type;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
- ast::CallStatement call(create<ast::CallExpression>(id, params));
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
+ ast::CallStatement call(create<ast::CallExpression>(Source{}, id, params));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{},
diff --git a/src/writer/msl/generator_impl_cast_test.cc b/src/writer/msl/generator_impl_cast_test.cc
index c63fef3..d8b44ae 100644
--- a/src/writer/msl/generator_impl_cast_test.cc
+++ b/src/writer/msl/generator_impl_cast_test.cc
@@ -34,10 +34,10 @@
ast::type::F32 f32;
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("id"), "id"));
- ast::TypeConstructorExpression cast(&f32, params);
+ ast::TypeConstructorExpression cast(Source{}, &f32, params);
ASSERT_TRUE(gen.EmitExpression(&cast)) << gen.error();
EXPECT_EQ(gen.result(), "float(id)");
@@ -48,10 +48,10 @@
ast::type::Vector vec3(&f32, 3);
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("id"), "id"));
- ast::TypeConstructorExpression cast(&vec3, params);
+ ast::TypeConstructorExpression cast(Source{}, &vec3, params);
ASSERT_TRUE(gen.EmitExpression(&cast)) << gen.error();
EXPECT_EQ(gen.result(), "float3(id)");
diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc
index 0f50308..34cebed 100644
--- a/src/writer/msl/generator_impl_constructor_test.cc
+++ b/src/writer/msl/generator_impl_constructor_test.cc
@@ -40,7 +40,7 @@
TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) {
ast::type::Bool bool_type;
auto* lit = create<ast::BoolLiteral>(Source{}, &bool_type, false);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "false");
@@ -49,7 +49,7 @@
TEST_F(MslGeneratorImplTest, EmitConstructor_Int) {
ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "-12345");
@@ -58,7 +58,7 @@
TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) {
ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 56779);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "56779u");
@@ -69,7 +69,7 @@
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto* lit = create<ast::FloatLiteral>(Source{}, &f32,
static_cast<float>((1 << 30) - 4));
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "1073741824.0f");
@@ -80,9 +80,9 @@
auto* lit = create<ast::FloatLiteral>(Source{}, &f32, -1.2e-5);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&f32, values);
+ ast::TypeConstructorExpression expr(Source{}, &f32, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "float(-0.000012f)");
@@ -93,9 +93,9 @@
auto* lit = create<ast::BoolLiteral>(Source{}, &b, true);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&b, values);
+ ast::TypeConstructorExpression expr(Source{}, &b, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "bool(true)");
@@ -106,9 +106,9 @@
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&i32, values);
+ ast::TypeConstructorExpression expr(Source{}, &i32, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "int(-12345)");
@@ -119,9 +119,9 @@
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 12345);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&u32, values);
+ ast::TypeConstructorExpression expr(Source{}, &u32, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "uint(12345u)");
@@ -135,11 +135,11 @@
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32, 2.f);
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32, 3.f);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- ast::TypeConstructorExpression expr(&vec, values);
+ ast::TypeConstructorExpression expr(Source{}, &vec, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "float3(1.0f, 2.0f, 3.0f)");
@@ -150,7 +150,7 @@
ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
- ast::TypeConstructorExpression expr(&vec, values);
+ ast::TypeConstructorExpression expr(Source{}, &vec, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "float3(0.0f)");
@@ -175,14 +175,15 @@
static_cast<float>(3 + (i * 2)));
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- mat_values.push_back(create<ast::TypeConstructorExpression>(&vec, values));
+ mat_values.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values));
}
- ast::TypeConstructorExpression expr(&mat, mat_values);
+ ast::TypeConstructorExpression expr(Source{}, &mat, mat_values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
// A matrix of type T with n columns and m rows can also be constructed from
@@ -207,14 +208,15 @@
static_cast<float>(3 + (i * 3)));
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- ary_values.push_back(create<ast::TypeConstructorExpression>(&vec, values));
+ ary_values.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values));
}
- ast::TypeConstructorExpression expr(&ary, ary_values);
+ ast::TypeConstructorExpression expr(Source{}, &ary, ary_values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(),
"{float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), "
diff --git a/src/writer/msl/generator_impl_function_entry_point_data_test.cc b/src/writer/msl/generator_impl_function_entry_point_data_test.cc
index eaf49e3..e6bf9f6 100644
--- a/src/writer/msl/generator_impl_function_entry_point_data_test.cc
+++ b/src/writer/msl/generator_impl_function_entry_point_data_test.cc
@@ -83,11 +83,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body,
@@ -153,11 +157,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body,
@@ -223,11 +231,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
ast::FunctionDecorationList{
@@ -292,11 +304,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
@@ -359,11 +375,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
@@ -421,11 +441,15 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar")));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body,
@@ -490,11 +514,14 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
+ "x"))));
auto* func = create<ast::Function>(
Source{}, mod.RegisterSymbol("main"), "main", params, &void_type, body,
diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc
index d7cd5f1..66b3143 100644
--- a/src/writer/msl/generator_impl_function_test.cc
+++ b/src/writer/msl/generator_impl_function_test.cc
@@ -179,8 +179,10 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
@@ -252,11 +254,14 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
+ "x"))));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
@@ -316,9 +321,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
"x")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -395,9 +401,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
"b")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -479,9 +486,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("b"),
"b")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -578,14 +586,18 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("foo"),
+ "foo")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("val"), "val"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("param"), "param")));
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("val"),
+ "val"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("param"),
+ "param")));
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod.RegisterSymbol("foo"), "foo")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("foo"), "foo")));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -594,14 +606,16 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("sub_func"),
- "sub_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
expr)));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func_1 = create<ast::Function>(
@@ -675,8 +689,8 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod.RegisterSymbol("param"), "param")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param"), "param")));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -685,14 +699,16 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("sub_func"),
- "sub_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
expr)));
body->append(create<ast::ReturnStatement>(Source{}));
@@ -775,14 +791,17 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("x"),
+ "x"))));
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod.RegisterSymbol("param"), "param")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("param"), "param")));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -791,14 +810,16 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("depth"), "depth"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("depth"),
+ "depth"),
create<ast::CallExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("sub_func"),
- "sub_func"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
expr)));
body->append(create<ast::ReturnStatement>(Source{}));
auto* func_1 = create<ast::Function>(
@@ -866,11 +887,12 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("x"), "x"))));
+ Source{}, create<ast::MemberAccessorExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("x"), "x"))));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -879,19 +901,20 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- auto* var =
- create<ast::Variable>(Source{}, // source
- "v", // name
- ast::StorageClass::kFunction, // storage_class
- &f32, // type
- false, // is_const
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(
- mod.RegisterSymbol("sub_func"), "sub_func"),
- expr), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var = create<ast::Variable>(
+ Source{}, // source
+ "v", // name
+ ast::StorageClass::kFunction, // storage_class
+ &f32, // type
+ false, // is_const
+ create<ast::CallExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
+ expr), // constructor
+ ast::VariableDecorationList{}); // decorations
body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -972,11 +995,12 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"))));
+ Source{}, create<ast::MemberAccessorExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("b"), "b"))));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -985,19 +1009,20 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- auto* var =
- create<ast::Variable>(Source{}, // source
- "v", // name
- ast::StorageClass::kFunction, // storage_class
- &f32, // type
- false, // is_const
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(
- mod.RegisterSymbol("sub_func"), "sub_func"),
- expr), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var = create<ast::Variable>(
+ Source{}, // source
+ "v", // name
+ ast::StorageClass::kFunction, // storage_class
+ &f32, // type
+ false, // is_const
+ create<ast::CallExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
+ expr), // constructor
+ ast::VariableDecorationList{}); // decorations
body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -1084,11 +1109,12 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("coord"),
- "coord"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"))));
+ Source{}, create<ast::MemberAccessorExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("coord"), "coord"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("b"), "b"))));
auto* sub_func = create<ast::Function>(
Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body,
ast::FunctionDecorationList{});
@@ -1097,19 +1123,20 @@
ast::ExpressionList expr;
expr.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
- auto* var =
- create<ast::Variable>(Source{}, // source
- "v", // name
- ast::StorageClass::kFunction, // storage_class
- &f32, // type
- false, // is_const
- create<ast::CallExpression>(
- create<ast::IdentifierExpression>(
- mod.RegisterSymbol("sub_func"), "sub_func"),
- expr), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var = create<ast::Variable>(
+ Source{}, // source
+ "v", // name
+ ast::StorageClass::kFunction, // storage_class
+ &f32, // type
+ false, // is_const
+ create<ast::CallExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("sub_func"), "sub_func"),
+ expr), // constructor
+ ast::VariableDecorationList{}); // decorations
body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
@@ -1170,9 +1197,10 @@
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("bar"),
+ "bar"),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
auto* list = create<ast::BlockStatement>();
list->append(create<ast::ReturnStatement>(Source{}));
@@ -1180,11 +1208,11 @@
body->append(create<ast::IfStatement>(
Source{},
create<ast::BinaryExpression>(
- ast::BinaryOp::kEqual,
+ Source{}, ast::BinaryOp::kEqual,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))),
list, ast::ElseStatementList{}));
body->append(create<ast::ReturnStatement>(Source{}));
@@ -1336,9 +1364,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -1365,9 +1394,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
diff --git a/src/writer/msl/generator_impl_identifier_test.cc b/src/writer/msl/generator_impl_identifier_test.cc
index 94f6be8..4329b53 100644
--- a/src/writer/msl/generator_impl_identifier_test.cc
+++ b/src/writer/msl/generator_impl_identifier_test.cc
@@ -26,14 +26,15 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitIdentifierExpression) {
- ast::IdentifierExpression i(mod.RegisterSymbol("foo"), "foo");
+ ast::IdentifierExpression i(Source{}, mod.RegisterSymbol("foo"), "foo");
ASSERT_TRUE(gen.EmitExpression(&i)) << gen.error();
EXPECT_EQ(gen.result(), "foo");
}
TEST_F(MslGeneratorImplTest, EmitIdentifierExpression_Single_WithCollision) {
- ast::IdentifierExpression i(mod.RegisterSymbol("virtual"), "virtual");
+ ast::IdentifierExpression i(Source{}, mod.RegisterSymbol("virtual"),
+ "virtual");
ASSERT_TRUE(gen.EmitExpression(&i)) << gen.error();
EXPECT_EQ(gen.result(), "virtual_tint_0");
diff --git a/src/writer/msl/generator_impl_if_test.cc b/src/writer/msl/generator_impl_if_test.cc
index be01567..603698d 100644
--- a/src/writer/msl/generator_impl_if_test.cc
+++ b/src/writer/msl/generator_impl_if_test.cc
@@ -29,8 +29,8 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_If) {
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
@@ -47,12 +47,12 @@
TEST_F(MslGeneratorImplTest, Emit_IfWithElseIf) {
auto* else_cond = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("else_cond"), "else_cond");
+ Source{}, mod.RegisterSymbol("else_cond"), "else_cond");
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::ReturnStatement>(Source{}));
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
@@ -74,8 +74,8 @@
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::ReturnStatement>(Source{}));
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
@@ -95,7 +95,7 @@
TEST_F(MslGeneratorImplTest, Emit_IfWithMultiple) {
auto* else_cond = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("else_cond"), "else_cond");
+ Source{}, mod.RegisterSymbol("else_cond"), "else_cond");
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::ReturnStatement>(Source{}));
@@ -103,8 +103,8 @@
auto* else_body_2 = create<ast::BlockStatement>();
else_body_2->append(create<ast::ReturnStatement>(Source{}));
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(Source{}));
diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc
index 1d654c2..e2b5c37 100644
--- a/src/writer/msl/generator_impl_import_test.cc
+++ b/src/writer/msl/generator_impl_import_test.cc
@@ -55,12 +55,12 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
auto* ident = create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name);
+ Source{}, mod.RegisterSymbol(param.name), param.name);
- ast::CallExpression call(ident, params);
+ ast::CallExpression call(Source{}, ident, params);
// The call type determination will set the intrinsic data for the ident
ASSERT_TRUE(td.DetermineResultType(&call)) << td.error();
@@ -99,11 +99,12 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
- ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("abs"), "abs"),
- params);
+ ast::CallExpression expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("abs"), "abs"),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -119,13 +120,15 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(&expr)) << gen.error();
@@ -153,28 +156,32 @@
ast::ExpressionList params;
params.push_back(create<ast::TypeConstructorExpression>(
- &vec, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.f)),
- }));
+ Source{}, &vec,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.f)),
+ }));
params.push_back(create<ast::TypeConstructorExpression>(
- &vec, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 4.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 5.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 6.f)),
- }));
+ Source{}, &vec,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 4.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 5.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 6.f)),
+ }));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(&expr)) << gen.error();
@@ -194,13 +201,15 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(&expr)) << gen.error();
@@ -219,15 +228,17 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.f)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(&expr)) << gen.error();
@@ -251,15 +262,17 @@
ast::ExpressionList params;
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod.RegisterSymbol(param.name), param.name),
- params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol(param.name), param.name),
+ params);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
ASSERT_TRUE(gen.EmitCall(&expr)) << gen.error();
@@ -285,12 +298,13 @@
ast::VariableDecorationList{}); // decorations
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("var"), "var"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("var"), "var"));
ast::CallExpression expr(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("determinant"),
- "determinant"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("determinant"), "determinant"),
params);
mod.AddGlobalVariable(var);
diff --git a/src/writer/msl/generator_impl_intrinsic_test.cc b/src/writer/msl/generator_impl_intrinsic_test.cc
index c819943..28b7eae 100644
--- a/src/writer/msl/generator_impl_intrinsic_test.cc
+++ b/src/writer/msl/generator_impl_intrinsic_test.cc
@@ -88,14 +88,15 @@
ast::VariableDecorationList{}); // decorations
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("a"), "a"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("b"), "b"));
ast::CallExpression call(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("outer_product"),
- "outer_product"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("outer_product"), "outer_product"),
params);
td.RegisterVariableForTesting(a);
@@ -122,13 +123,14 @@
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
- ast::CallExpression call(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("dot"), "dot"),
- params);
+ ast::CallExpression call(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("dot"), "dot"),
+ params);
ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec,
false, nullptr, ast::VariableDecorationList{});
diff --git a/src/writer/msl/generator_impl_intrinsic_texture_test.cc b/src/writer/msl/generator_impl_intrinsic_texture_test.cc
index 9764fba..37a806c 100644
--- a/src/writer/msl/generator_impl_intrinsic_texture_test.cc
+++ b/src/writer/msl/generator_impl_intrinsic_texture_test.cc
@@ -263,7 +263,7 @@
param.buildTextureVariable(this);
param.buildSamplerVariable(this);
- ast::CallExpression call{Expr(param.function), param.args(this)};
+ ast::CallExpression call{Source{}, Expr(param.function), param.args(this)};
ASSERT_TRUE(td.Determine()) << td.error();
ASSERT_TRUE(td.DetermineResultType(&call)) << td.error();
diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc
index 004af07..cf0f375 100644
--- a/src/writer/msl/generator_impl_loop_test.cc
+++ b/src/writer/msl/generator_impl_loop_test.cc
@@ -90,10 +90,10 @@
body = create<ast::BlockStatement>();
body->append(inner);
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("rhs"), "rhs");
continuing = create<ast::BlockStatement>();
continuing->append(create<ast::AssignmentStatement>(lhs, rhs));
@@ -158,6 +158,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.4)), // constructor
ast::VariableDecorationList{}); // decorations
@@ -172,10 +173,10 @@
nullptr, // constructor
ast::VariableDecorationList{}))); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("rhs"), "rhs");
auto* continuing = create<ast::BlockStatement>();
continuing->append(create<ast::AssignmentStatement>(lhs, rhs));
diff --git a/src/writer/msl/generator_impl_member_accessor_test.cc b/src/writer/msl/generator_impl_member_accessor_test.cc
index 643f34e..2ad3397 100644
--- a/src/writer/msl/generator_impl_member_accessor_test.cc
+++ b/src/writer/msl/generator_impl_member_accessor_test.cc
@@ -29,12 +29,12 @@
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) {
- auto* str =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("str"), "str");
- auto* mem =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mem"), "mem");
+ auto* str = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("str"), "str");
+ auto* mem = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mem"), "mem");
- ast::MemberAccessorExpression expr(str, mem);
+ ast::MemberAccessorExpression expr(Source{}, str, mem);
ASSERT_TRUE(gen.EmitExpression(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "str.mem");
diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc
index 980beea..80756e3 100644
--- a/src/writer/msl/generator_impl_module_constant_test.cc
+++ b/src/writer/msl/generator_impl_module_constant_test.cc
@@ -40,20 +40,21 @@
ast::ExpressionList exprs;
exprs.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
exprs.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
exprs.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* var = create<ast::Variable>(
- Source{}, // source
- "pos", // name
- ast::StorageClass::kNone, // storage_class
- &ary, // type
- true, // is_const
- create<ast::TypeConstructorExpression>(&ary, exprs), // constructor
- ast::VariableDecorationList{}); // decorations
+ auto* var =
+ create<ast::Variable>(Source{}, // source
+ "pos", // name
+ ast::StorageClass::kNone, // storage_class
+ &ary, // type
+ true, // is_const
+ create<ast::TypeConstructorExpression>(
+ Source{}, &ary, exprs), // constructor
+ ast::VariableDecorationList{}); // decorations
ASSERT_TRUE(gen.EmitProgramConstVariable(var)) << gen.error();
EXPECT_EQ(gen.result(), "constant float pos[3] = {1.0f, 2.0f, 3.0f};\n");
@@ -69,6 +70,7 @@
&f32, // type
true, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)), // constructor
ast::VariableDecorationList{
// decorations
diff --git a/src/writer/msl/generator_impl_return_test.cc b/src/writer/msl/generator_impl_return_test.cc
index c285996..5efbfcc 100644
--- a/src/writer/msl/generator_impl_return_test.cc
+++ b/src/writer/msl/generator_impl_return_test.cc
@@ -39,8 +39,8 @@
}
TEST_F(MslGeneratorImplTest, Emit_ReturnWithValue) {
- auto* expr =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr");
ast::ReturnStatement r(Source{}, expr);
gen.increment_indent();
diff --git a/src/writer/msl/generator_impl_switch_test.cc b/src/writer/msl/generator_impl_switch_test.cc
index 0617374..56f3b82 100644
--- a/src/writer/msl/generator_impl_switch_test.cc
+++ b/src/writer/msl/generator_impl_switch_test.cc
@@ -50,8 +50,8 @@
body.push_back(case_stmt);
body.push_back(def);
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
ast::SwitchStatement s(cond, body);
gen.increment_indent();
diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc
index c50f21d..0910b78 100644
--- a/src/writer/msl/generator_impl_test.cc
+++ b/src/writer/msl/generator_impl_test.cc
@@ -79,7 +79,7 @@
TEST_F(MslGeneratorImplTest, NameConflictWith_InputStructName) {
ASSERT_EQ(gen.generate_name("func_main_in"), "func_main_in");
- ast::IdentifierExpression ident(mod.RegisterSymbol("func_main_in"),
+ ast::IdentifierExpression ident(Source{}, mod.RegisterSymbol("func_main_in"),
"func_main_in");
ASSERT_TRUE(gen.EmitIdentifier(&ident));
EXPECT_EQ(gen.result(), "func_main_in_0");
diff --git a/src/writer/msl/generator_impl_unary_op_test.cc b/src/writer/msl/generator_impl_unary_op_test.cc
index d054bce..ad0bd07 100644
--- a/src/writer/msl/generator_impl_unary_op_test.cc
+++ b/src/writer/msl/generator_impl_unary_op_test.cc
@@ -39,9 +39,9 @@
TEST_P(MslUnaryOpTest, Emit) {
auto params = GetParam();
- auto* expr =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
- ast::UnaryOpExpression op(params.op, expr);
+ auto* expr = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr");
+ ast::UnaryOpExpression op(Source{}, params.op, expr);
ASSERT_TRUE(gen.EmitExpression(&op)) << gen.error();
EXPECT_EQ(gen.result(), std::string(params.name) + "(expr)");
diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
index 50a2830..0119490 100644
--- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc
+++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc
@@ -194,7 +194,7 @@
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
auto* ident = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("initializer"), "initializer");
+ Source{}, mod.RegisterSymbol("initializer"), "initializer");
ast::type::F32 f32;
auto* var =
@@ -218,7 +218,8 @@
ast::type::Vector vec(&f32, 3);
ast::ExpressionList values;
- auto* zero_vec = create<ast::TypeConstructorExpression>(&vec, values);
+ auto* zero_vec =
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values);
auto* var =
create<ast::Variable>(Source{}, // source
diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc
index 157e0cd..a1ce040 100644
--- a/src/writer/spirv/builder_accessor_expression_test.cc
+++ b/src/writer/spirv/builder_accessor_expression_test.cc
@@ -56,12 +56,12 @@
ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3, false,
nullptr, ast::VariableDecorationList{});
- auto* ary =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary");
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ary"), "ary");
auto* idx_expr = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1));
- ast::ArrayAccessorExpression expr(ary, idx_expr);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx_expr);
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -101,12 +101,12 @@
ast::Variable idx(Source{}, "idx", ast::StorageClass::kFunction, &i32, false,
nullptr, ast::VariableDecorationList{});
- auto* ary =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary");
- auto* idx_expr =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("idx"), "idx");
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ary"), "ary");
+ auto* idx_expr = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("idx"), "idx");
- ast::ArrayAccessorExpression expr(ary, idx_expr);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx_expr);
td.RegisterVariableForTesting(&var);
td.RegisterVariableForTesting(&idx);
@@ -148,16 +148,17 @@
ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3, false,
nullptr, ast::VariableDecorationList{});
- auto* ary =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary");
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ary"), "ary");
ast::ArrayAccessorExpression expr(
- ary, create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd,
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, ary,
+ create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kAdd,
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -198,12 +199,15 @@
nullptr, ast::VariableDecorationList{});
ast::ArrayAccessorExpression expr(
+ Source{},
create<ast::ArrayAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary"),
+ Source{},
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("ary"), "ary"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -246,11 +250,15 @@
nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::ArrayAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary"),
+ Source{},
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("ary"), "ary"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("xy"), "xy"));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("xy"),
+ "xy"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -303,8 +311,11 @@
false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"), "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("ident"),
+ "ident"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("b"),
+ "b"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -359,12 +370,15 @@
false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"),
- "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("inner"),
- "inner")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("inner"), "inner")),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("a"),
+ "a"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -422,12 +436,15 @@
false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"),
- "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("inner"),
- "inner")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("inner"), "inner")),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("a"),
+ "a"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -484,15 +501,18 @@
false, nullptr, ast::VariableDecorationList{});
auto* lhs = create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"),
- "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("inner"),
- "inner")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("inner"), "inner")),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("a"),
+ "a"));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.f));
ast::AssignmentStatement expr(lhs, rhs);
@@ -554,16 +574,19 @@
ast::Variable store(Source{}, "store", ast::StorageClass::kFunction, &f32,
false, nullptr, ast::VariableDecorationList{});
- auto* lhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("store"), "store");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("store"), "store");
auto* rhs = create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"),
- "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("inner"),
- "inner")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("inner"), "inner")),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("a"),
+ "a"));
ast::AssignmentStatement expr(lhs, rhs);
@@ -608,8 +631,11 @@
false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"), "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("y"), "y"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("ident"),
+ "ident"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("y"),
+ "y"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -645,8 +671,11 @@
false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"), "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("yx"), "yx"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("ident"),
+ "ident"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("yx"),
+ "yx"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -681,11 +710,15 @@
false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"),
- "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("yxz"), "yxz")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("xz"), "xz"));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"),
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("yxz"), "yxz")),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("xz"),
+ "xz"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -721,11 +754,15 @@
false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"),
- "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("yxz"), "yxz")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("x"), "x"));
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"),
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("yxz"), "yxz")),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("x"),
+ "x"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -761,12 +798,15 @@
false, nullptr, ast::VariableDecorationList{});
ast::ArrayAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"),
- "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("yxz"), "yxz")),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("ident"), "ident"),
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("yxz"), "yxz")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -832,23 +872,32 @@
&a_ary_type, false, nullptr, ast::VariableDecorationList{});
ast::MemberAccessorExpression expr(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::MemberAccessorExpression>(
+ Source{},
create<ast::ArrayAccessorExpression>(
+ Source{},
create<ast::IdentifierExpression>(
- mod->RegisterSymbol("index"), "index"),
+ Source{}, mod->RegisterSymbol("index"), "index"),
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::SintLiteral>(Source{}, &i32, 0))),
create<ast::IdentifierExpression>(
- mod->RegisterSymbol("foo"), "foo")),
+ Source{}, mod->RegisterSymbol("foo"), "foo")),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("bar"),
- "bar")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("baz"), "baz")),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("yx"), "yx"));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("bar"), "bar")),
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("baz"), "baz")),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("yx"),
+ "yx"));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -901,37 +950,43 @@
ast::ExpressionList ary_params;
ary_params.push_back(create<ast::TypeConstructorExpression>(
- &vec, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 0.0)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 0.5)),
- }));
+ Source{}, &vec,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 0.0)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 0.5)),
+ }));
ary_params.push_back(create<ast::TypeConstructorExpression>(
- &vec, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
- }));
+ Source{}, &vec,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
+ }));
ary_params.push_back(create<ast::TypeConstructorExpression>(
- &vec, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 0.5)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
- }));
+ Source{}, &vec,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 0.5)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
+ }));
- ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &arr, true,
- create<ast::TypeConstructorExpression>(&arr, ary_params),
- ast::VariableDecorationList{});
+ ast::Variable var(
+ Source{}, "pos", ast::StorageClass::kPrivate, &arr, true,
+ create<ast::TypeConstructorExpression>(Source{}, &arr, ary_params),
+ ast::VariableDecorationList{});
ast::ArrayAccessorExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("pos"), "pos"),
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("pos"),
+ "pos"),
create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)));
td.RegisterVariableForTesting(&var);
ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error();
@@ -977,19 +1032,21 @@
ast::ExpressionList vec_params;
vec_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 0.0)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 0.0)));
vec_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 0.5)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 0.5)));
- ast::Variable var(
- Source{}, "pos", ast::StorageClass::kPrivate, &vec, true,
- create<ast::TypeConstructorExpression>(&vec, std::move(vec_params)),
- ast::VariableDecorationList{});
+ ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &vec, true,
+ create<ast::TypeConstructorExpression>(
+ Source{}, &vec, std::move(vec_params)),
+ ast::VariableDecorationList{});
ast::ArrayAccessorExpression expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("pos"), "pos"),
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("pos"),
+ "pos"),
create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)));
+ Source{}, create<ast::UintLiteral>(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 8947438..6f557e9 100644
--- a/src/writer/spirv/builder_assign_test.cc
+++ b/src/writer/spirv/builder_assign_test.cc
@@ -47,10 +47,10 @@
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32, false,
nullptr, ast::VariableDecorationList{});
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var");
auto* val = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
ast::AssignmentStatement assign(ident, val);
@@ -83,10 +83,10 @@
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec, false,
nullptr, ast::VariableDecorationList{});
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var");
ast::ExpressionList vals;
- auto* val = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* val = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
ast::AssignmentStatement assign(ident, val);
@@ -118,25 +118,28 @@
ast::type::Vector vec2(&f32, 2);
auto* first = create<ast::TypeConstructorExpression>(
- &vec2, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f)),
- });
+ Source{}, &vec2,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f)),
+ });
auto* init = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- first,
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ first,
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
+ });
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false,
nullptr, ast::VariableDecorationList{});
ast::AssignmentStatement assign(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
init);
td.RegisterVariableForTesting(&v);
@@ -174,19 +177,20 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec3, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false,
nullptr, ast::VariableDecorationList{});
ast::AssignmentStatement assign(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
init);
td.RegisterVariableForTesting(&v);
@@ -235,11 +239,14 @@
false, nullptr, ast::VariableDecorationList{});
auto* ident = create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("ident"), "ident"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("ident"),
+ "ident"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("b"),
+ "b"));
auto* val = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 4.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 4.0f));
ast::AssignmentStatement assign(ident, val);
@@ -277,18 +284,18 @@
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false,
nullptr, ast::VariableDecorationList{});
- auto* ident =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
+ auto* ident = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var");
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* val = create<ast::TypeConstructorExpression>(&vec3, vals);
+ auto* val = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
ast::AssignmentStatement assign(ident, val);
@@ -327,10 +334,13 @@
nullptr, ast::VariableDecorationList{});
auto* ident = create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("y"), "y"));
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("y"),
+ "y"));
auto* val = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
ast::AssignmentStatement assign(ident, val);
@@ -373,11 +383,13 @@
nullptr, ast::VariableDecorationList{});
auto* ident = create<ast::ArrayAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
auto* val = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
+ Source{}, create<ast::FloatLiteral>(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 1fdfd7a..cc52ae7 100644
--- a/src/writer/spirv/builder_binary_expression_test.cc
+++ b/src/writer/spirv/builder_binary_expression_test.cc
@@ -57,11 +57,11 @@
ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 4));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 4));
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -82,26 +82,28 @@
ast::type::Vector vec3(&i32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ });
auto* rhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ });
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -124,12 +126,12 @@
ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &i32,
false, nullptr, ast::VariableDecorationList{});
- auto* lhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("param"), "param");
- auto* rhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("param"), "param");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("param"), "param");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("param"), "param");
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
td.RegisterVariableForTesting(&var);
EXPECT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -175,11 +177,11 @@
ast::type::U32 u32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 4));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 4));
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -200,26 +202,28 @@
ast::type::Vector vec3(&u32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ });
auto* rhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ });
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -256,11 +260,11 @@
ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.2f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.2f));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 4.5f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 4.5f));
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
b.push_function(Function{});
@@ -281,26 +285,28 @@
ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ });
auto* rhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ });
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -331,11 +337,11 @@
ast::type::U32 u32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 3));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 3));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 4));
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 4));
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -358,26 +364,28 @@
ast::type::Vector vec3(&u32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ });
auto* rhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::UintLiteral>(Source{}, &u32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::UintLiteral>(Source{}, &u32, 1)),
+ });
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -412,11 +420,11 @@
ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 4));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 4));
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -439,26 +447,28 @@
ast::type::Vector vec3(&i32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ });
auto* rhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
+ });
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -493,11 +503,11 @@
ast::type::F32 f32;
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.2f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.2f));
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 4.5f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 4.5f));
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -520,26 +530,28 @@
ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ });
auto* rhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ });
- ast::BinaryExpression expr(param.op, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, param.op, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -572,19 +584,20 @@
ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
+ });
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -605,18 +618,18 @@
ast::type::Vector vec3(&f32, 3);
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ auto* rhs = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -644,14 +657,14 @@
false, // is_const
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("mat"), "mat");
auto* rhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -685,13 +698,13 @@
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
auto* lhs = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f));
- auto* rhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f));
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("mat"), "mat");
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -725,21 +738,21 @@
false, // is_const
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("mat"), "mat");
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ auto* rhs = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -777,19 +790,19 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- auto* lhs = create<ast::TypeConstructorExpression>(&vec3, vals);
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ auto* lhs = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
- auto* rhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("mat"), "mat");
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -824,14 +837,14 @@
false, // is_const
nullptr, // constructor
ast::VariableDecorationList{}); // decorations
- auto* lhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
- auto* rhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("mat"), "mat");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("mat"), "mat");
td.RegisterVariableForTesting(var);
- ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kMultiply, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -856,20 +869,20 @@
ast::type::I32 i32;
auto* lhs = create<ast::BinaryExpression>(
- ast::BinaryOp::kEqual,
+ Source{}, ast::BinaryOp::kEqual,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
auto* rhs = create<ast::BinaryExpression>(
- ast::BinaryOp::kEqual,
+ Source{}, ast::BinaryOp::kEqual,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 4)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 4)));
- ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kLogicalAnd, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -907,6 +920,7 @@
&bool_type, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::BoolLiteral>(Source{}, &bool_type, true)), // constructor
ast::VariableDecorationList{}); // decorations
auto* b_var = create<ast::Variable>(
@@ -915,17 +929,20 @@
ast::StorageClass::kFunction, // storage_class
&bool_type, // type
false, // is_const
- create<ast::ScalarConstructorExpression>(create<ast::BoolLiteral>(
- Source{}, &bool_type, false)), // constructor
- ast::VariableDecorationList{}); // decorations
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type,
+ false)), // constructor
+ ast::VariableDecorationList{}); // decorations
- auto* lhs = create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a");
- auto* rhs = create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b");
+ auto* lhs = create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("a"), "a");
+ auto* rhs = create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("b"), "b");
td.RegisterVariableForTesting(a_var);
td.RegisterVariableForTesting(b_var);
- ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kLogicalAnd, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -964,16 +981,16 @@
// From: crbug.com/tint/355
auto* logical_and_expr = create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalAnd,
+ Source{}, ast::BinaryOp::kLogicalAnd,
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_ty, false)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_ty, false)));
ast::BinaryExpression expr(
- ast::BinaryOp::kLogicalOr,
+ Source{}, ast::BinaryOp::kLogicalOr,
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
logical_and_expr);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -1011,16 +1028,16 @@
// From: crbug.com/tint/355
auto* logical_or_expr = create<ast::BinaryExpression>(
- ast::BinaryOp::kLogicalOr,
+ Source{}, ast::BinaryOp::kLogicalOr,
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_ty, false)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_ty, false)));
ast::BinaryExpression expr(
- ast::BinaryOp::kLogicalAnd,
+ Source{}, ast::BinaryOp::kLogicalAnd,
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
logical_or_expr);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -1054,20 +1071,20 @@
ast::type::I32 i32;
auto* lhs = create<ast::BinaryExpression>(
- ast::BinaryOp::kEqual,
+ Source{}, ast::BinaryOp::kEqual,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)));
auto* rhs = create<ast::BinaryExpression>(
- ast::BinaryOp::kEqual,
+ Source{}, ast::BinaryOp::kEqual,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3)),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 4)));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 4)));
- ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kLogicalOr, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -1105,6 +1122,7 @@
&bool_type, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::BoolLiteral>(Source{}, &bool_type, true)), // constructor
ast::VariableDecorationList{}); // decorations
auto* b_var = create<ast::Variable>(
@@ -1113,17 +1131,20 @@
ast::StorageClass::kFunction, // storage_class
&bool_type, // type
false, // is_const
- create<ast::ScalarConstructorExpression>(create<ast::BoolLiteral>(
- Source{}, &bool_type, false)), // constructor
- ast::VariableDecorationList{}); // decorations
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type,
+ false)), // constructor
+ ast::VariableDecorationList{}); // decorations
- auto* lhs = create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a");
- auto* rhs = create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b");
+ auto* lhs = create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("a"), "a");
+ auto* rhs = create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("b"), "b");
td.RegisterVariableForTesting(a_var);
td.RegisterVariableForTesting(b_var);
- ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kLogicalOr, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
diff --git a/src/writer/spirv/builder_bitcast_expression_test.cc b/src/writer/spirv/builder_bitcast_expression_test.cc
index b9ccae7..cb75092 100644
--- a/src/writer/spirv/builder_bitcast_expression_test.cc
+++ b/src/writer/spirv/builder_bitcast_expression_test.cc
@@ -36,8 +36,9 @@
ast::type::F32 f32;
ast::BitcastExpression bitcast(
- &u32, create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
+ Source{}, &u32,
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
ASSERT_TRUE(td.DetermineResultType(&bitcast)) << td.error();
@@ -57,8 +58,9 @@
ast::type::F32 f32;
ast::BitcastExpression bitcast(
- &f32, create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
+ Source{}, &f32,
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(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 7dea26e..43977b9 100644
--- a/src/writer/spirv/builder_block_test.cc
+++ b/src/writer/spirv/builder_block_test.cc
@@ -50,9 +50,10 @@
nullptr, // constructor
ast::VariableDecorationList{}))); // decorations
outer.append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
auto* inner = create<ast::BlockStatement>();
inner->append(create<ast::VariableDeclStatement>(
@@ -64,15 +65,17 @@
nullptr, // constructor
ast::VariableDecorationList{}))); // decorations
inner->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f))));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f))));
outer.append(inner);
outer.append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("var"),
+ "var"),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f))));
+ Source{}, create<ast::FloatLiteral>(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 e7a7b52..8607589 100644
--- a/src/writer/spirv/builder_call_test.cc
+++ b/src/writer/spirv/builder_call_test.cc
@@ -63,11 +63,12 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd,
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b"))));
+ Source{}, create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kAdd,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("b"), "b"))));
ast::Function a_func(Source{}, mod->RegisterSymbol("a_func"), "a_func",
func_params, &f32, body, ast::FunctionDecorationList{});
@@ -77,13 +78,15 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
call_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- ast::CallExpression expr(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("a_func"), "a_func"),
- call_params);
+ ast::CallExpression expr(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("a_func"),
+ "a_func"),
+ call_params);
ASSERT_TRUE(td.DetermineFunction(&func)) << td.error();
ASSERT_TRUE(td.DetermineFunction(&a_func)) << td.error();
@@ -143,11 +146,12 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd,
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b"))));
+ Source{}, create<ast::BinaryExpression>(
+ Source{}, ast::BinaryOp::kAdd,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("b"), "b"))));
ast::Function a_func(Source{}, mod->RegisterSymbol("a_func"), "a_func",
func_params, &void_type, body,
@@ -159,14 +163,15 @@
ast::ExpressionList call_params;
call_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
call_params.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
- ast::CallStatement expr(
- create<ast::CallExpression>(create<ast::IdentifierExpression>(
- mod->RegisterSymbol("a_func"), "a_func"),
- call_params));
+ ast::CallStatement expr(create<ast::CallExpression>(
+ Source{},
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("a_func"),
+ "a_func"),
+ call_params));
ASSERT_TRUE(td.DetermineFunction(&func)) << td.error();
ASSERT_TRUE(td.DetermineFunction(&a_func)) << td.error();
diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc
index 7f322a6..2b1fdef 100644
--- a/src/writer/spirv/builder_constructor_expression_test.cc
+++ b/src/writer/spirv/builder_constructor_expression_test.cc
@@ -104,7 +104,7 @@
ast::type::Alias alias(mod->RegisterSymbol("Int"), "Int", ty.i32);
- ast::TypeConstructorExpression cast(&alias, ExprList(2.3f));
+ ast::TypeConstructorExpression cast(Source{}, &alias, ExprList(2.3f));
ASSERT_TRUE(td.DetermineResultType(&cast)) << td.error();
@@ -173,8 +173,8 @@
}
TEST_F(SpvBuilderConstructorTest, Type_NonConst_Value_Fails) {
- auto* rel = create<ast::BinaryExpression>(ast::BinaryOp::kAdd, Expr(3.0f),
- Expr(3.0f));
+ auto* rel = create<ast::BinaryExpression>(Source{}, ast::BinaryOp::kAdd,
+ Expr(3.0f), Expr(3.0f));
auto* t = vec2<f32>(1.0f, rel);
@@ -186,7 +186,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Bool_With_Bool) {
- ast::TypeConstructorExpression cast(ty.bool_, ExprList(true));
+ ast::TypeConstructorExpression cast(Source{}, ty.bool_, ExprList(true));
ASSERT_TRUE(td.DetermineResultType(&cast)) << td.error();
@@ -202,7 +202,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_I32_With_I32) {
- ast::TypeConstructorExpression cast(ty.i32, ExprList(2));
+ ast::TypeConstructorExpression cast(Source{}, ty.i32, ExprList(2));
ASSERT_TRUE(td.DetermineResultType(&cast)) << td.error();
@@ -216,7 +216,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_U32_With_U32) {
- ast::TypeConstructorExpression cast(ty.u32, ExprList(2u));
+ ast::TypeConstructorExpression cast(Source{}, ty.u32, ExprList(2u));
ASSERT_TRUE(td.DetermineResultType(&cast)) << td.error();
@@ -230,7 +230,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_F32_With_F32) {
- ast::TypeConstructorExpression cast(ty.f32, ExprList(2.0f));
+ ast::TypeConstructorExpression cast(Source{}, ty.f32, ExprList(2.0f));
ASSERT_TRUE(td.DetermineResultType(&cast)) << td.error();
diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc
index f349f2e..67a294c 100644
--- a/src/writer/spirv/builder_function_decoration_test.cc
+++ b/src/writer/spirv/builder_function_decoration_test.cc
@@ -165,19 +165,20 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_out"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_out"),
"my_out"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_in"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_in"),
"my_in")));
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_wg"), "my_wg"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_wg"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_wg"),
+ "my_wg"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_wg"),
"my_wg")));
// Add duplicate usages so we show they don't get output multiple times.
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_out"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_out"),
"my_out"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("my_in"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("my_in"),
"my_in")));
ast::Function func(
diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc
index db78c03..6c7aefd 100644
--- a/src/writer/spirv/builder_function_test.cc
+++ b/src/writer/spirv/builder_function_test.cc
@@ -98,8 +98,8 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a")));
ASSERT_TRUE(td.DetermineResultType(body)) << td.error();
ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {},
@@ -168,8 +168,8 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(
- Source{},
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a")));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a")));
ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", params,
&f32, body, ast::FunctionDecorationList{});
@@ -301,9 +301,11 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -330,9 +332,11 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod->RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{},
+ mod->RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc
index 8e40bad..e33a4c0 100644
--- a/src/writer/spirv/builder_function_variable_test.cc
+++ b/src/writer/spirv/builder_function_variable_test.cc
@@ -70,13 +70,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -111,18 +111,18 @@
ast::type::Vector vec(&f32, 2);
auto* rel = create<ast::BinaryExpression>(
- ast::BinaryOp::kAdd,
+ Source{}, ast::BinaryOp::kAdd,
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(rel);
- auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -160,7 +160,7 @@
ast::type::F32 f32;
auto* init = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
ASSERT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -168,10 +168,10 @@
init, ast::VariableDecorationList{});
td.RegisterVariableForTesting(&v);
- ast::Variable v2(
- Source{}, "v2", ast::StorageClass::kFunction, &f32, false,
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
- ast::VariableDecorationList{});
+ ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32, false,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v"), "v"),
+ ast::VariableDecorationList{});
td.RegisterVariableForTesting(&v2);
ASSERT_TRUE(td.DetermineResultType(v2.constructor())) << td.error();
@@ -207,7 +207,7 @@
ast::type::F32 f32;
auto* init = create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -215,10 +215,10 @@
init, ast::VariableDecorationList{});
td.RegisterVariableForTesting(&v);
- ast::Variable v2(
- Source{}, "v2", ast::StorageClass::kFunction, &f32, true,
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
- ast::VariableDecorationList{});
+ ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32, true,
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("v"), "v"),
+ ast::VariableDecorationList{});
td.RegisterVariableForTesting(&v2);
ASSERT_TRUE(td.DetermineResultType(v2.constructor())) << td.error();
@@ -250,13 +250,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc
index 9a8f136..126b535 100644
--- a/src/writer/spirv/builder_global_variable_test.cc
+++ b/src/writer/spirv/builder_global_variable_test.cc
@@ -99,13 +99,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -135,13 +135,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -168,12 +168,12 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec3, vals);
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec3, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -199,19 +199,21 @@
ast::type::Vector vec2(&f32, 2);
auto* first = create<ast::TypeConstructorExpression>(
- &vec2, ast::ExpressionList{
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)),
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 2.0f)),
- });
+ Source{}, &vec2,
+ ast::ExpressionList{
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)),
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.0f)),
+ });
auto* init = create<ast::TypeConstructorExpression>(
- &vec3, ast::ExpressionList{
- first,
- create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
- });
+ Source{}, &vec3,
+ ast::ExpressionList{
+ first,
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
+ });
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -328,6 +330,7 @@
&bool_type, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::BoolLiteral>(Source{}, &bool_type, true)), // constructor
ast::VariableDecorationList{
// decorations
@@ -383,6 +386,7 @@
&f32, // type
false, // is_const
create<ast::ScalarConstructorExpression>(
+ Source{},
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{
// decorations
diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc
index 4f1f3af..48cd6b2 100644
--- a/src/writer/spirv/builder_ident_expression_test.cc
+++ b/src/writer/spirv/builder_ident_expression_test.cc
@@ -43,13 +43,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -68,7 +68,7 @@
%5 = OpConstantComposite %1 %3 %3 %4
)");
- ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var");
+ ast::IdentifierExpression expr(Source{}, mod->RegisterSymbol("var"), "var");
ASSERT_TRUE(td.DetermineResultType(&expr));
EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 5u);
@@ -91,7 +91,7 @@
%1 = OpVariable %2 Output %4
)");
- ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var");
+ ast::IdentifierExpression expr(Source{}, mod->RegisterSymbol("var"), "var");
ASSERT_TRUE(td.DetermineResultType(&expr));
EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 1u);
}
@@ -102,13 +102,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* init = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
@@ -126,7 +126,7 @@
%5 = OpConstantComposite %1 %3 %3 %4
)");
- ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var");
+ ast::IdentifierExpression expr(Source{}, mod->RegisterSymbol("var"), "var");
ASSERT_TRUE(td.DetermineResultType(&expr));
EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 5u);
}
@@ -152,7 +152,7 @@
R"(%1 = OpVariable %2 Function %4
)");
- ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var");
+ ast::IdentifierExpression expr(Source{}, mod->RegisterSymbol("var"), "var");
ASSERT_TRUE(td.DetermineResultType(&expr));
EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 1u);
}
@@ -165,12 +165,12 @@
td.RegisterVariableForTesting(&var);
- auto* lhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
- auto* rhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var");
- ast::BinaryExpression expr(ast::BinaryOp::kAdd, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kAdd, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -195,17 +195,17 @@
ast::Variable var(Source{}, "var", ast::StorageClass::kNone, &i32, true,
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2)),
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2)),
ast::VariableDecorationList{});
td.RegisterVariableForTesting(&var);
- auto* lhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
- auto* rhs =
- create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("var"), "var");
- ast::BinaryExpression expr(ast::BinaryOp::kAdd, lhs, rhs);
+ ast::BinaryExpression expr(Source{}, ast::BinaryOp::kAdd, lhs, rhs);
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc
index e3724bb..f5050ea 100644
--- a/src/writer/spirv/builder_if_test.cc
+++ b/src/writer/spirv/builder_if_test.cc
@@ -46,7 +46,7 @@
// if (true) {
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
ast::IfStatement expr(Source{}, cond, create<ast::BlockStatement>(),
ast::ElseStatementList{});
@@ -86,12 +86,13 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
ast::IfStatement expr(Source{}, cond, body, ast::ElseStatementList{});
@@ -140,18 +141,20 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))));
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
ast::IfStatement expr(Source{}, cond, body,
{create<ast::ElseStatement>(else_body)});
@@ -206,21 +209,23 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))));
auto* else_cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
ast::IfStatement expr(Source{}, cond, body,
{create<ast::ElseStatement>(else_cond, else_body)});
@@ -284,32 +289,36 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* elseif_1_body = create<ast::BlockStatement>();
elseif_1_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))));
auto* elseif_2_body = create<ast::BlockStatement>();
elseif_2_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 4))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 4))));
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 5))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 5))));
auto* elseif_1_cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* elseif_2_cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, false));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, false));
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
ast::IfStatement expr(
Source{}, cond, body,
@@ -376,7 +385,7 @@
// }
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* if_body = create<ast::BlockStatement>();
if_body->append(create<ast::BreakStatement>());
@@ -424,7 +433,7 @@
// }
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::BreakStatement>());
@@ -474,7 +483,7 @@
// }
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* if_body = create<ast::BlockStatement>();
if_body->append(create<ast::ContinueStatement>());
@@ -522,7 +531,7 @@
// }
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::ContinueStatement>());
@@ -570,7 +579,7 @@
// return;
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* if_body = create<ast::BlockStatement>();
if_body->append(create<ast::ReturnStatement>(Source{}));
@@ -600,9 +609,9 @@
// return false;
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* cond2 = create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, false));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, false));
auto* if_body = create<ast::BlockStatement>();
if_body->append(create<ast::ReturnStatement>(Source{}, cond2));
@@ -643,10 +652,11 @@
ast::VariableDecorationList{}); // decorations
td.RegisterVariableForTesting(var);
- ast::IfStatement expr(
- Source{},
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"),
- create<ast::BlockStatement>(), ast::ElseStatementList{});
+ ast::IfStatement expr(Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ create<ast::BlockStatement>(),
+ ast::ElseStatementList{});
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc
index d839c9c..de5055b 100644
--- a/src/writer/spirv/builder_intrinsic_test.cc
+++ b/src/writer/spirv/builder_intrinsic_test.cc
@@ -1315,8 +1315,8 @@
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
- auto expr = Call("arrayLength",
- create<ast::MemberAccessorExpression>(Expr("b"), Expr("a")));
+ auto expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
+ Source{}, Expr("b"), Expr("a")));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -1355,8 +1355,8 @@
ast::type::Struct s_type("my_struct", s);
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
- auto expr = Call("arrayLength",
- create<ast::MemberAccessorExpression>(Expr("b"), Expr("a")));
+ auto expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
+ Source{}, Expr("b"), Expr("a")));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -1400,7 +1400,8 @@
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
Var("ptr_var", ast::StorageClass::kPrivate, &ptr,
- create<ast::MemberAccessorExpression>(Expr("b"), Expr("a")), {});
+ create<ast::MemberAccessorExpression>(Source{}, Expr("b"), Expr("a")),
+ {});
auto expr = Call("arrayLength", "ptr_var");
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
diff --git a/src/writer/spirv/builder_intrinsic_texture_test.cc b/src/writer/spirv/builder_intrinsic_texture_test.cc
index 858b3ba..1c8cc12 100644
--- a/src/writer/spirv/builder_intrinsic_texture_test.cc
+++ b/src/writer/spirv/builder_intrinsic_texture_test.cc
@@ -2723,7 +2723,7 @@
auto* texture = param.buildTextureVariable(this);
auto* sampler = param.buildSamplerVariable(this);
- ast::CallExpression call{Expr(param.function), param.args(this)};
+ ast::CallExpression call{Source{}, Expr(param.function), param.args(this)};
EXPECT_TRUE(td.Determine()) << td.error();
EXPECT_TRUE(td.DetermineResultType(&call)) << td.error();
diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc
index 98cffeb..3fa284d 100644
--- a/src/writer/spirv/builder_loop_test.cc
+++ b/src/writer/spirv/builder_loop_test.cc
@@ -76,9 +76,10 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
ast::LoopStatement expr(body, create<ast::BlockStatement>());
@@ -129,15 +130,17 @@
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* continuing = create<ast::BlockStatement>();
continuing->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(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 8c66100..8800100 100644
--- a/src/writer/spirv/builder_return_test.cc
+++ b/src/writer/spirv/builder_return_test.cc
@@ -51,13 +51,13 @@
ast::ExpressionList vals;
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
vals.push_back(create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
- auto* val = create<ast::TypeConstructorExpression>(&vec, vals);
+ auto* val = create<ast::TypeConstructorExpression>(Source{}, &vec, vals);
ast::ReturnStatement ret(Source{}, val);
@@ -85,8 +85,8 @@
false, nullptr, ast::VariableDecorationList{});
ast::ReturnStatement ret(
- Source{},
- create<ast::IdentifierExpression>(mod->RegisterSymbol("param"), "param"));
+ Source{}, create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("param"), "param"));
td.RegisterVariableForTesting(&var);
EXPECT_TRUE(td.DetermineResultType(&ret)) << td.error();
diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc
index 4ace391..10341be 100644
--- a/src/writer/spirv/builder_switch_test.cc
+++ b/src/writer/spirv/builder_switch_test.cc
@@ -45,7 +45,7 @@
// switch (1) {
// }
auto* cond = create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1));
ast::SwitchStatement expr(cond, ast::CaseStatementList{});
@@ -95,15 +95,17 @@
auto* case_1_body = create<ast::BlockStatement>();
case_1_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))));
auto* case_2_body = create<ast::BlockStatement>();
case_2_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
ast::CaseSelectorList selector_1;
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
@@ -115,8 +117,9 @@
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
cases.push_back(create<ast::CaseStatement>(selector_2, case_2_body));
- ast::SwitchStatement expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"), cases);
+ ast::SwitchStatement expr(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ cases);
td.RegisterVariableForTesting(v);
td.RegisterVariableForTesting(a);
@@ -189,15 +192,17 @@
auto* default_body = create<ast::BlockStatement>();
default_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))));
ast::CaseStatementList cases;
cases.push_back(create<ast::CaseStatement>(default_body));
- ast::SwitchStatement expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"), cases);
+ ast::SwitchStatement expr(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ cases);
td.RegisterVariableForTesting(v);
td.RegisterVariableForTesting(a);
@@ -268,21 +273,24 @@
auto* case_1_body = create<ast::BlockStatement>();
case_1_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))));
auto* case_2_body = create<ast::BlockStatement>();
case_2_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* default_body = create<ast::BlockStatement>();
default_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))));
ast::CaseSelectorList selector_1;
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
@@ -296,8 +304,9 @@
cases.push_back(create<ast::CaseStatement>(selector_2, case_2_body));
cases.push_back(create<ast::CaseStatement>(default_body));
- ast::SwitchStatement expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"), cases);
+ ast::SwitchStatement expr(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ cases);
td.RegisterVariableForTesting(v);
td.RegisterVariableForTesting(a);
@@ -377,22 +386,25 @@
auto* case_1_body = create<ast::BlockStatement>();
case_1_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))));
case_1_body->append(create<ast::FallthroughStatement>());
auto* case_2_body = create<ast::BlockStatement>();
case_2_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 2))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 2))));
auto* default_body = create<ast::BlockStatement>();
default_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 3))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 3))));
ast::CaseSelectorList selector_1;
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
@@ -405,8 +417,9 @@
cases.push_back(create<ast::CaseStatement>(selector_2, case_2_body));
cases.push_back(create<ast::CaseStatement>(default_body));
- ast::SwitchStatement expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"), cases);
+ ast::SwitchStatement expr(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ cases);
td.RegisterVariableForTesting(v);
td.RegisterVariableForTesting(a);
@@ -482,9 +495,10 @@
auto* case_1_body = create<ast::BlockStatement>();
case_1_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))));
case_1_body->append(create<ast::FallthroughStatement>());
ast::CaseSelectorList selector_1;
@@ -493,8 +507,9 @@
ast::CaseStatementList cases;
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
- ast::SwitchStatement expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"), cases);
+ ast::SwitchStatement expr(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ cases);
td.RegisterVariableForTesting(v);
td.RegisterVariableForTesting(a);
@@ -548,13 +563,14 @@
case_1_body->append(create<ast::IfStatement>(
Source{},
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, true)),
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true)),
if_body, ast::ElseStatementList{}));
case_1_body->append(create<ast::AssignmentStatement>(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("v"),
+ "v"),
create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1))));
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1))));
ast::CaseSelectorList selector_1;
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
@@ -562,8 +578,9 @@
ast::CaseStatementList cases;
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
- ast::SwitchStatement expr(
- create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"), cases);
+ ast::SwitchStatement expr(create<ast::IdentifierExpression>(
+ Source{}, mod->RegisterSymbol("a"), "a"),
+ cases);
td.RegisterVariableForTesting(v);
td.RegisterVariableForTesting(a);
diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc
index ab14418..e633b48 100644
--- a/src/writer/spirv/builder_unary_op_expression_test.cc
+++ b/src/writer/spirv/builder_unary_op_expression_test.cc
@@ -40,9 +40,10 @@
TEST_F(BuilderTest, UnaryOp_Negation_Integer) {
ast::type::I32 i32;
- ast::UnaryOpExpression expr(ast::UnaryOp::kNegation,
- create<ast::ScalarConstructorExpression>(
- create<ast::SintLiteral>(Source{}, &i32, 1)));
+ ast::UnaryOpExpression expr(
+ Source{}, ast::UnaryOp::kNegation,
+ create<ast::ScalarConstructorExpression>(
+ Source{}, create<ast::SintLiteral>(Source{}, &i32, 1)));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -60,9 +61,9 @@
ast::type::F32 f32;
ast::UnaryOpExpression expr(
- ast::UnaryOp::kNegation,
+ Source{}, ast::UnaryOp::kNegation,
create<ast::ScalarConstructorExpression>(
- create<ast::FloatLiteral>(Source{}, &f32, 1)));
+ Source{}, create<ast::FloatLiteral>(Source{}, &f32, 1)));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -80,9 +81,9 @@
ast::type::Bool bool_type;
ast::UnaryOpExpression expr(
- ast::UnaryOp::kNot,
+ Source{}, ast::UnaryOp::kNot,
create<ast::ScalarConstructorExpression>(
- create<ast::BoolLiteral>(Source{}, &bool_type, false)));
+ Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, false)));
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
@@ -104,8 +105,9 @@
false, nullptr, ast::VariableDecorationList{});
ast::UnaryOpExpression expr(
- ast::UnaryOp::kNegation,
- create<ast::IdentifierExpression>(mod->RegisterSymbol("param"), "param"));
+ Source{}, ast::UnaryOp::kNegation,
+ create<ast::IdentifierExpression>(Source{}, mod->RegisterSymbol("param"),
+ "param"));
td.RegisterVariableForTesting(&var);
EXPECT_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 06c7619..551600d 100644
--- a/src/writer/wgsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc
@@ -33,23 +33,23 @@
TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) {
ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(Source{}, &i32, 5);
- auto* idx = create<ast::ScalarConstructorExpression>(lit);
- auto* ary =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
+ auto* idx = create<ast::ScalarConstructorExpression>(Source{}, lit);
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ary"), "ary");
- ast::ArrayAccessorExpression expr(ary, idx);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx);
ASSERT_TRUE(gen.EmitExpression(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "ary[5]");
}
TEST_F(WgslGeneratorImplTest, EmitArrayAccessor) {
- auto* ary =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
- auto* idx =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("idx"), "idx");
+ auto* ary = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("ary"), "ary");
+ auto* idx = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("idx"), "idx");
- ast::ArrayAccessorExpression expr(ary, idx);
+ ast::ArrayAccessorExpression expr(Source{}, ary, idx);
ASSERT_TRUE(gen.EmitArrayAccessor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "ary[idx]");
diff --git a/src/writer/wgsl/generator_impl_assign_test.cc b/src/writer/wgsl/generator_impl_assign_test.cc
index 891eeed..436a0a2 100644
--- a/src/writer/wgsl/generator_impl_assign_test.cc
+++ b/src/writer/wgsl/generator_impl_assign_test.cc
@@ -29,10 +29,10 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, Emit_Assign) {
- auto* lhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("lhs"), "lhs");
- auto* rhs =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("rhs"), "rhs");
+ auto* lhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("lhs"), "lhs");
+ auto* rhs = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("rhs"), "rhs");
ast::AssignmentStatement assign(lhs, rhs);
gen.increment_indent();
diff --git a/src/writer/wgsl/generator_impl_binary_test.cc b/src/writer/wgsl/generator_impl_binary_test.cc
index 0ad8c07..2c55ab6 100644
--- a/src/writer/wgsl/generator_impl_binary_test.cc
+++ b/src/writer/wgsl/generator_impl_binary_test.cc
@@ -37,12 +37,12 @@
TEST_P(WgslBinaryTest, Emit) {
auto params = GetParam();
- auto* left =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("left"), "left");
- auto* right =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("right"), "right");
+ auto* left = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("left"), "left");
+ auto* right = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("right"), "right");
- ast::BinaryExpression expr(params.op, left, right);
+ ast::BinaryExpression expr(Source{}, params.op, left, right);
ASSERT_TRUE(gen.EmitExpression(&expr)) << gen.error();
EXPECT_EQ(gen.result(), params.result);
diff --git a/src/writer/wgsl/generator_impl_bitcast_test.cc b/src/writer/wgsl/generator_impl_bitcast_test.cc
index bf1cc6b..26f7257 100644
--- a/src/writer/wgsl/generator_impl_bitcast_test.cc
+++ b/src/writer/wgsl/generator_impl_bitcast_test.cc
@@ -30,8 +30,9 @@
TEST_F(WgslGeneratorImplTest, EmitExpression_Bitcast) {
ast::type::F32 f32;
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id");
- ast::BitcastExpression bitcast(&f32, id);
+ auto* id = create<ast::IdentifierExpression>(Source{},
+ mod.RegisterSymbol("id"), "id");
+ ast::BitcastExpression bitcast(Source{}, &f32, id);
ASSERT_TRUE(gen.EmitExpression(&bitcast)) << gen.error();
EXPECT_EQ(gen.result(), "bitcast<f32>(id)");
diff --git a/src/writer/wgsl/generator_impl_call_test.cc b/src/writer/wgsl/generator_impl_call_test.cc
index 77cf83c..1855d0c 100644
--- a/src/writer/wgsl/generator_impl_call_test.cc
+++ b/src/writer/wgsl/generator_impl_call_test.cc
@@ -29,38 +29,38 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
- ast::CallExpression call(id, {});
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
+ ast::CallExpression call(Source{}, id, {});
ASSERT_TRUE(gen.EmitExpression(&call)) << gen.error();
EXPECT_EQ(gen.result(), "my_func()");
}
TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithParams) {
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
- ast::CallExpression call(id, params);
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
+ ast::CallExpression call(Source{}, id, params);
ASSERT_TRUE(gen.EmitExpression(&call)) << gen.error();
EXPECT_EQ(gen.result(), "my_func(param1, param2)");
}
TEST_F(WgslGeneratorImplTest, EmitStatement_Call) {
- auto* id = create<ast::IdentifierExpression>(mod.RegisterSymbol("my_func"),
- "my_func");
+ auto* id = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("my_func"), "my_func");
ast::ExpressionList params;
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param1"), "param1"));
+ Source{}, mod.RegisterSymbol("param1"), "param1"));
params.push_back(create<ast::IdentifierExpression>(
- mod.RegisterSymbol("param2"), "param2"));
+ Source{}, mod.RegisterSymbol("param2"), "param2"));
- ast::CallStatement call(create<ast::CallExpression>(id, params));
+ ast::CallStatement call(create<ast::CallExpression>(Source{}, id, params));
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(&call)) << gen.error();
diff --git a/src/writer/wgsl/generator_impl_cast_test.cc b/src/writer/wgsl/generator_impl_cast_test.cc
index a0e9f1b..97b5fc6 100644
--- a/src/writer/wgsl/generator_impl_cast_test.cc
+++ b/src/writer/wgsl/generator_impl_cast_test.cc
@@ -32,10 +32,10 @@
ast::type::F32 f32;
ast::ExpressionList params;
- params.push_back(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("id"), "id"));
+ params.push_back(create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("id"), "id"));
- ast::TypeConstructorExpression cast(&f32, params);
+ ast::TypeConstructorExpression cast(Source{}, &f32, params);
ASSERT_TRUE(gen.EmitExpression(&cast)) << gen.error();
EXPECT_EQ(gen.result(), "f32(id)");
diff --git a/src/writer/wgsl/generator_impl_constructor_test.cc b/src/writer/wgsl/generator_impl_constructor_test.cc
index f945e55..cc6a30d 100644
--- a/src/writer/wgsl/generator_impl_constructor_test.cc
+++ b/src/writer/wgsl/generator_impl_constructor_test.cc
@@ -38,7 +38,7 @@
TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) {
ast::type::Bool bool_type;
auto* lit = create<ast::BoolLiteral>(Source{}, &bool_type, false);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "false");
@@ -47,7 +47,7 @@
TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) {
ast::type::I32 i32;
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "-12345");
@@ -56,7 +56,7 @@
TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) {
ast::type::U32 u32;
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 56779);
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "56779u");
@@ -67,7 +67,7 @@
// Use a number close to 1<<30 but whose decimal representation ends in 0.
auto* lit = create<ast::FloatLiteral>(Source{}, &f32,
static_cast<float>((1 << 30) - 4));
- ast::ScalarConstructorExpression expr(lit);
+ ast::ScalarConstructorExpression expr(Source{}, lit);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "1073741824.0");
@@ -78,9 +78,9 @@
auto* lit = create<ast::FloatLiteral>(Source{}, &f32, -1.2e-5);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&f32, values);
+ ast::TypeConstructorExpression expr(Source{}, &f32, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "f32(-0.000012)");
@@ -91,9 +91,9 @@
auto* lit = create<ast::BoolLiteral>(Source{}, &b, true);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&b, values);
+ ast::TypeConstructorExpression expr(Source{}, &b, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "bool(true)");
@@ -104,9 +104,9 @@
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&i32, values);
+ ast::TypeConstructorExpression expr(Source{}, &i32, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "i32(-12345)");
@@ -117,9 +117,9 @@
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 12345);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit));
- ast::TypeConstructorExpression expr(&u32, values);
+ ast::TypeConstructorExpression expr(Source{}, &u32, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "u32(12345u)");
@@ -133,11 +133,11 @@
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32, 2.f);
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32, 3.f);
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- ast::TypeConstructorExpression expr(&vec, values);
+ ast::TypeConstructorExpression expr(Source{}, &vec, values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "vec3<f32>(1.0, 2.0, 3.0)");
@@ -158,13 +158,14 @@
static_cast<float>(2 + (i * 2)));
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
- mat_values.push_back(create<ast::TypeConstructorExpression>(&vec, values));
+ mat_values.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values));
}
- ast::TypeConstructorExpression expr(&mat, mat_values);
+ ast::TypeConstructorExpression expr(Source{}, &mat, mat_values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(), std::string("mat2x3<f32>(vec2<f32>(1.0, 2.0), ") +
@@ -187,14 +188,15 @@
static_cast<float>(3 + (i * 3)));
ast::ExpressionList values;
- values.push_back(create<ast::ScalarConstructorExpression>(lit1));
- values.push_back(create<ast::ScalarConstructorExpression>(lit2));
- values.push_back(create<ast::ScalarConstructorExpression>(lit3));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit1));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit2));
+ values.push_back(create<ast::ScalarConstructorExpression>(Source{}, lit3));
- ary_values.push_back(create<ast::TypeConstructorExpression>(&vec, values));
+ ary_values.push_back(
+ create<ast::TypeConstructorExpression>(Source{}, &vec, values));
}
- ast::TypeConstructorExpression expr(&ary, ary_values);
+ ast::TypeConstructorExpression expr(Source{}, &ary, ary_values);
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
EXPECT_EQ(gen.result(),
diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc
index 2f44fa9..21407f7 100644
--- a/src/writer/wgsl/generator_impl_function_test.cc
+++ b/src/writer/wgsl/generator_impl_function_test.cc
@@ -230,9 +230,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
@@ -259,9 +260,10 @@
&f32, // type
false, // is_const
create<ast::MemberAccessorExpression>(
- create<ast::IdentifierExpression>(mod.RegisterSymbol("data"),
- "data"),
- create<ast::IdentifierExpression>(mod.RegisterSymbol("d"),
+ Source{},
+ create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("data"), "data"),
+ create<ast::IdentifierExpression>(Source{}, mod.RegisterSymbol("d"),
"d")), // constructor
ast::VariableDecorationList{}); // decorations
diff --git a/src/writer/wgsl/generator_impl_identifier_test.cc b/src/writer/wgsl/generator_impl_identifier_test.cc
index d01e3ea..4b50990 100644
--- a/src/writer/wgsl/generator_impl_identifier_test.cc
+++ b/src/writer/wgsl/generator_impl_identifier_test.cc
@@ -24,7 +24,7 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitIdentifierExpression_Single) {
- ast::IdentifierExpression i(mod.RegisterSymbol("glsl"), "glsl");
+ ast::IdentifierExpression i(Source{}, mod.RegisterSymbol("glsl"), "glsl");
ASSERT_TRUE(gen.EmitExpression(&i)) << gen.error();
EXPECT_EQ(gen.result(), "glsl");
diff --git a/src/writer/wgsl/generator_impl_if_test.cc b/src/writer/wgsl/generator_impl_if_test.cc
index 29051a9..8b3e0e9 100644
--- a/src/writer/wgsl/generator_impl_if_test.cc
+++ b/src/writer/wgsl/generator_impl_if_test.cc
@@ -28,8 +28,8 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, Emit_If) {
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::DiscardStatement>());
@@ -46,12 +46,12 @@
TEST_F(WgslGeneratorImplTest, Emit_IfWithElseIf) {
auto* else_cond = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("else_cond"), "else_cond");
+ Source{}, mod.RegisterSymbol("else_cond"), "else_cond");
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::DiscardStatement>());
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::DiscardStatement>());
@@ -73,8 +73,8 @@
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::DiscardStatement>());
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::DiscardStatement>());
@@ -94,7 +94,7 @@
TEST_F(WgslGeneratorImplTest, Emit_IfWithMultiple) {
auto* else_cond = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("else_cond"), "else_cond");
+ Source{}, mod.RegisterSymbol("else_cond"), "else_cond");
auto* else_body = create<ast::BlockStatement>();
else_body->append(create<ast::DiscardStatement>());
@@ -102,8 +102,8 @@
auto* else_body_2 = create<ast::BlockStatement>();
else_body_2->append(create<ast::DiscardStatement>());
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
auto* body = create<ast::BlockStatement>();
body->append(create<ast::DiscardStatement>());
diff --git a/src/writer/wgsl/generator_impl_member_accessor_test.cc b/src/writer/wgsl/generator_impl_member_accessor_test.cc
index fd5be5a..d01c0ce 100644
--- a/src/writer/wgsl/generator_impl_member_accessor_test.cc
+++ b/src/writer/wgsl/generator_impl_member_accessor_test.cc
@@ -28,12 +28,12 @@
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitExpression_MemberAccessor) {
- auto* str =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("str"), "str");
- auto* mem =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("mem"), "mem");
+ auto* str = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("str"), "str");
+ auto* mem = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("mem"), "mem");
- ast::MemberAccessorExpression expr(str, mem);
+ ast::MemberAccessorExpression expr(Source{}, str, mem);
ASSERT_TRUE(gen.EmitExpression(&expr)) << gen.error();
EXPECT_EQ(gen.result(), "str.mem");
diff --git a/src/writer/wgsl/generator_impl_return_test.cc b/src/writer/wgsl/generator_impl_return_test.cc
index 0cad4a0..961e484 100644
--- a/src/writer/wgsl/generator_impl_return_test.cc
+++ b/src/writer/wgsl/generator_impl_return_test.cc
@@ -38,8 +38,8 @@
}
TEST_F(WgslGeneratorImplTest, Emit_ReturnWithValue) {
- auto* expr =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
+ auto* expr = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr");
ast::ReturnStatement r(Source{}, expr);
gen.increment_indent();
diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc
index dfa38af..96ddc99 100644
--- a/src/writer/wgsl/generator_impl_switch_test.cc
+++ b/src/writer/wgsl/generator_impl_switch_test.cc
@@ -49,8 +49,8 @@
body.push_back(case_stmt);
body.push_back(def);
- auto* cond =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("cond"), "cond");
+ auto* cond = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("cond"), "cond");
ast::SwitchStatement s(cond, body);
gen.increment_indent();
diff --git a/src/writer/wgsl/generator_impl_unary_op_test.cc b/src/writer/wgsl/generator_impl_unary_op_test.cc
index dbac9fc..7f8acd4 100644
--- a/src/writer/wgsl/generator_impl_unary_op_test.cc
+++ b/src/writer/wgsl/generator_impl_unary_op_test.cc
@@ -38,9 +38,9 @@
TEST_P(WgslUnaryOpTest, Emit) {
auto params = GetParam();
- auto* expr =
- create<ast::IdentifierExpression>(mod.RegisterSymbol("expr"), "expr");
- ast::UnaryOpExpression op(params.op, expr);
+ auto* expr = create<ast::IdentifierExpression>(
+ Source{}, mod.RegisterSymbol("expr"), "expr");
+ ast::UnaryOpExpression op(Source{}, params.op, expr);
ASSERT_TRUE(gen.EmitExpression(&op)) << gen.error();
EXPECT_EQ(gen.result(), std::string(params.name) + "(expr)");
diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc
index 39cffac..6583725 100644
--- a/src/writer/wgsl/generator_impl_variable_test.cc
+++ b/src/writer/wgsl/generator_impl_variable_test.cc
@@ -88,7 +88,7 @@
TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
auto* ident = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("initializer"), "initializer");
+ Source{}, mod.RegisterSymbol("initializer"), "initializer");
ast::type::F32 f32;
ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32, false, ident,
@@ -101,7 +101,7 @@
TEST_F(WgslGeneratorImplTest, EmitVariable_Const) {
auto* ident = create<ast::IdentifierExpression>(
- mod.RegisterSymbol("initializer"), "initializer");
+ Source{}, mod.RegisterSymbol("initializer"), "initializer");
ast::type::F32 f32;
ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32, true, ident,