ast: Add Source argument to literals
Bug: tint:396 Bug: tint:390 Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
604bc72dd9
commit
5ed161b2d9
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::BoolLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BoolLiteral::BoolLiteral(type::Type* type, bool value)
|
||||
: Base(type), value_(value) {}
|
||||
BoolLiteral::BoolLiteral(const Source& source, type::Type* type, bool value)
|
||||
: Base(source, type), value_(value) {}
|
||||
|
||||
BoolLiteral::~BoolLiteral() = default;
|
||||
|
||||
|
@ -36,7 +36,8 @@ std::string BoolLiteral::name() const {
|
|||
}
|
||||
|
||||
BoolLiteral* BoolLiteral::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<BoolLiteral>(ctx->Clone(type()), value_);
|
||||
return ctx->mod->create<BoolLiteral>(ctx->Clone(source()), ctx->Clone(type()),
|
||||
value_);
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -26,9 +26,10 @@ namespace ast {
|
|||
class BoolLiteral : public Castable<BoolLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
/// @param value the bool literals value
|
||||
BoolLiteral(type::Type* type, bool value);
|
||||
BoolLiteral(const Source& source, type::Type* type, bool value);
|
||||
~BoolLiteral() override;
|
||||
|
||||
/// @returns true if the bool literal is true
|
||||
|
|
|
@ -29,7 +29,7 @@ using BoolLiteralTest = TestHelper;
|
|||
|
||||
TEST_F(BoolLiteralTest, True) {
|
||||
type::Bool bool_type;
|
||||
BoolLiteral b{&bool_type, true};
|
||||
BoolLiteral b{Source{}, &bool_type, true};
|
||||
ASSERT_TRUE(b.Is<BoolLiteral>());
|
||||
ASSERT_TRUE(b.IsTrue());
|
||||
ASSERT_FALSE(b.IsFalse());
|
||||
|
@ -37,7 +37,7 @@ TEST_F(BoolLiteralTest, True) {
|
|||
|
||||
TEST_F(BoolLiteralTest, False) {
|
||||
type::Bool bool_type;
|
||||
BoolLiteral b{&bool_type, false};
|
||||
BoolLiteral b{Source{}, &bool_type, false};
|
||||
ASSERT_TRUE(b.Is<BoolLiteral>());
|
||||
ASSERT_FALSE(b.IsTrue());
|
||||
ASSERT_TRUE(b.IsFalse());
|
||||
|
@ -45,7 +45,7 @@ TEST_F(BoolLiteralTest, False) {
|
|||
|
||||
TEST_F(BoolLiteralTest, Is) {
|
||||
type::Bool bool_type;
|
||||
BoolLiteral b{&bool_type, false};
|
||||
BoolLiteral b{Source{}, &bool_type, false};
|
||||
Literal* l = &b;
|
||||
EXPECT_TRUE(l->Is<BoolLiteral>());
|
||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||
|
@ -57,8 +57,8 @@ TEST_F(BoolLiteralTest, Is) {
|
|||
|
||||
TEST_F(BoolLiteralTest, ToStr) {
|
||||
type::Bool bool_type;
|
||||
BoolLiteral t{&bool_type, true};
|
||||
BoolLiteral f{&bool_type, false};
|
||||
BoolLiteral t{Source{}, &bool_type, true};
|
||||
BoolLiteral f{Source{}, &bool_type, false};
|
||||
|
||||
EXPECT_EQ(t.to_str(), "true");
|
||||
EXPECT_EQ(f.to_str(), "false");
|
||||
|
|
|
@ -275,19 +275,27 @@ class Builder {
|
|||
|
||||
/// @param val the boolan value
|
||||
/// @return a boolean literal with the given value
|
||||
BoolLiteral* Literal(bool val) { return create<BoolLiteral>(ty.bool_, val); }
|
||||
BoolLiteral* Literal(bool val) {
|
||||
return create<BoolLiteral>(Source{}, ty.bool_, val);
|
||||
}
|
||||
|
||||
/// @param val the float value
|
||||
/// @return a float literal with the given value
|
||||
FloatLiteral* Literal(f32 val) { return create<FloatLiteral>(ty.f32, val); }
|
||||
FloatLiteral* Literal(f32 val) {
|
||||
return create<FloatLiteral>(Source{}, ty.f32, val);
|
||||
}
|
||||
|
||||
/// @param val the unsigned int value
|
||||
/// @return a UintLiteral with the given value
|
||||
UintLiteral* Literal(u32 val) { return create<UintLiteral>(ty.u32, val); }
|
||||
UintLiteral* Literal(u32 val) {
|
||||
return create<UintLiteral>(Source{}, ty.u32, val);
|
||||
}
|
||||
|
||||
/// @param val the integer value
|
||||
/// @return the SintLiteral with the given value
|
||||
SintLiteral* Literal(i32 val) { return create<SintLiteral>(ty.i32, val); }
|
||||
SintLiteral* Literal(i32 val) {
|
||||
return create<SintLiteral>(Source{}, ty.i32, val);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the type constructor
|
||||
/// @return an `TypeConstructorExpression` of type `ty`, with the values
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(CaseStatementTest, Creation_i32) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList b;
|
||||
auto* selector = create<SintLiteral>(&i32, 2);
|
||||
auto* selector = create<SintLiteral>(Source{}, &i32, 2);
|
||||
b.push_back(selector);
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
|
@ -50,7 +50,7 @@ TEST_F(CaseStatementTest, Creation_u32) {
|
|||
type::U32 u32;
|
||||
|
||||
CaseSelectorList b;
|
||||
auto* selector = create<SintLiteral>(&u32, 2);
|
||||
auto* selector = create<SintLiteral>(Source{}, &u32, 2);
|
||||
b.push_back(selector);
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
|
@ -67,7 +67,7 @@ TEST_F(CaseStatementTest, Creation_u32) {
|
|||
TEST_F(CaseStatementTest, Creation_WithSource) {
|
||||
type::I32 i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
b.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
@ -89,7 +89,7 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) {
|
|||
TEST_F(CaseStatementTest, IsDefault_WithSelectors) {
|
||||
type::I32 i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
b.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
CaseStatement c(b, create<BlockStatement>());
|
||||
EXPECT_FALSE(c.IsDefault());
|
||||
|
@ -108,7 +108,7 @@ TEST_F(CaseStatementTest, IsValid) {
|
|||
TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
|
||||
type::I32 i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
b.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
@ -121,7 +121,7 @@ TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
|
|||
TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) {
|
||||
type::I32 i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
b.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<IfStatement>(Source{}, nullptr, create<BlockStatement>(),
|
||||
|
@ -134,7 +134,7 @@ TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) {
|
|||
TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
|
||||
type::I32 i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, -2));
|
||||
b.push_back(create<SintLiteral>(Source{}, &i32, -2));
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
@ -151,7 +151,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
|
|||
TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) {
|
||||
type::U32 u32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<UintLiteral>(&u32, 2));
|
||||
b.push_back(create<UintLiteral>(Source{}, &u32, 2));
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
@ -169,8 +169,8 @@ TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 1));
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
b.push_back(create<SintLiteral>(Source{}, &i32, 1));
|
||||
b.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
|
|
@ -109,7 +109,8 @@ class CloneContext {
|
|||
/// // Replace all ast::UintLiterals with the number 42
|
||||
/// CloneCtx ctx(mod);
|
||||
/// ctx.ReplaceAll([&] (ast::UintLiteral* in) {
|
||||
/// return ctx.mod->create<ast::UintLiteral>(ctx.Clone(in->type()), 42);
|
||||
/// return ctx.mod->create<ast::UintLiteral>(ctx.Clone(in->source()),
|
||||
/// ctx.Clone(in->type()), 42);
|
||||
/// });
|
||||
/// auto* out = ctx.Clone(tree);
|
||||
/// ```
|
||||
|
|
|
@ -30,7 +30,7 @@ using ElseStatementTest = TestHelper;
|
|||
TEST_F(ElseStatementTest, Creation) {
|
||||
type::Bool bool_type;
|
||||
auto* cond = create<ScalarConstructorExpression>(
|
||||
create<BoolLiteral>(&bool_type, true));
|
||||
create<BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
||||
|
@ -57,7 +57,7 @@ TEST_F(ElseStatementTest, IsElse) {
|
|||
TEST_F(ElseStatementTest, HasCondition) {
|
||||
type::Bool bool_type;
|
||||
auto* cond = create<ScalarConstructorExpression>(
|
||||
create<BoolLiteral>(&bool_type, true));
|
||||
create<BoolLiteral>(Source{}, &bool_type, true));
|
||||
ElseStatement e(cond, create<BlockStatement>());
|
||||
EXPECT_TRUE(e.HasCondition());
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ TEST_F(ElseStatementTest, IsValid_InvalidBodyStatement) {
|
|||
TEST_F(ElseStatementTest, ToStr) {
|
||||
type::Bool bool_type;
|
||||
auto* cond = create<ScalarConstructorExpression>(
|
||||
create<BoolLiteral>(&bool_type, true));
|
||||
create<BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::FloatLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
FloatLiteral::FloatLiteral(type::Type* type, float value)
|
||||
: Base(type), value_(value) {}
|
||||
FloatLiteral::FloatLiteral(const Source& source, type::Type* type, float value)
|
||||
: Base(source, type), value_(value) {}
|
||||
|
||||
FloatLiteral::~FloatLiteral() = default;
|
||||
|
||||
|
@ -43,7 +43,8 @@ std::string FloatLiteral::name() const {
|
|||
}
|
||||
|
||||
FloatLiteral* FloatLiteral::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<FloatLiteral>(ctx->Clone(type()), value_);
|
||||
return ctx->mod->create<FloatLiteral>(ctx->Clone(source()),
|
||||
ctx->Clone(type()), value_);
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -26,9 +26,10 @@ namespace ast {
|
|||
class FloatLiteral : public Castable<FloatLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
/// @param value the float literals value
|
||||
FloatLiteral(type::Type* type, float value);
|
||||
FloatLiteral(const Source& source, type::Type* type, float value);
|
||||
~FloatLiteral() override;
|
||||
|
||||
/// @returns the float literal value
|
||||
|
|
|
@ -29,14 +29,14 @@ using FloatLiteralTest = TestHelper;
|
|||
|
||||
TEST_F(FloatLiteralTest, Value) {
|
||||
type::F32 f32;
|
||||
FloatLiteral f{&f32, 47.2f};
|
||||
FloatLiteral f{Source{}, &f32, 47.2f};
|
||||
ASSERT_TRUE(f.Is<FloatLiteral>());
|
||||
EXPECT_EQ(f.value(), 47.2f);
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, Is) {
|
||||
type::F32 f32;
|
||||
FloatLiteral f{&f32, 42.f};
|
||||
FloatLiteral f{Source{}, &f32, 42.f};
|
||||
Literal* l = &f;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||
|
@ -48,14 +48,14 @@ TEST_F(FloatLiteralTest, Is) {
|
|||
|
||||
TEST_F(FloatLiteralTest, ToStr) {
|
||||
type::F32 f32;
|
||||
FloatLiteral f{&f32, 42.1f};
|
||||
FloatLiteral f{Source{}, &f32, 42.1f};
|
||||
|
||||
EXPECT_EQ(f.to_str(), "42.099998");
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, ToName) {
|
||||
type::F32 f32;
|
||||
FloatLiteral f{&f32, 42.1f};
|
||||
FloatLiteral f{Source{}, &f32, 42.1f};
|
||||
EXPECT_EQ(f.name(), "__float42.0999985");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::IntLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
IntLiteral::IntLiteral(type::Type* type) : Base(type) {}
|
||||
IntLiteral::IntLiteral(const Source& source, type::Type* type)
|
||||
: Base(source, type) {}
|
||||
|
||||
IntLiteral::~IntLiteral() = default;
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ class IntLiteral : public Castable<IntLiteral, Literal> {
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
explicit IntLiteral(type::Type* type);
|
||||
IntLiteral(const Source& source, type::Type* type);
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -31,13 +31,13 @@ using IntLiteralTest = TestHelper;
|
|||
|
||||
TEST_F(IntLiteralTest, Sint_IsInt) {
|
||||
type::I32 i32;
|
||||
SintLiteral i{&i32, 47};
|
||||
SintLiteral i{Source{}, &i32, 47};
|
||||
ASSERT_TRUE(i.Is<IntLiteral>());
|
||||
}
|
||||
|
||||
TEST_F(IntLiteralTest, Uint_IsInt) {
|
||||
type::I32 i32;
|
||||
UintLiteral i{&i32, 42};
|
||||
UintLiteral i{Source{}, &i32, 42};
|
||||
EXPECT_TRUE(i.Is<IntLiteral>());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::Literal);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Literal::Literal(type::Type* type) : type_(type) {}
|
||||
Literal::Literal(const Source& source, type::Type* type)
|
||||
: Base(source), type_(type) {}
|
||||
|
||||
Literal::~Literal() = default;
|
||||
|
||||
|
|
|
@ -47,8 +47,9 @@ class Literal : public Castable<Literal, Node> {
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
explicit Literal(type::Type* type);
|
||||
explicit Literal(const Source& source, type::Type* type);
|
||||
|
||||
private:
|
||||
type::Type* type_ = nullptr;
|
||||
|
|
|
@ -64,7 +64,7 @@ class Node : public Castable<Node> {
|
|||
/// Create a new node
|
||||
Node();
|
||||
/// Create a new node
|
||||
/// @param source The input source for the node
|
||||
/// @param source the input source for the node
|
||||
explicit Node(const Source& source);
|
||||
/// Move constructor
|
||||
Node(Node&&);
|
||||
|
|
|
@ -22,7 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::NullLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
NullLiteral::NullLiteral(type::Type* type) : Base(type) {}
|
||||
NullLiteral::NullLiteral(const Source& source, type::Type* type)
|
||||
: Base(source, type) {}
|
||||
|
||||
NullLiteral::~NullLiteral() = default;
|
||||
|
||||
|
@ -35,7 +36,8 @@ std::string NullLiteral::name() const {
|
|||
}
|
||||
|
||||
NullLiteral* NullLiteral::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<NullLiteral>(ctx->Clone(type()));
|
||||
return ctx->mod->create<NullLiteral>(ctx->Clone(source()),
|
||||
ctx->Clone(type()));
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -26,8 +26,9 @@ namespace ast {
|
|||
class NullLiteral : public Castable<NullLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param source the input source
|
||||
/// @param type the type
|
||||
explicit NullLiteral(type::Type* type);
|
||||
NullLiteral(const Source& source, type::Type* type);
|
||||
~NullLiteral() override;
|
||||
|
||||
/// @returns the name for this literal. This name is unique to this value.
|
||||
|
|
|
@ -29,7 +29,7 @@ using NullLiteralTest = TestHelper;
|
|||
|
||||
TEST_F(NullLiteralTest, Is) {
|
||||
type::I32 i32;
|
||||
NullLiteral i{&i32};
|
||||
NullLiteral i{Source{}, &i32};
|
||||
Literal* l = &i;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||
|
@ -41,14 +41,14 @@ TEST_F(NullLiteralTest, Is) {
|
|||
|
||||
TEST_F(NullLiteralTest, ToStr) {
|
||||
type::I32 i32;
|
||||
NullLiteral i{&i32};
|
||||
NullLiteral i{Source{}, &i32};
|
||||
|
||||
EXPECT_EQ(i.to_str(), "null __i32");
|
||||
}
|
||||
|
||||
TEST_F(NullLiteralTest, Name_I32) {
|
||||
type::I32 i32;
|
||||
NullLiteral i{&i32};
|
||||
NullLiteral i{Source{}, &i32};
|
||||
EXPECT_EQ("__null__i32", i.name());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@ using ScalarConstructorExpressionTest = TestHelper;
|
|||
|
||||
TEST_F(ScalarConstructorExpressionTest, Creation) {
|
||||
type::Bool bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
auto* b = create<BoolLiteral>(Source{}, &bool_type, true);
|
||||
ScalarConstructorExpression c(b);
|
||||
EXPECT_EQ(c.literal(), b);
|
||||
}
|
||||
|
||||
TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) {
|
||||
type::Bool bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
auto* b = create<BoolLiteral>(Source{}, &bool_type, true);
|
||||
ScalarConstructorExpression c(Source{Source::Location{20, 2}}, b);
|
||||
auto src = c.source();
|
||||
EXPECT_EQ(src.range.begin.line, 20u);
|
||||
|
@ -42,7 +42,7 @@ TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(ScalarConstructorExpressionTest, IsValid) {
|
||||
type::Bool bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
auto* b = create<BoolLiteral>(Source{}, &bool_type, true);
|
||||
ScalarConstructorExpression c(b);
|
||||
EXPECT_TRUE(c.IsValid());
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ TEST_F(ScalarConstructorExpressionTest, IsValid_MissingLiteral) {
|
|||
|
||||
TEST_F(ScalarConstructorExpressionTest, ToStr) {
|
||||
type::Bool bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
auto* b = create<BoolLiteral>(Source{}, &bool_type, true);
|
||||
ScalarConstructorExpression c(b);
|
||||
std::ostringstream out;
|
||||
c.to_str(out, 2);
|
||||
|
|
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::SintLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
SintLiteral::SintLiteral(type::Type* type, int32_t value)
|
||||
: Base(type), value_(value) {}
|
||||
SintLiteral::SintLiteral(const Source& source, type::Type* type, int32_t value)
|
||||
: Base(source, type), value_(value) {}
|
||||
|
||||
SintLiteral::~SintLiteral() = default;
|
||||
|
||||
|
@ -36,7 +36,8 @@ std::string SintLiteral::name() const {
|
|||
}
|
||||
|
||||
SintLiteral* SintLiteral::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<SintLiteral>(ctx->Clone(type()), value_);
|
||||
return ctx->mod->create<SintLiteral>(ctx->Clone(source()), ctx->Clone(type()),
|
||||
value_);
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -26,9 +26,10 @@ namespace ast {
|
|||
class SintLiteral : public Castable<SintLiteral, IntLiteral> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param source the input source
|
||||
/// @param type the type
|
||||
/// @param value the signed int literals value
|
||||
SintLiteral(type::Type* type, int32_t value);
|
||||
SintLiteral(const Source& source, type::Type* type, int32_t value);
|
||||
~SintLiteral() override;
|
||||
|
||||
/// @returns the int literal value
|
||||
|
|
|
@ -30,14 +30,14 @@ using SintLiteralTest = TestHelper;
|
|||
|
||||
TEST_F(SintLiteralTest, Value) {
|
||||
type::I32 i32;
|
||||
SintLiteral i{&i32, 47};
|
||||
SintLiteral i{Source{}, &i32, 47};
|
||||
ASSERT_TRUE(i.Is<SintLiteral>());
|
||||
EXPECT_EQ(i.value(), 47);
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Is) {
|
||||
type::I32 i32;
|
||||
SintLiteral i{&i32, 42};
|
||||
SintLiteral i{Source{}, &i32, 42};
|
||||
Literal* l = &i;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_TRUE(l->Is<SintLiteral>());
|
||||
|
@ -48,20 +48,20 @@ TEST_F(SintLiteralTest, Is) {
|
|||
|
||||
TEST_F(SintLiteralTest, ToStr) {
|
||||
type::I32 i32;
|
||||
SintLiteral i{&i32, -42};
|
||||
SintLiteral i{Source{}, &i32, -42};
|
||||
|
||||
EXPECT_EQ(i.to_str(), "-42");
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Name_I32) {
|
||||
type::I32 i32;
|
||||
SintLiteral i{&i32, 2};
|
||||
SintLiteral i{Source{}, &i32, 2};
|
||||
EXPECT_EQ("__sint__i32_2", i.name());
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Name_U32) {
|
||||
type::U32 u32;
|
||||
SintLiteral i{&u32, 2};
|
||||
SintLiteral i{Source{}, &u32, 2};
|
||||
EXPECT_EQ("__sint__u32_2", i.name());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST_F(SwitchStatementTest, Creation) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 1));
|
||||
lit.push_back(create<SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
auto* ident =
|
||||
create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
|
||||
|
@ -61,7 +61,7 @@ TEST_F(SwitchStatementTest, IsSwitch) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* ident =
|
||||
create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
|
||||
|
@ -76,7 +76,7 @@ TEST_F(SwitchStatementTest, IsValid) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* ident =
|
||||
create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
|
||||
|
@ -91,7 +91,7 @@ TEST_F(SwitchStatementTest, IsValid_Null_Condition) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
CaseStatementList body;
|
||||
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
|
||||
|
@ -104,7 +104,7 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* ident = create<IdentifierExpression>(mod.RegisterSymbol(""), "");
|
||||
CaseStatementList body;
|
||||
|
@ -118,7 +118,7 @@ TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* ident =
|
||||
create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
|
||||
|
@ -163,7 +163,7 @@ TEST_F(SwitchStatementTest, ToStr) {
|
|||
type::I32 i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
lit.push_back(create<SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* ident =
|
||||
create<IdentifierExpression>(mod.RegisterSymbol("ident"), "ident");
|
||||
|
|
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::UintLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
UintLiteral::UintLiteral(type::Type* type, uint32_t value)
|
||||
: Base(type), value_(value) {}
|
||||
UintLiteral::UintLiteral(const Source& source, type::Type* type, uint32_t value)
|
||||
: Base(source, type), value_(value) {}
|
||||
|
||||
UintLiteral::~UintLiteral() = default;
|
||||
|
||||
|
@ -36,7 +36,8 @@ std::string UintLiteral::name() const {
|
|||
}
|
||||
|
||||
UintLiteral* UintLiteral::Clone(CloneContext* ctx) const {
|
||||
return ctx->mod->create<UintLiteral>(ctx->Clone(type()), value_);
|
||||
return ctx->mod->create<UintLiteral>(ctx->Clone(source()), ctx->Clone(type()),
|
||||
value_);
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -26,9 +26,10 @@ namespace ast {
|
|||
class UintLiteral : public Castable<UintLiteral, IntLiteral> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
/// @param value the uint literals value
|
||||
UintLiteral(type::Type* type, uint32_t value);
|
||||
UintLiteral(const Source& source, type::Type* type, uint32_t value);
|
||||
~UintLiteral() override;
|
||||
|
||||
/// @returns the uint literal value
|
||||
|
|
|
@ -29,14 +29,14 @@ using UintLiteralTest = TestHelper;
|
|||
|
||||
TEST_F(UintLiteralTest, Value) {
|
||||
type::U32 u32;
|
||||
UintLiteral u{&u32, 47};
|
||||
UintLiteral u{Source{}, &u32, 47};
|
||||
ASSERT_TRUE(u.Is<UintLiteral>());
|
||||
EXPECT_EQ(u.value(), 47u);
|
||||
}
|
||||
|
||||
TEST_F(UintLiteralTest, Is) {
|
||||
type::U32 u32;
|
||||
UintLiteral u{&u32, 42};
|
||||
UintLiteral u{Source{}, &u32, 42};
|
||||
Literal* l = &u;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||
|
@ -47,9 +47,8 @@ TEST_F(UintLiteralTest, Is) {
|
|||
|
||||
TEST_F(UintLiteralTest, ToStr) {
|
||||
type::U32 u32;
|
||||
UintLiteral i{&u32, 42};
|
||||
|
||||
EXPECT_EQ(i.to_str(), "42");
|
||||
UintLiteral u{Source{}, &u32, 42};
|
||||
EXPECT_EQ(u.to_str(), "42");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -228,28 +228,28 @@ class InspectorHelper {
|
|||
/// @param val scalar value for the literal to contain
|
||||
/// @returns a Literal of the expected type and value
|
||||
ast::Literal* MakeLiteral(ast::type::Type* type, bool* val) {
|
||||
return create<ast::BoolLiteral>(type, *val);
|
||||
return create<ast::BoolLiteral>(Source{}, type, *val);
|
||||
}
|
||||
|
||||
/// @param type AST type of the literal, must resolve to UIntLiteral
|
||||
/// @param val scalar value for the literal to contain
|
||||
/// @returns a Literal of the expected type and value
|
||||
ast::Literal* MakeLiteral(ast::type::Type* type, uint32_t* val) {
|
||||
return create<ast::UintLiteral>(type, *val);
|
||||
return create<ast::UintLiteral>(Source{}, type, *val);
|
||||
}
|
||||
|
||||
/// @param type AST type of the literal, must resolve to IntLiteral
|
||||
/// @param val scalar value for the literal to contain
|
||||
/// @returns a Literal of the expected type and value
|
||||
ast::Literal* MakeLiteral(ast::type::Type* type, int32_t* val) {
|
||||
return create<ast::SintLiteral>(type, *val);
|
||||
return create<ast::SintLiteral>(Source{}, type, *val);
|
||||
}
|
||||
|
||||
/// @param type AST type of the literal, must resolve to FloattLiteral
|
||||
/// @param val scalar value for the literal to contain
|
||||
/// @returns a Literal of the expected type and value
|
||||
ast::Literal* MakeLiteral(ast::type::Type* type, float* val) {
|
||||
return create<ast::FloatLiteral>(type, *val);
|
||||
return create<ast::FloatLiteral>(Source{}, type, *val);
|
||||
}
|
||||
|
||||
/// @param vec Vector of strings to be searched
|
||||
|
|
|
@ -695,7 +695,7 @@ void FunctionEmitter::PushTrueGuard(uint32_t end_id) {
|
|||
assert(!statements_stack_.empty());
|
||||
const auto& top = statements_stack_.back();
|
||||
|
||||
auto* cond = MakeTrue();
|
||||
auto* cond = MakeTrue(Source{});
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
AddStatement(
|
||||
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
|
||||
|
@ -2142,7 +2142,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) {
|
|||
ast::StorageClass::kFunction, // storage_class
|
||||
parser_impl_.Bool(), // type
|
||||
false, // is_const
|
||||
MakeTrue(), // constructor
|
||||
MakeTrue(Source{}), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* guard_decl = create<ast::VariableDeclStatement>(guard_var);
|
||||
AddStatement(guard_decl);
|
||||
|
@ -2354,10 +2354,10 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) {
|
|||
const uint32_t value32 = uint32_t(value & 0xFFFFFFFF);
|
||||
if (selector.type->is_unsigned_scalar_or_vector()) {
|
||||
selectors.emplace_back(
|
||||
create<ast::UintLiteral>(selector.type, value32));
|
||||
create<ast::UintLiteral>(Source{}, selector.type, value32));
|
||||
} else {
|
||||
selectors.emplace_back(
|
||||
create<ast::SintLiteral>(selector.type, value32));
|
||||
create<ast::SintLiteral>(Source{}, selector.type, value32));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2572,7 +2572,7 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed(
|
|||
return create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(
|
||||
ast_module_.RegisterSymbol(flow_guard), flow_guard),
|
||||
MakeFalse());
|
||||
MakeFalse(Source{}));
|
||||
}
|
||||
|
||||
// For an unconditional branch, the break out to an if-selection
|
||||
|
@ -3256,7 +3256,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(
|
|||
auto make_index = [this](uint32_t literal) {
|
||||
auto* type = create<ast::type::U32>();
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(type, literal));
|
||||
create<ast::UintLiteral>(Source{}, type, literal));
|
||||
};
|
||||
|
||||
const auto composite = inst.GetSingleWordInOperand(0);
|
||||
|
@ -3356,15 +3356,15 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(
|
|||
return current_expr;
|
||||
}
|
||||
|
||||
ast::Expression* FunctionEmitter::MakeTrue() const {
|
||||
ast::Expression* FunctionEmitter::MakeTrue(const Source& source) const {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(parser_impl_.Bool(), true));
|
||||
create<ast::BoolLiteral>(source, parser_impl_.Bool(), true));
|
||||
}
|
||||
|
||||
ast::Expression* FunctionEmitter::MakeFalse() const {
|
||||
ast::Expression* FunctionEmitter::MakeFalse(const Source& source) const {
|
||||
ast::type::Bool bool_type;
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(parser_impl_.Bool(), false));
|
||||
create<ast::BoolLiteral>(source, parser_impl_.Bool(), false));
|
||||
}
|
||||
|
||||
TypedExpression FunctionEmitter::MakeVectorShuffle(
|
||||
|
|
|
@ -698,7 +698,7 @@ class FunctionEmitter {
|
|||
/// return the given value. Otherwise, wrap the value in a TypeConstructor
|
||||
/// expression.
|
||||
/// @param value the value to pass through or convert
|
||||
/// @reutrns the value as an I32 value.
|
||||
/// @returns the value as an I32 value.
|
||||
TypedExpression ToI32(TypedExpression value);
|
||||
|
||||
private:
|
||||
|
@ -865,10 +865,10 @@ class FunctionEmitter {
|
|||
void PushTrueGuard(uint32_t end_id);
|
||||
|
||||
/// @returns a boolean true expression.
|
||||
ast::Expression* MakeTrue() const;
|
||||
ast::Expression* MakeTrue(const Source&) const;
|
||||
|
||||
/// @returns a boolean false expression.
|
||||
ast::Expression* MakeFalse() const;
|
||||
ast::Expression* MakeFalse(const Source&) const;
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
|
|
|
@ -1033,7 +1033,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
|||
ast_type = ConvertType(inst.type_id());
|
||||
ast_expr =
|
||||
create<ast::ScalarConstructorExpression>(create<ast::BoolLiteral>(
|
||||
ast_type, inst.opcode() == SpvOpSpecConstantTrue));
|
||||
Source{}, ast_type, inst.opcode() == SpvOpSpecConstantTrue));
|
||||
break;
|
||||
}
|
||||
case SpvOpSpecConstant: {
|
||||
|
@ -1042,17 +1042,17 @@ bool ParserImpl::EmitScalarSpecConstants() {
|
|||
if (ast_type->Is<ast::type::I32>()) {
|
||||
ast_expr =
|
||||
create<ast::ScalarConstructorExpression>(create<ast::SintLiteral>(
|
||||
ast_type, static_cast<int32_t>(literal_value)));
|
||||
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>(
|
||||
ast_type, static_cast<uint32_t>(literal_value)));
|
||||
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>(
|
||||
create<ast::FloatLiteral>(ast_type, float_value));
|
||||
create<ast::FloatLiteral>(Source{}, ast_type, float_value));
|
||||
} else {
|
||||
return Fail() << " invalid result type for OpSpecConstant "
|
||||
<< inst.PrettyPrint();
|
||||
|
@ -1314,6 +1314,7 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
|||
return {};
|
||||
}
|
||||
|
||||
auto source = GetSourceForInst(inst);
|
||||
auto* ast_type = original_ast_type->UnwrapIfNeeded();
|
||||
|
||||
// TODO(dneto): Note: NullConstant for int, uint, float map to a regular 0.
|
||||
|
@ -1322,25 +1323,25 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
|
|||
// See https://bugs.chromium.org/p/tint/issues/detail?id=34
|
||||
if (ast_type->Is<ast::type::U32>()) {
|
||||
return {ast_type,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(ast_type, spirv_const->GetU32()))};
|
||||
create<ast::ScalarConstructorExpression>(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>(ast_type, spirv_const->GetS32()))};
|
||||
create<ast::ScalarConstructorExpression>(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>(ast_type, spirv_const->GetFloat()))};
|
||||
create<ast::ScalarConstructorExpression>(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>(ast_type, value))};
|
||||
create<ast::BoolLiteral>(source, ast_type, value))};
|
||||
}
|
||||
auto* spirv_composite_const = spirv_const->AsCompositeConstant();
|
||||
if (spirv_composite_const != nullptr) {
|
||||
|
@ -1394,19 +1395,19 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) {
|
|||
|
||||
if (type->Is<ast::type::Bool>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(type, false));
|
||||
create<ast::BoolLiteral>(Source{}, type, false));
|
||||
}
|
||||
if (type->Is<ast::type::U32>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(type, 0u));
|
||||
create<ast::UintLiteral>(Source{}, type, 0u));
|
||||
}
|
||||
if (type->Is<ast::type::I32>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(type, 0));
|
||||
create<ast::SintLiteral>(Source{}, type, 0));
|
||||
}
|
||||
if (type->Is<ast::type::F32>()) {
|
||||
return create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(type, 0.0f));
|
||||
create<ast::FloatLiteral>(Source{}, type, 0.0f));
|
||||
}
|
||||
if (const auto* vec_ty = type->As<ast::type::Vector>()) {
|
||||
ast::ExpressionList ast_components;
|
||||
|
|
|
@ -2678,19 +2678,19 @@ Maybe<ast::Literal*> ParserImpl::const_literal() {
|
|||
auto t = peek();
|
||||
if (match(Token::Type::kTrue)) {
|
||||
auto* type = module_.create<ast::type::Bool>();
|
||||
return create<ast::BoolLiteral>(type, true);
|
||||
return create<ast::BoolLiteral>(Source{}, type, true);
|
||||
}
|
||||
if (match(Token::Type::kFalse)) {
|
||||
auto* type = module_.create<ast::type::Bool>();
|
||||
return create<ast::BoolLiteral>(type, false);
|
||||
return create<ast::BoolLiteral>(Source{}, type, false);
|
||||
}
|
||||
if (match(Token::Type::kSintLiteral)) {
|
||||
auto* type = module_.create<ast::type::I32>();
|
||||
return create<ast::SintLiteral>(type, t.to_i32());
|
||||
return create<ast::SintLiteral>(Source{}, type, t.to_i32());
|
||||
}
|
||||
if (match(Token::Type::kUintLiteral)) {
|
||||
auto* type = module_.create<ast::type::U32>();
|
||||
return create<ast::UintLiteral>(type, t.to_u32());
|
||||
return create<ast::UintLiteral>(Source{}, type, t.to_u32());
|
||||
}
|
||||
if (match(Token::Type::kFloatLiteral)) {
|
||||
auto p = peek();
|
||||
|
@ -2699,7 +2699,7 @@ Maybe<ast::Literal*> ParserImpl::const_literal() {
|
|||
add_error(p.source(), "float literals must not be suffixed with 'f'");
|
||||
}
|
||||
auto* type = module_.create<ast::type::F32>();
|
||||
return create<ast::FloatLiteral>(type, t.to_f32());
|
||||
return create<ast::FloatLiteral>(Source{}, type, t.to_f32());
|
||||
}
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
|
|
|
@ -105,13 +105,15 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
|||
} else if (val >= int32_t(size)) {
|
||||
val = int32_t(size) - 1;
|
||||
}
|
||||
lit = ctx->mod->create<ast::SintLiteral>(ctx->Clone(sint->type()), val);
|
||||
lit = ctx->mod->create<ast::SintLiteral>(ctx->Clone(sint->source()),
|
||||
ctx->Clone(sint->type()), val);
|
||||
} else if (auto* uint = lit->As<ast::UintLiteral>()) {
|
||||
uint32_t val = uint->value();
|
||||
if (val >= size - 1) {
|
||||
val = size - 1;
|
||||
}
|
||||
lit = ctx->mod->create<ast::UintLiteral>(ctx->Clone(uint->type()), val);
|
||||
lit = ctx->mod->create<ast::UintLiteral>(ctx->Clone(uint->source()),
|
||||
ctx->Clone(uint->type()), val);
|
||||
} else {
|
||||
diag::Diagnostic err;
|
||||
err.severity = diag::Severity::Error;
|
||||
|
@ -132,7 +134,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
|||
params.push_back(
|
||||
ctx->mod->create<ast::TypeConstructorExpression>(u32, cast_expr));
|
||||
params.push_back(ctx->mod->create<ast::ScalarConstructorExpression>(
|
||||
ctx->mod->create<ast::UintLiteral>(u32, size - 1)));
|
||||
ctx->mod->create<ast::UintLiteral>(Source{}, u32, size - 1)));
|
||||
|
||||
auto* call_expr = ctx->mod->create<ast::CallExpression>(
|
||||
ctx->mod->create<ast::IdentifierExpression>(
|
||||
|
|
|
@ -66,7 +66,7 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) {
|
|||
|
||||
// Build the AST expression & statement for assigning pointsize one.
|
||||
auto* one = mod->create<ast::ScalarConstructorExpression>(
|
||||
mod->create<ast::FloatLiteral>(f32, 1.0f));
|
||||
mod->create<ast::FloatLiteral>(Source{}, f32, 1.0f));
|
||||
auto* pointsize_ident = mod->create<ast::IdentifierExpression>(
|
||||
Source{}, mod->RegisterSymbol(kPointSizeVar), kPointSizeVar);
|
||||
auto* pointsize_assign =
|
||||
|
|
|
@ -353,7 +353,7 @@ void VertexPulling::State::AddVertexPullingPreamble(
|
|||
|
||||
ast::Expression* VertexPulling::State::GenUint(uint32_t value) {
|
||||
return mod->create<ast::ScalarConstructorExpression>(
|
||||
mod->create<ast::UintLiteral>(GetU32Type(), value));
|
||||
mod->create<ast::UintLiteral>(Source{}, GetU32Type(), value));
|
||||
}
|
||||
|
||||
ast::Expression* VertexPulling::State::CreatePullingPositionIdent() {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -50,8 +50,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
|
@ -84,13 +84,13 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(
|
||||
create<ast::CaseStatement>(csl, create<ast::BlockStatement>()));
|
||||
|
@ -122,8 +122,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
|
@ -135,7 +135,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
|||
create<ast::CaseStatement>(default_csl_1, block_default_1));
|
||||
|
||||
ast::CaseSelectorList csl_case_1;
|
||||
csl_case_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl_case_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* block_case_1 = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(csl_case_1, block_case_1));
|
||||
|
||||
|
@ -172,15 +172,15 @@ TEST_F(ValidateControlBlockTest,
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::UintLiteral>(&u32, 1));
|
||||
csl.push_back(create<ast::UintLiteral>(Source{}, &u32, 1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
|
||||
|
@ -215,15 +215,15 @@ TEST_F(ValidateControlBlockTest,
|
|||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::UintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, -1));
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, -1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
|
||||
|
@ -257,21 +257,21 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
|||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 3)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::UintLiteral>(Source{}, &u32, 3)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::UintLiteral>(&u32, 0));
|
||||
csl_1.push_back(create<ast::UintLiteral>(Source{}, &u32, 0));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::UintLiteral>(&u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(&u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
|
||||
|
@ -305,23 +305,23 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::SintLiteral>(&i32, 10));
|
||||
csl_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 0));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 2));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 10));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
|
||||
|
@ -353,8 +353,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
@ -390,8 +390,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
@ -401,7 +401,7 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
|||
body.push_back(create<ast::CaseStatement>(Source{Source::Location{12, 34}},
|
||||
default_csl, block_default));
|
||||
ast::CaseSelectorList case_csl;
|
||||
case_csl.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
case_csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
auto* block_case = create<ast::BlockStatement>();
|
||||
body.push_back(create<ast::CaseStatement>(case_csl, block_case));
|
||||
|
||||
|
@ -430,8 +430,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
|||
&my_int, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
|
|
@ -46,8 +46,8 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
|
@ -94,8 +94,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
|
@ -155,7 +155,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
|||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
return_expr));
|
||||
|
@ -179,7 +179,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
|||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{Source::Location{12, 34}},
|
||||
return_expr));
|
||||
|
@ -205,7 +205,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
|||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
auto* func =
|
||||
|
@ -215,7 +215,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
|||
ast::VariableList params_copy;
|
||||
auto* body_copy = create<ast::BlockStatement>();
|
||||
auto* return_expr_copy = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
body_copy->append(create<ast::ReturnStatement>(Source{}, return_expr_copy));
|
||||
auto* func_copy = create<ast::Function>(
|
||||
|
@ -274,7 +274,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
|||
auto* body0 = create<ast::BlockStatement>();
|
||||
body0->append(create<ast::VariableDeclStatement>(var));
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
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 +293,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
|||
ast::type::I32 i32;
|
||||
ast::VariableList params;
|
||||
auto* return_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
|
||||
|
|
|
@ -65,7 +65,7 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* rhs = create<ast::IdentifierExpression>(mod()->RegisterSymbol("my_var"),
|
||||
"my_var");
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
|
@ -83,7 +83,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) {
|
|||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
auto* assign = create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
|
||||
|
@ -101,7 +101,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
|
|||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -123,13 +123,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
|
@ -154,13 +154,13 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
|
@ -188,13 +188,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
@ -223,12 +223,12 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::BlockStatement block;
|
||||
block.append(create<ast::VariableDeclStatement>(var));
|
||||
|
@ -324,14 +324,14 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"),
|
||||
"not_global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
@ -363,13 +363,13 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
mod()->RegisterSymbol("global_var"), "global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
|
||||
|
@ -402,19 +402,19 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
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>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(
|
||||
|
@ -442,17 +442,17 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
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>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
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,8 +479,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
|
@ -490,8 +490,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
|
||||
EXPECT_TRUE(v()->ValidateGlobalVariables(mod()->global_variables()))
|
||||
|
@ -510,8 +510,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
|
@ -521,8 +521,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
|
||||
EXPECT_FALSE(v()->ValidateGlobalVariables(mod()->global_variables()));
|
||||
|
@ -543,13 +543,13 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
|||
&i32, // type
|
||||
true, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
@ -580,8 +580,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(global_var);
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
|
@ -591,8 +591,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
|
@ -624,8 +624,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
|||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var_a_float = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
|
@ -634,8 +634,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
@ -667,12 +667,12 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
|
@ -683,8 +683,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(
|
||||
|
@ -711,8 +711,8 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
|
@ -721,12 +721,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var));
|
||||
|
@ -753,8 +753,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
|
@ -763,8 +763,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
|||
&void_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
|
@ -813,7 +813,7 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
|||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
|
|
@ -779,7 +779,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre,
|
|||
|
||||
auto emit_vector_appended_with_i32_zero = [&](tint::ast::Expression* vector) {
|
||||
auto* i32 = module_->create<ast::type::I32>();
|
||||
ast::SintLiteral zero_lit(i32, 0);
|
||||
ast::SintLiteral zero_lit(Source{}, i32, 0);
|
||||
ast::ScalarConstructorExpression zero(&zero_lit);
|
||||
zero.set_result_type(i32);
|
||||
return AppendVector(vector, &zero,
|
||||
|
|
|
@ -31,7 +31,7 @@ using HlslGeneratorImplTest_Expression = TestHelper;
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) {
|
||||
ast::type::I32 i32;
|
||||
auto* lit = create<ast::SintLiteral>(&i32, 5);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, 5);
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(lit);
|
||||
auto* ary =
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
|
||||
|
|
|
@ -193,15 +193,15 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||
|
||||
|
@ -217,15 +217,15 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||
|
@ -252,7 +252,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
|||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
||||
|
@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
|||
nullptr, // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
auto* rhs =
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("mat"), "mat");
|
||||
|
||||
|
@ -307,11 +307,11 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
@ -339,11 +339,11 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
auto* lhs = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
auto* rhs =
|
||||
|
@ -462,13 +462,13 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) {
|
|||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>(
|
||||
Source{}, create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
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>(&i32, 2))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))));
|
||||
auto* else_if_stmt = create<ast::ElseStatement>(
|
||||
create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLogicalOr,
|
||||
|
@ -479,7 +479,7 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) {
|
|||
body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>(
|
||||
Source{}, create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1))));
|
||||
|
||||
ast::IfStatement expr(
|
||||
Source{},
|
||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
|
|||
body->append(create<ast::BreakStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
@ -53,7 +53,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
ast::CaseStatement c(lit, create<ast::BlockStatement>());
|
||||
|
||||
gen.increment_indent();
|
||||
|
@ -72,7 +72,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
|
|||
body->append(create<ast::FallthroughStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
@ -91,8 +91,8 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
|
|||
body->append(create<ast::BreakStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 6));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 6));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
|
|
@ -37,7 +37,7 @@ using HlslGeneratorImplTest_Constructor = TestHelper;
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
|
||||
ast::type::Bool bool_type;
|
||||
auto* lit = create<ast::BoolLiteral>(&bool_type, false);
|
||||
auto* lit = create<ast::BoolLiteral>(Source{}, &bool_type, false);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
|
||||
|
@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) {
|
||||
ast::type::I32 i32;
|
||||
auto* lit = create<ast::SintLiteral>(&i32, -12345);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
|
||||
|
@ -55,7 +55,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) {
|
||||
ast::type::U32 u32;
|
||||
auto* lit = create<ast::UintLiteral>(&u32, 56779);
|
||||
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 56779);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
|
||||
|
@ -65,8 +65,8 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) {
|
|||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) {
|
||||
ast::type::F32 f32;
|
||||
// Use a number close to 1<<30 but whose decimal representation ends in 0.
|
||||
auto* lit =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>((1 << 30) - 4));
|
||||
auto* lit = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>((1 << 30) - 4));
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error();
|
||||
|
@ -76,7 +76,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) {
|
|||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* lit = create<ast::FloatLiteral>(&f32, -1.2e-5);
|
||||
auto* lit = create<ast::FloatLiteral>(Source{}, &f32, -1.2e-5);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -89,7 +89,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
|
|||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) {
|
||||
ast::type::Bool b;
|
||||
|
||||
auto* lit = create<ast::BoolLiteral>(&b, true);
|
||||
auto* lit = create<ast::BoolLiteral>(Source{}, &b, true);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -102,7 +102,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) {
|
|||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lit = create<ast::SintLiteral>(&i32, -12345);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -115,7 +115,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) {
|
|||
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) {
|
||||
ast::type::U32 u32;
|
||||
|
||||
auto* lit = create<ast::UintLiteral>(&u32, 12345);
|
||||
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 12345);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -129,9 +129,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec(&f32, 3);
|
||||
|
||||
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
|
||||
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
|
||||
auto* lit3 = create<ast::FloatLiteral>(&f32, 3.f);
|
||||
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));
|
||||
|
@ -165,12 +165,12 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
|
|||
ast::ExpressionList mat_values;
|
||||
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
auto* lit1 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(1 + (i * 2)));
|
||||
auto* lit2 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(2 + (i * 2)));
|
||||
auto* lit3 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(3 + (i * 2)));
|
||||
auto* lit1 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(1 + (i * 2)));
|
||||
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(2 + (i * 2)));
|
||||
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(3 + (i * 2)));
|
||||
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit1));
|
||||
|
@ -198,12 +198,12 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
|
|||
ast::ExpressionList ary_values;
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto* lit1 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(1 + (i * 3)));
|
||||
auto* lit2 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(2 + (i * 3)));
|
||||
auto* lit3 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(3 + (i * 3)));
|
||||
auto* lit1 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(1 + (i * 3)));
|
||||
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(2 + (i * 3)));
|
||||
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(3 + (i * 3)));
|
||||
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit1));
|
||||
|
|
|
@ -606,7 +606,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
"coord"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(assign);
|
||||
|
@ -710,7 +710,7 @@ TEST_F(
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -798,7 +798,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -900,7 +900,7 @@ TEST_F(
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -990,7 +990,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, // source
|
||||
|
@ -1082,7 +1082,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, // source
|
||||
|
@ -1150,18 +1150,19 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f))));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
|
||||
|
||||
auto* list = create<ast::BlockStatement>();
|
||||
list->append(create<ast::ReturnStatement>(Source{}));
|
||||
|
||||
body->append(create<ast::IfStatement>(
|
||||
Source{},
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))),
|
||||
create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1))),
|
||||
list, ast::ElseStatementList{}));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
|
|
|
@ -54,7 +54,7 @@ TEST_P(HlslImportData_SingleParamTest, FloatScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
|
||||
auto* ident = create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name);
|
||||
|
@ -100,7 +100,7 @@ TEST_P(HlslImportData_SingleIntParamTest, IntScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
@ -122,9 +122,9 @@ TEST_P(HlslImportData_DualParamTest, FloatScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
@ -155,21 +155,21 @@ TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) {
|
|||
params.push_back(create<ast::TypeConstructorExpression>(
|
||||
&vec, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.f)),
|
||||
}));
|
||||
|
||||
params.push_back(create<ast::TypeConstructorExpression>(
|
||||
&vec, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 4.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 4.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 5.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 5.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 6.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 6.f)),
|
||||
}));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
|
@ -194,9 +194,9 @@ TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
@ -219,11 +219,11 @@ TEST_P(HlslImportData_TripleParamTest, FloatScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.f)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
@ -253,11 +253,11 @@ TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
|
|
@ -153,8 +153,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.4)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.4)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
|
|
@ -519,9 +519,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
"data"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -573,7 +573,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -629,11 +629,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kAdd,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 4))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 4))),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3))));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -692,7 +692,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f));
|
||||
ast::AssignmentStatement assign(lhs, rhs);
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&assign));
|
||||
|
@ -747,9 +747,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
ast::AssignmentStatement assign(lhs, rhs);
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error();
|
||||
|
@ -804,7 +804,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("data"), "data"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("a"), "a"));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
ast::AssignmentStatement assign(lhs, rhs);
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&assign));
|
||||
|
@ -910,9 +910,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ASSERT_TRUE(td.Determine()) << td.error();
|
||||
|
||||
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
|
||||
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
|
||||
auto* lit3 = create<ast::FloatLiteral>(&f32, 3.f);
|
||||
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));
|
||||
|
@ -1001,7 +1001,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
"data"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr));
|
||||
|
@ -1081,7 +1081,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
|
||||
"c")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("xy"), "xy"));
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ TEST_F(
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
|
||||
"c")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("g"), "g"));
|
||||
|
||||
|
@ -1240,10 +1240,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
|
||||
"c")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr));
|
||||
ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error();
|
||||
|
@ -1318,12 +1318,12 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
"data"),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("c"), "c")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b"));
|
||||
|
||||
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
|
||||
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
|
||||
auto* lit3 = create<ast::FloatLiteral>(&f32, 3.f);
|
||||
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));
|
||||
|
@ -1410,12 +1410,12 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
create<ast::IdentifierExpression>(mod.RegisterSymbol("c"),
|
||||
"c")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("b"), "b")),
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("y"), "y"));
|
||||
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&i32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &i32, 1.f));
|
||||
|
||||
ast::AssignmentStatement assign(lhs, rhs);
|
||||
|
||||
|
|
|
@ -38,11 +38,11 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
|||
|
||||
ast::ExpressionList exprs;
|
||||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
|
||||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
|
@ -67,7 +67,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
|||
&f32, // type
|
||||
true, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)), // constructor
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)), // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::ConstantIdDecoration>(23, Source{}),
|
||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
|
|||
|
||||
ast::type::I32 i32;
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
case_val.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
|
||||
auto* case_body = create<ast::BlockStatement>();
|
||||
case_body->append(create<ast::BreakStatement>());
|
||||
|
|
|
@ -33,7 +33,7 @@ using MslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitExpression_ArrayAccessor) {
|
||||
ast::type::I32 i32;
|
||||
auto* lit = create<ast::SintLiteral>(&i32, 5);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, 5);
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(lit);
|
||||
auto* ary =
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
|
||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case) {
|
|||
body->append(create<ast::BreakStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
@ -55,7 +55,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
ast::CaseStatement c(lit, create<ast::BlockStatement>());
|
||||
|
||||
gen.increment_indent();
|
||||
|
@ -74,7 +74,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) {
|
|||
body->append(create<ast::FallthroughStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
@ -93,8 +93,8 @@ TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
|||
body->append(create<ast::BreakStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 6));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 6));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
|
|
@ -39,7 +39,7 @@ using MslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) {
|
||||
ast::type::Bool bool_type;
|
||||
auto* lit = create<ast::BoolLiteral>(&bool_type, false);
|
||||
auto* lit = create<ast::BoolLiteral>(Source{}, &bool_type, false);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -48,7 +48,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitConstructor_Int) {
|
||||
ast::type::I32 i32;
|
||||
auto* lit = create<ast::SintLiteral>(&i32, -12345);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -57,7 +57,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Int) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) {
|
||||
ast::type::U32 u32;
|
||||
auto* lit = create<ast::UintLiteral>(&u32, 56779);
|
||||
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 56779);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -67,8 +67,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) {
|
|||
TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
|
||||
ast::type::F32 f32;
|
||||
// Use a number close to 1<<30 but whose decimal representation ends in 0.
|
||||
auto* lit =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>((1 << 30) - 4));
|
||||
auto* lit = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>((1 << 30) - 4));
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -78,7 +78,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
|
|||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* lit = create<ast::FloatLiteral>(&f32, -1.2e-5);
|
||||
auto* lit = create<ast::FloatLiteral>(Source{}, &f32, -1.2e-5);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -91,7 +91,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) {
|
|||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) {
|
||||
ast::type::Bool b;
|
||||
|
||||
auto* lit = create<ast::BoolLiteral>(&b, true);
|
||||
auto* lit = create<ast::BoolLiteral>(Source{}, &b, true);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -104,7 +104,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) {
|
|||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lit = create<ast::SintLiteral>(&i32, -12345);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -117,7 +117,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) {
|
|||
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Uint) {
|
||||
ast::type::U32 u32;
|
||||
|
||||
auto* lit = create<ast::UintLiteral>(&u32, 12345);
|
||||
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 12345);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -131,9 +131,9 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec(&f32, 3);
|
||||
|
||||
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
|
||||
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
|
||||
auto* lit3 = create<ast::FloatLiteral>(&f32, 3.f);
|
||||
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));
|
||||
|
@ -167,12 +167,12 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) {
|
|||
ast::ExpressionList mat_values;
|
||||
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
auto* lit1 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(1 + (i * 2)));
|
||||
auto* lit2 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(2 + (i * 2)));
|
||||
auto* lit3 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(3 + (i * 2)));
|
||||
auto* lit1 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(1 + (i * 2)));
|
||||
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(2 + (i * 2)));
|
||||
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(3 + (i * 2)));
|
||||
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit1));
|
||||
|
@ -199,12 +199,12 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) {
|
|||
ast::ExpressionList ary_values;
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto* lit1 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(1 + (i * 3)));
|
||||
auto* lit2 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(2 + (i * 3)));
|
||||
auto* lit3 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(3 + (i * 3)));
|
||||
auto* lit1 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(1 + (i * 3)));
|
||||
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(2 + (i * 3)));
|
||||
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(3 + (i * 3)));
|
||||
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit1));
|
||||
|
|
|
@ -594,7 +594,7 @@ TEST_F(
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -685,7 +685,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -791,7 +791,7 @@ TEST_F(
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -879,7 +879,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, // source
|
||||
|
@ -985,7 +985,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, // source
|
||||
|
@ -1097,7 +1097,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, // source
|
||||
|
@ -1172,18 +1172,19 @@ TEST_F(MslGeneratorImplTest,
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("bar"), "bar"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f))));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
|
||||
|
||||
auto* list = create<ast::BlockStatement>();
|
||||
list->append(create<ast::ReturnStatement>(Source{}));
|
||||
|
||||
body->append(create<ast::IfStatement>(
|
||||
Source{},
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))),
|
||||
create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1))),
|
||||
list, ast::ElseStatementList{}));
|
||||
|
||||
body->append(create<ast::ReturnStatement>(Source{}));
|
||||
|
|
|
@ -55,7 +55,7 @@ TEST_P(MslImportData_SingleParamTest, FloatScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
|
||||
auto* ident = create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name);
|
||||
|
@ -99,7 +99,7 @@ TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_IntScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
|
||||
ast::CallExpression expr(
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("abs"), "abs"),
|
||||
|
@ -119,9 +119,9 @@ TEST_P(MslImportData_DualParamTest, FloatScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
@ -155,21 +155,21 @@ TEST_P(MslImportData_DualParam_VectorTest, FloatVector) {
|
|||
params.push_back(create<ast::TypeConstructorExpression>(
|
||||
&vec, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.f)),
|
||||
}));
|
||||
|
||||
params.push_back(create<ast::TypeConstructorExpression>(
|
||||
&vec, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 4.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 4.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 5.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 5.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 6.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 6.f)),
|
||||
}));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
|
@ -194,9 +194,9 @@ TEST_P(MslImportData_DualParam_Int_Test, IntScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
@ -219,11 +219,11 @@ TEST_P(MslImportData_TripleParamTest, FloatScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.f)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.f)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
@ -251,11 +251,11 @@ TEST_P(MslImportData_TripleParam_Int_Test, IntScalar) {
|
|||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod.RegisterSymbol(param.name), param.name),
|
||||
|
|
|
@ -158,8 +158,8 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.4)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.4)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
|
|
@ -40,11 +40,11 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
|||
|
||||
ast::ExpressionList exprs;
|
||||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
|
||||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
|
@ -69,7 +69,7 @@ TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
|
|||
&f32, // type
|
||||
true, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)), // constructor
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)), // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::ConstantIdDecoration>(23, Source{}),
|
||||
|
|
|
@ -39,7 +39,7 @@ TEST_F(MslGeneratorImplTest, Emit_Switch) {
|
|||
|
||||
ast::type::I32 i32;
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
case_val.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
|
||||
auto* case_body = create<ast::BlockStatement>();
|
||||
case_body->append(create<ast::BreakStatement>());
|
||||
|
|
|
@ -376,7 +376,7 @@ void Builder::GenerateLabel(uint32_t id) {
|
|||
|
||||
uint32_t Builder::GenerateU32Literal(uint32_t val) {
|
||||
ast::type::U32 u32;
|
||||
ast::SintLiteral lit(&u32, val);
|
||||
ast::SintLiteral lit(Source{}, &u32, val);
|
||||
return GenerateLiteralIfNeeded(nullptr, &lit);
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ bool Builder::GenerateFunctionVariable(ast::Variable* var) {
|
|||
|
||||
// TODO(dsinclair) We could detect if the constructor is fully const and emit
|
||||
// an initializer value for the variable instead of doing the OpLoad.
|
||||
ast::NullLiteral nl(var->type()->UnwrapPtrIfNeeded());
|
||||
ast::NullLiteral nl(Source{}, var->type()->UnwrapPtrIfNeeded());
|
||||
auto null_id = GenerateLiteralIfNeeded(var, &nl);
|
||||
if (null_id == 0) {
|
||||
return 0;
|
||||
|
@ -741,16 +741,16 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||
// then WGSL requires an initializer.
|
||||
if (var->HasConstantIdDecoration()) {
|
||||
if (type->Is<ast::type::F32>()) {
|
||||
ast::FloatLiteral l(type, 0.0f);
|
||||
ast::FloatLiteral l(Source{}, type, 0.0f);
|
||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||
} else if (type->Is<ast::type::U32>()) {
|
||||
ast::UintLiteral l(type, 0);
|
||||
ast::UintLiteral l(Source{}, type, 0);
|
||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||
} else if (type->Is<ast::type::I32>()) {
|
||||
ast::SintLiteral l(type, 0);
|
||||
ast::SintLiteral l(Source{}, type, 0);
|
||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||
} else if (type->Is<ast::type::Bool>()) {
|
||||
ast::BoolLiteral l(type, false);
|
||||
ast::BoolLiteral l(Source{}, type, false);
|
||||
init_id = GenerateLiteralIfNeeded(var, &l);
|
||||
} else {
|
||||
error_ = "invalid type for constant_id, must be scalar";
|
||||
|
@ -763,7 +763,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||
} else if (var->storage_class() == ast::StorageClass::kPrivate ||
|
||||
var->storage_class() == ast::StorageClass::kNone ||
|
||||
var->storage_class() == ast::StorageClass::kOutput) {
|
||||
ast::NullLiteral nl(type);
|
||||
ast::NullLiteral nl(Source{}, type);
|
||||
init_id = GenerateLiteralIfNeeded(var, &nl);
|
||||
if (init_id == 0) {
|
||||
return 0;
|
||||
|
@ -1015,7 +1015,7 @@ uint32_t Builder::GenerateAccessorExpression(ast::Expression* expr) {
|
|||
|
||||
auto ary_result = result_op();
|
||||
|
||||
ast::NullLiteral nl(ary_res_type);
|
||||
ast::NullLiteral nl(Source{}, ary_res_type);
|
||||
auto init = GenerateLiteralIfNeeded(nullptr, &nl);
|
||||
|
||||
// If we're access chaining into an array then we must be in a function
|
||||
|
@ -1220,7 +1220,7 @@ uint32_t Builder::GenerateTypeConstructorExpression(
|
|||
|
||||
// Generate the zero initializer if there are no values provided.
|
||||
if (values.empty()) {
|
||||
ast::NullLiteral nl(init->type()->UnwrapPtrIfNeeded());
|
||||
ast::NullLiteral nl(Source{}, init->type()->UnwrapPtrIfNeeded());
|
||||
return GenerateLiteralIfNeeded(nullptr, &nl);
|
||||
}
|
||||
|
||||
|
@ -2053,7 +2053,7 @@ void Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident,
|
|||
spirv_params.emplace_back(gen_param(pidx.depth_ref));
|
||||
|
||||
ast::type::F32 f32;
|
||||
ast::FloatLiteral float_0(&f32, 0.0);
|
||||
ast::FloatLiteral float_0(Source{}, &f32, 0.0);
|
||||
image_operands.emplace_back(ImageOperand{
|
||||
SpvImageOperandsLodMask,
|
||||
Operand::Int(GenerateLiteralIfNeeded(nullptr, &float_0))});
|
||||
|
|
|
@ -59,7 +59,7 @@ TEST_F(BuilderTest, ArrayAccessor) {
|
|||
auto* ary =
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary");
|
||||
auto* idx_expr = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
ast::ArrayAccessorExpression expr(ary, idx_expr);
|
||||
|
||||
|
@ -152,12 +152,12 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) {
|
|||
create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary");
|
||||
|
||||
ast::ArrayAccessorExpression expr(
|
||||
ary,
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kAdd,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
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))));
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
@ -201,9 +201,9 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) {
|
|||
create<ast::ArrayAccessorExpression>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3))),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
@ -249,7 +249,7 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) {
|
|||
create<ast::ArrayAccessorExpression>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("ary"), "ary"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("xy"), "xy"));
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
|
@ -492,7 +492,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) {
|
|||
create<ast::IdentifierExpression>(mod->RegisterSymbol("a"), "a"));
|
||||
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.f));
|
||||
|
||||
ast::AssignmentStatement expr(lhs, rhs);
|
||||
|
||||
|
@ -766,7 +766,7 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) {
|
|||
"ident"),
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("yxz"), "yxz")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
@ -840,11 +840,11 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
|
|||
create<ast::IdentifierExpression>(
|
||||
mod->RegisterSymbol("index"), "index"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0))),
|
||||
create<ast::IdentifierExpression>(
|
||||
mod->RegisterSymbol("foo"), "foo")),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))),
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("bar"),
|
||||
"bar")),
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("baz"), "baz")),
|
||||
|
@ -903,25 +903,25 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) {
|
|||
ary_params.push_back(create<ast::TypeConstructorExpression>(
|
||||
&vec, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.0)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.0)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.5)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.5)),
|
||||
}));
|
||||
|
||||
ary_params.push_back(create<ast::TypeConstructorExpression>(
|
||||
&vec, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, -0.5)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, -0.5)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
|
||||
}));
|
||||
|
||||
ary_params.push_back(create<ast::TypeConstructorExpression>(
|
||||
&vec, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.5)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.5)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, -0.5)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, -0.5)),
|
||||
}));
|
||||
|
||||
ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &arr, true,
|
||||
|
@ -931,7 +931,7 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) {
|
|||
ast::ArrayAccessorExpression expr(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("pos"), "pos"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)));
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)));
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error();
|
||||
|
@ -977,9 +977,9 @@ TEST_F(BuilderTest, Accessor_Const_Vec) {
|
|||
|
||||
ast::ExpressionList vec_params;
|
||||
vec_params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.0)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.0)));
|
||||
vec_params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.5)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.5)));
|
||||
|
||||
ast::Variable var(
|
||||
Source{}, "pos", ast::StorageClass::kPrivate, &vec, true,
|
||||
|
@ -989,7 +989,7 @@ TEST_F(BuilderTest, Accessor_Const_Vec) {
|
|||
ast::ArrayAccessorExpression expr(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("pos"), "pos"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)));
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)));
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error();
|
||||
|
|
|
@ -50,7 +50,7 @@ TEST_F(BuilderTest, Assign_Var) {
|
|||
auto* ident =
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var");
|
||||
auto* val = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
|
||||
|
||||
ast::AssignmentStatement assign(ident, val);
|
||||
|
||||
|
@ -120,16 +120,16 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) {
|
|||
auto* first = create<ast::TypeConstructorExpression>(
|
||||
&vec2, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f)),
|
||||
});
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
first,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
|
||||
});
|
||||
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false,
|
||||
|
@ -174,11 +174,11 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
|
@ -239,7 +239,7 @@ TEST_F(BuilderTest, Assign_StructMember) {
|
|||
create<ast::IdentifierExpression>(mod->RegisterSymbol("b"), "b"));
|
||||
|
||||
auto* val = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 4.0f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 4.0f));
|
||||
|
||||
ast::AssignmentStatement assign(ident, val);
|
||||
|
||||
|
@ -282,11 +282,11 @@ TEST_F(BuilderTest, Assign_Vector) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* val = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
|
@ -330,7 +330,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) {
|
|||
create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("y"), "y"));
|
||||
auto* val = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
|
||||
|
||||
ast::AssignmentStatement assign(ident, val);
|
||||
|
||||
|
@ -375,9 +375,9 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) {
|
|||
auto* ident = create<ast::ArrayAccessorExpression>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
auto* val = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
|
||||
|
||||
ast::AssignmentStatement assign(ident, val);
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 4));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 4));
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
||||
|
@ -84,21 +84,21 @@ TEST_P(BinaryArithSignedIntegerTest, Vector) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
});
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
@ -175,9 +175,9 @@ TEST_P(BinaryArithUnsignedIntegerTest, Scalar) {
|
|||
ast::type::U32 u32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 3));
|
||||
create<ast::UintLiteral>(Source{}, &u32, 3));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 4));
|
||||
create<ast::UintLiteral>(Source{}, &u32, 4));
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
||||
|
@ -202,21 +202,21 @@ TEST_P(BinaryArithUnsignedIntegerTest, Vector) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
});
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
@ -256,9 +256,9 @@ TEST_P(BinaryArithFloatTest, Scalar) {
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.2f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.2f));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 4.5f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 4.5f));
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
||||
|
@ -283,21 +283,21 @@ TEST_P(BinaryArithFloatTest, Vector) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
});
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
@ -331,9 +331,9 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) {
|
|||
ast::type::U32 u32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 3));
|
||||
create<ast::UintLiteral>(Source{}, &u32, 3));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 4));
|
||||
create<ast::UintLiteral>(Source{}, &u32, 4));
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
||||
|
@ -360,21 +360,21 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Vector) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 1)),
|
||||
create<ast::UintLiteral>(Source{}, &u32, 1)),
|
||||
});
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
@ -412,9 +412,9 @@ TEST_P(BinaryCompareSignedIntegerTest, Scalar) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 4));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 4));
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
||||
|
@ -441,21 +441,21 @@ TEST_P(BinaryCompareSignedIntegerTest, Vector) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
});
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
@ -493,9 +493,9 @@ TEST_P(BinaryCompareFloatTest, Scalar) {
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.2f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.2f));
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 4.5f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 4.5f));
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
||||
|
@ -522,21 +522,21 @@ TEST_P(BinaryCompareFloatTest, Vector) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
});
|
||||
|
||||
ast::BinaryExpression expr(param.op, lhs, rhs);
|
||||
|
@ -574,15 +574,15 @@ TEST_F(BuilderTest, Binary_Multiply_VectorScalar) {
|
|||
auto* lhs = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)),
|
||||
});
|
||||
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||
|
||||
|
@ -605,15 +605,15 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarVector) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kMultiply, lhs, rhs);
|
||||
|
@ -647,7 +647,7 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) {
|
|||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
||||
|
@ -685,7 +685,7 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) {
|
|||
nullptr, // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f));
|
||||
auto* rhs =
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("mat"), "mat");
|
||||
|
||||
|
@ -730,11 +730,11 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
auto* rhs = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
@ -777,11 +777,11 @@ TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
auto* lhs = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
auto* rhs =
|
||||
|
@ -855,19 +855,19 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) {
|
|||
TEST_F(BuilderTest, Binary_LogicalAnd) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs =
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
auto* lhs = create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
|
||||
auto* rhs =
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 4)));
|
||||
auto* rhs = create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 4)));
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, lhs, rhs);
|
||||
|
||||
|
@ -907,17 +907,17 @@ TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) {
|
|||
&bool_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* b_var = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
"b", // name
|
||||
ast::StorageClass::kFunction, // storage_class
|
||||
&bool_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, false)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::ScalarConstructorExpression>(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");
|
||||
|
@ -966,14 +966,15 @@ TEST_F(BuilderTest, Binary_logicalOr_Nested_LogicalAnd) {
|
|||
auto* logical_and_expr = create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLogicalAnd,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_ty, true)),
|
||||
create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_ty, false)));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_ty, false)));
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_ty, true)),
|
||||
logical_and_expr);
|
||||
ast::BinaryExpression expr(
|
||||
ast::BinaryOp::kLogicalOr,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
|
||||
logical_and_expr);
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
||||
|
@ -1012,14 +1013,15 @@ TEST_F(BuilderTest, Binary_logicalAnd_Nested_LogicalOr) {
|
|||
auto* logical_or_expr = create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLogicalOr,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_ty, true)),
|
||||
create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_ty, false)));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_ty, false)));
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_ty, true)),
|
||||
logical_or_expr);
|
||||
ast::BinaryExpression expr(
|
||||
ast::BinaryOp::kLogicalAnd,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(Source{}, &bool_ty, true)),
|
||||
logical_or_expr);
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
||||
|
@ -1051,19 +1053,19 @@ OpBranch %4
|
|||
TEST_F(BuilderTest, Binary_LogicalOr) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs =
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
auto* lhs = create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)));
|
||||
|
||||
auto* rhs =
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 4)));
|
||||
auto* rhs = create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(Source{}, &i32, 4)));
|
||||
|
||||
ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, lhs, rhs);
|
||||
|
||||
|
@ -1103,17 +1105,17 @@ TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) {
|
|||
&bool_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* b_var = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
"b", // name
|
||||
ast::StorageClass::kFunction, // storage_class
|
||||
&bool_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, false)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::ScalarConstructorExpression>(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");
|
||||
|
|
|
@ -35,9 +35,9 @@ TEST_F(BuilderTest, Bitcast) {
|
|||
ast::type::U32 u32;
|
||||
ast::type::F32 f32;
|
||||
|
||||
ast::BitcastExpression bitcast(&u32,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.4)));
|
||||
ast::BitcastExpression bitcast(
|
||||
&u32, create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&bitcast)) << td.error();
|
||||
|
||||
|
@ -56,9 +56,9 @@ TEST_F(BuilderTest, Bitcast) {
|
|||
TEST_F(BuilderTest, Bitcast_DuplicateType) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
ast::BitcastExpression bitcast(&f32,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.4)));
|
||||
ast::BitcastExpression bitcast(
|
||||
&f32, create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.4)));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&bitcast)) << td.error();
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ TEST_F(BuilderTest, Block) {
|
|||
outer.append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f))));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f))));
|
||||
|
||||
auto* inner = create<ast::BlockStatement>();
|
||||
inner->append(create<ast::VariableDeclStatement>(
|
||||
|
@ -66,13 +66,13 @@ TEST_F(BuilderTest, Block) {
|
|||
inner->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f))));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f))));
|
||||
|
||||
outer.append(inner);
|
||||
outer.append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("var"), "var"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f))));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f))));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&outer)) << td.error();
|
||||
|
||||
|
|
|
@ -77,9 +77,9 @@ TEST_F(BuilderTest, Expression_Call) {
|
|||
|
||||
ast::ExpressionList call_params;
|
||||
call_params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
call_params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
|
||||
ast::CallExpression expr(create<ast::IdentifierExpression>(
|
||||
mod->RegisterSymbol("a_func"), "a_func"),
|
||||
|
@ -159,9 +159,9 @@ TEST_F(BuilderTest, Statement_Call) {
|
|||
|
||||
ast::ExpressionList call_params;
|
||||
call_params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
call_params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.f)));
|
||||
|
||||
ast::CallStatement expr(
|
||||
create<ast::CallExpression>(create<ast::IdentifierExpression>(
|
||||
|
|
|
@ -70,11 +70,11 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
||||
|
@ -110,16 +110,16 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec(&f32, 2);
|
||||
|
||||
auto* rel =
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kAdd,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
auto* rel = create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kAdd,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(rel);
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
@ -160,7 +160,7 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) {
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* init = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
|
@ -207,7 +207,7 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) {
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* init = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f));
|
||||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
|
@ -250,11 +250,11 @@ TEST_F(BuilderTest, FunctionVar_Const) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
||||
|
|
|
@ -99,11 +99,11 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
||||
|
@ -135,11 +135,11 @@ TEST_F(BuilderTest, GlobalVar_Const) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
||||
|
@ -168,11 +168,11 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
@ -201,16 +201,16 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
|
|||
auto* first = create<ast::TypeConstructorExpression>(
|
||||
&vec2, ast::ExpressionList{
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0f)),
|
||||
});
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(
|
||||
&vec3, ast::ExpressionList{
|
||||
first,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)),
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)),
|
||||
});
|
||||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
@ -328,7 +328,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
|
|||
&bool_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true)), // constructor
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true)), // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::ConstantIdDecoration>(1200, Source{}),
|
||||
|
@ -383,7 +383,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
|
|||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{
|
||||
// decorations
|
||||
create<ast::ConstantIdDecoration>(0, Source{}),
|
||||
|
|
|
@ -43,11 +43,11 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
||||
|
@ -102,11 +102,11 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
||||
|
@ -195,7 +195,7 @@ TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) {
|
|||
|
||||
ast::Variable var(Source{}, "var", ast::StorageClass::kNone, &i32, true,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)),
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
|
|
|
@ -46,7 +46,7 @@ TEST_F(BuilderTest, If_Empty) {
|
|||
// if (true) {
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
ast::IfStatement expr(Source{}, cond, create<ast::BlockStatement>(),
|
||||
ast::ElseStatementList{});
|
||||
|
@ -88,10 +88,10 @@ TEST_F(BuilderTest, If_WithStatements) {
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))));
|
||||
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
ast::IfStatement expr(Source{}, cond, body, ast::ElseStatementList{});
|
||||
|
||||
|
@ -142,16 +142,16 @@ TEST_F(BuilderTest, If_WithElse) {
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3))));
|
||||
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
ast::IfStatement expr(Source{}, cond, body,
|
||||
{create<ast::ElseStatement>(else_body)});
|
||||
|
@ -208,19 +208,19 @@ TEST_F(BuilderTest, If_WithElseIf) {
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3))));
|
||||
|
||||
auto* else_cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
ast::IfStatement expr(Source{}, cond, body,
|
||||
{create<ast::ElseStatement>(else_cond, else_body)});
|
||||
|
@ -286,30 +286,30 @@ TEST_F(BuilderTest, If_WithMultiple) {
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 4))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 5))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 5))));
|
||||
|
||||
auto* elseif_1_cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* elseif_2_cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, false));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, false));
|
||||
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
ast::IfStatement expr(
|
||||
Source{}, cond, body,
|
||||
|
@ -376,7 +376,7 @@ TEST_F(BuilderTest, If_WithBreak) {
|
|||
// }
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
auto* if_body = create<ast::BlockStatement>();
|
||||
if_body->append(create<ast::BreakStatement>());
|
||||
|
@ -424,7 +424,7 @@ TEST_F(BuilderTest, If_WithElseBreak) {
|
|||
// }
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
auto* else_body = create<ast::BlockStatement>();
|
||||
else_body->append(create<ast::BreakStatement>());
|
||||
|
@ -474,7 +474,7 @@ TEST_F(BuilderTest, If_WithContinue) {
|
|||
// }
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
auto* if_body = create<ast::BlockStatement>();
|
||||
if_body->append(create<ast::ContinueStatement>());
|
||||
|
@ -522,7 +522,7 @@ TEST_F(BuilderTest, If_WithElseContinue) {
|
|||
// }
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
auto* else_body = create<ast::BlockStatement>();
|
||||
else_body->append(create<ast::ContinueStatement>());
|
||||
|
@ -570,7 +570,7 @@ TEST_F(BuilderTest, If_WithReturn) {
|
|||
// return;
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
|
||||
auto* if_body = create<ast::BlockStatement>();
|
||||
if_body->append(create<ast::ReturnStatement>(Source{}));
|
||||
|
@ -600,9 +600,9 @@ TEST_F(BuilderTest, If_WithReturnValue) {
|
|||
// return false;
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* cond2 = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, false));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, false));
|
||||
|
||||
auto* if_body = create<ast::BlockStatement>();
|
||||
if_body->append(create<ast::ReturnStatement>(Source{}, cond2));
|
||||
|
|
|
@ -35,7 +35,7 @@ using BuilderTest = TestHelper;
|
|||
|
||||
TEST_F(BuilderTest, Literal_Bool_True) {
|
||||
ast::type::Bool bool_type;
|
||||
ast::BoolLiteral b_true(&bool_type, true);
|
||||
ast::BoolLiteral b_true(Source{}, &bool_type, true);
|
||||
|
||||
auto id = b.GenerateLiteralIfNeeded(nullptr, &b_true);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
@ -48,7 +48,7 @@ TEST_F(BuilderTest, Literal_Bool_True) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_Bool_False) {
|
||||
ast::type::Bool bool_type;
|
||||
ast::BoolLiteral b_false(&bool_type, false);
|
||||
ast::BoolLiteral b_false(Source{}, &bool_type, false);
|
||||
|
||||
auto id = b.GenerateLiteralIfNeeded(nullptr, &b_false);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
@ -61,8 +61,8 @@ TEST_F(BuilderTest, Literal_Bool_False) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_Bool_Dedup) {
|
||||
ast::type::Bool bool_type;
|
||||
ast::BoolLiteral b_true(&bool_type, true);
|
||||
ast::BoolLiteral b_false(&bool_type, false);
|
||||
ast::BoolLiteral b_true(Source{}, &bool_type, true);
|
||||
ast::BoolLiteral b_false(Source{}, &bool_type, false);
|
||||
|
||||
ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &b_true), 0u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
@ -79,7 +79,7 @@ TEST_F(BuilderTest, Literal_Bool_Dedup) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_I32) {
|
||||
ast::type::I32 i32;
|
||||
ast::SintLiteral i(&i32, -23);
|
||||
ast::SintLiteral i(Source{}, &i32, -23);
|
||||
|
||||
auto id = b.GenerateLiteralIfNeeded(nullptr, &i);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
@ -92,8 +92,8 @@ TEST_F(BuilderTest, Literal_I32) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_I32_Dedup) {
|
||||
ast::type::I32 i32;
|
||||
ast::SintLiteral i1(&i32, -23);
|
||||
ast::SintLiteral i2(&i32, -23);
|
||||
ast::SintLiteral i1(Source{}, &i32, -23);
|
||||
ast::SintLiteral i2(Source{}, &i32, -23);
|
||||
|
||||
ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i1), 0u);
|
||||
ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i2), 0u);
|
||||
|
@ -106,7 +106,7 @@ TEST_F(BuilderTest, Literal_I32_Dedup) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_U32) {
|
||||
ast::type::U32 u32;
|
||||
ast::UintLiteral i(&u32, 23);
|
||||
ast::UintLiteral i(Source{}, &u32, 23);
|
||||
|
||||
auto id = b.GenerateLiteralIfNeeded(nullptr, &i);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
@ -119,8 +119,8 @@ TEST_F(BuilderTest, Literal_U32) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_U32_Dedup) {
|
||||
ast::type::U32 u32;
|
||||
ast::UintLiteral i1(&u32, 23);
|
||||
ast::UintLiteral i2(&u32, 23);
|
||||
ast::UintLiteral i1(Source{}, &u32, 23);
|
||||
ast::UintLiteral i2(Source{}, &u32, 23);
|
||||
|
||||
ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i1), 0u);
|
||||
ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i2), 0u);
|
||||
|
@ -133,7 +133,7 @@ TEST_F(BuilderTest, Literal_U32_Dedup) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_F32) {
|
||||
ast::type::F32 f32;
|
||||
ast::FloatLiteral i(&f32, 23.245f);
|
||||
ast::FloatLiteral i(Source{}, &f32, 23.245f);
|
||||
|
||||
auto id = b.GenerateLiteralIfNeeded(nullptr, &i);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
@ -146,8 +146,8 @@ TEST_F(BuilderTest, Literal_F32) {
|
|||
|
||||
TEST_F(BuilderTest, Literal_F32_Dedup) {
|
||||
ast::type::F32 f32;
|
||||
ast::FloatLiteral i1(&f32, 23.245f);
|
||||
ast::FloatLiteral i2(&f32, 23.245f);
|
||||
ast::FloatLiteral i1(Source{}, &f32, 23.245f);
|
||||
ast::FloatLiteral i2(Source{}, &f32, 23.245f);
|
||||
|
||||
ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i1), 0u);
|
||||
ASSERT_NE(b.GenerateLiteralIfNeeded(nullptr, &i2), 0u);
|
||||
|
|
|
@ -78,7 +78,7 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) {
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))));
|
||||
|
||||
ast::LoopStatement expr(body, create<ast::BlockStatement>());
|
||||
|
||||
|
@ -131,13 +131,13 @@ TEST_F(BuilderTest, Loop_WithContinuing) {
|
|||
body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3))));
|
||||
ast::LoopStatement expr(body, continuing);
|
||||
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
|
|
@ -51,11 +51,11 @@ TEST_F(BuilderTest, Return_WithValue) {
|
|||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0f)));
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.0f)));
|
||||
|
||||
auto* val = create<ast::TypeConstructorExpression>(&vec, vals);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST_F(BuilderTest, Switch_Empty) {
|
|||
// switch (1) {
|
||||
// }
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
ast::SwitchStatement expr(cond, ast::CaseStatementList{});
|
||||
|
||||
|
@ -97,19 +97,19 @@ TEST_F(BuilderTest, Switch_WithCase) {
|
|||
case_1_body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2))));
|
||||
|
||||
ast::CaseSelectorList selector_1;
|
||||
selector_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
ast::CaseSelectorList selector_2;
|
||||
selector_2.push_back(create<ast::SintLiteral>(&i32, 2));
|
||||
selector_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
|
||||
|
@ -191,7 +191,7 @@ TEST_F(BuilderTest, Switch_WithDefault) {
|
|||
default_body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1))));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(default_body));
|
||||
|
@ -270,26 +270,26 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) {
|
|||
case_1_body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3))));
|
||||
|
||||
ast::CaseSelectorList selector_1;
|
||||
selector_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
ast::CaseSelectorList selector_2;
|
||||
selector_2.push_back(create<ast::SintLiteral>(&i32, 2));
|
||||
selector_2.push_back(create<ast::SintLiteral>(&i32, 3));
|
||||
selector_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
selector_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 3));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
|
||||
|
@ -379,26 +379,26 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) {
|
|||
case_1_body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2))));
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 3))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 3))));
|
||||
|
||||
ast::CaseSelectorList selector_1;
|
||||
selector_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
ast::CaseSelectorList selector_2;
|
||||
selector_2.push_back(create<ast::SintLiteral>(&i32, 2));
|
||||
selector_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
|
||||
|
@ -484,11 +484,11 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) {
|
|||
case_1_body->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>(mod->RegisterSymbol("v"), "v"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1))));
|
||||
case_1_body->append(create<ast::FallthroughStatement>());
|
||||
|
||||
ast::CaseSelectorList selector_1;
|
||||
selector_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
|
||||
|
@ -545,19 +545,19 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) {
|
|||
if_body->append(create<ast::BreakStatement>());
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>();
|
||||
case_1_body->append(
|
||||
create<ast::IfStatement>(Source{},
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true)),
|
||||
if_body, ast::ElseStatementList{}));
|
||||
case_1_body->append(create<ast::IfStatement>(
|
||||
Source{},
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
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::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1))));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1))));
|
||||
|
||||
ast::CaseSelectorList selector_1;
|
||||
selector_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
selector_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
|
||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) {
|
|||
|
||||
ast::UnaryOpExpression expr(ast::UnaryOp::kNegation,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1)));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1)));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
||||
|
@ -59,9 +59,10 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) {
|
|||
TEST_F(BuilderTest, UnaryOp_Negation_Float) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
ast::UnaryOpExpression expr(ast::UnaryOp::kNegation,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1)));
|
||||
ast::UnaryOpExpression expr(
|
||||
ast::UnaryOp::kNegation,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1)));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
||||
|
@ -78,9 +79,10 @@ TEST_F(BuilderTest, UnaryOp_Negation_Float) {
|
|||
TEST_F(BuilderTest, UnaryOp_Not) {
|
||||
ast::type::Bool bool_type;
|
||||
|
||||
ast::UnaryOpExpression expr(ast::UnaryOp::kNot,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, false)));
|
||||
ast::UnaryOpExpression expr(
|
||||
ast::UnaryOp::kNot,
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, false)));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ using WgslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) {
|
||||
ast::type::I32 i32;
|
||||
auto* lit = create<ast::SintLiteral>(&i32, 5);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, 5);
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(lit);
|
||||
auto* ary =
|
||||
create<ast::IdentifierExpression>(mod.RegisterSymbol("ary"), "ary");
|
||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Case) {
|
|||
body->append(create<ast::BreakStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
@ -56,8 +56,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
|||
body->append(create<ast::BreakStatement>());
|
||||
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(&i32, 6));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(Source{}, &i32, 6));
|
||||
ast::CaseStatement c(lit, body);
|
||||
|
||||
gen.increment_indent();
|
||||
|
|
|
@ -37,7 +37,7 @@ using WgslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) {
|
||||
ast::type::Bool bool_type;
|
||||
auto* lit = create<ast::BoolLiteral>(&bool_type, false);
|
||||
auto* lit = create<ast::BoolLiteral>(Source{}, &bool_type, false);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -46,7 +46,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) {
|
||||
ast::type::I32 i32;
|
||||
auto* lit = create<ast::SintLiteral>(&i32, -12345);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -55,7 +55,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) {
|
||||
ast::type::U32 u32;
|
||||
auto* lit = create<ast::UintLiteral>(&u32, 56779);
|
||||
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 56779);
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -65,8 +65,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) {
|
|||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) {
|
||||
ast::type::F32 f32;
|
||||
// Use a number close to 1<<30 but whose decimal representation ends in 0.
|
||||
auto* lit =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>((1 << 30) - 4));
|
||||
auto* lit = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>((1 << 30) - 4));
|
||||
ast::ScalarConstructorExpression expr(lit);
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructor(&expr)) << gen.error();
|
||||
|
@ -76,7 +76,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) {
|
|||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* lit = create<ast::FloatLiteral>(&f32, -1.2e-5);
|
||||
auto* lit = create<ast::FloatLiteral>(Source{}, &f32, -1.2e-5);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -89,7 +89,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) {
|
|||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Bool) {
|
||||
ast::type::Bool b;
|
||||
|
||||
auto* lit = create<ast::BoolLiteral>(&b, true);
|
||||
auto* lit = create<ast::BoolLiteral>(Source{}, &b, true);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -102,7 +102,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Bool) {
|
|||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Int) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lit = create<ast::SintLiteral>(&i32, -12345);
|
||||
auto* lit = create<ast::SintLiteral>(Source{}, &i32, -12345);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -115,7 +115,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Int) {
|
|||
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Uint) {
|
||||
ast::type::U32 u32;
|
||||
|
||||
auto* lit = create<ast::UintLiteral>(&u32, 12345);
|
||||
auto* lit = create<ast::UintLiteral>(Source{}, &u32, 12345);
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit));
|
||||
|
||||
|
@ -129,9 +129,9 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec(&f32, 3);
|
||||
|
||||
auto* lit1 = create<ast::FloatLiteral>(&f32, 1.f);
|
||||
auto* lit2 = create<ast::FloatLiteral>(&f32, 2.f);
|
||||
auto* lit3 = create<ast::FloatLiteral>(&f32, 3.f);
|
||||
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));
|
||||
|
@ -152,10 +152,10 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) {
|
|||
ast::ExpressionList mat_values;
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto* lit1 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(1 + (i * 2)));
|
||||
auto* lit2 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(2 + (i * 2)));
|
||||
auto* lit1 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(1 + (i * 2)));
|
||||
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(2 + (i * 2)));
|
||||
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit1));
|
||||
|
@ -179,12 +179,12 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) {
|
|||
ast::ExpressionList ary_values;
|
||||
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
auto* lit1 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(1 + (i * 3)));
|
||||
auto* lit2 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(2 + (i * 3)));
|
||||
auto* lit3 =
|
||||
create<ast::FloatLiteral>(&f32, static_cast<float>(3 + (i * 3)));
|
||||
auto* lit1 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(1 + (i * 3)));
|
||||
auto* lit2 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(2 + (i * 3)));
|
||||
auto* lit3 = create<ast::FloatLiteral>(Source{}, &f32,
|
||||
static_cast<float>(3 + (i * 3)));
|
||||
|
||||
ast::ExpressionList values;
|
||||
values.push_back(create<ast::ScalarConstructorExpression>(lit1));
|
||||
|
|
|
@ -38,7 +38,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) {
|
|||
|
||||
ast::type::I32 i32;
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
case_val.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
|
||||
auto* case_body = create<ast::BlockStatement>();
|
||||
case_body->append(create<ast::BreakStatement>());
|
||||
|
|
Loading…
Reference in New Issue