ast: Remove Variable constructor that doesn't take a source
set_source() will be removed, so sources will only be specifiable at construction time. Bug: tint:390 Change-Id: I5c79efd3fa501ebd9308f7f93cfb77bc12198047 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35009 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
b4b29639a1
commit
321e5a9d7e
|
@ -32,7 +32,7 @@ Builder::~Builder() = default;
|
|||
Variable* Builder::Var(const std::string& name,
|
||||
StorageClass storage,
|
||||
type::Type* type) {
|
||||
auto* var = create<Variable>(name, storage, type);
|
||||
auto* var = create<Variable>(Source{}, name, storage, type);
|
||||
OnVariableBuilt(var);
|
||||
return var;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ Variable* Builder::Var(const std::string& name,
|
|||
Variable* Builder::Const(const std::string& name,
|
||||
StorageClass storage,
|
||||
type::Type* type) {
|
||||
auto* var = create<Variable>(name, storage, type);
|
||||
auto* var = create<Variable>(Source{}, name, storage, type);
|
||||
var->set_is_const(true);
|
||||
OnVariableBuilt(var);
|
||||
return var;
|
||||
|
|
|
@ -34,7 +34,7 @@ using DecoratedVariableTest = TestHelper;
|
|||
|
||||
TEST_F(DecoratedVariableTest, Creation) {
|
||||
type::I32 t;
|
||||
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
|
||||
auto* var = create<Variable>(Source{}, "my_var", StorageClass::kFunction, &t);
|
||||
DecoratedVariable dv(var);
|
||||
|
||||
EXPECT_EQ(dv.name(), "my_var");
|
||||
|
@ -63,7 +63,7 @@ TEST_F(DecoratedVariableTest, CreationWithSource) {
|
|||
|
||||
TEST_F(DecoratedVariableTest, NoDecorations) {
|
||||
type::I32 t;
|
||||
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
|
||||
auto* var = create<Variable>(Source{}, "my_var", StorageClass::kFunction, &t);
|
||||
DecoratedVariable dv(var);
|
||||
EXPECT_FALSE(dv.HasLocationDecoration());
|
||||
EXPECT_FALSE(dv.HasBuiltinDecoration());
|
||||
|
@ -72,7 +72,7 @@ TEST_F(DecoratedVariableTest, NoDecorations) {
|
|||
|
||||
TEST_F(DecoratedVariableTest, WithDecorations) {
|
||||
type::F32 t;
|
||||
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
|
||||
auto* var = create<Variable>(Source{}, "my_var", StorageClass::kFunction, &t);
|
||||
DecoratedVariable dv(var);
|
||||
|
||||
VariableDecorationList decos;
|
||||
|
@ -89,7 +89,7 @@ TEST_F(DecoratedVariableTest, WithDecorations) {
|
|||
|
||||
TEST_F(DecoratedVariableTest, ConstantId) {
|
||||
type::F32 t;
|
||||
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
|
||||
auto* var = create<Variable>(Source{}, "my_var", StorageClass::kFunction, &t);
|
||||
DecoratedVariable dv(var);
|
||||
|
||||
VariableDecorationList decos;
|
||||
|
@ -101,20 +101,21 @@ TEST_F(DecoratedVariableTest, ConstantId) {
|
|||
|
||||
TEST_F(DecoratedVariableTest, IsValid) {
|
||||
type::I32 t;
|
||||
auto* var = create<Variable>("my_var", StorageClass::kNone, &t);
|
||||
auto* var = create<Variable>(Source{}, "my_var", StorageClass::kNone, &t);
|
||||
DecoratedVariable dv(var);
|
||||
EXPECT_TRUE(dv.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(DecoratedVariableTest, IsDecorated) {
|
||||
type::I32 t;
|
||||
DecoratedVariable dv(create<Variable>("my_var", StorageClass::kNone, &t));
|
||||
DecoratedVariable dv(
|
||||
create<Variable>(Source{}, "my_var", StorageClass::kNone, &t));
|
||||
EXPECT_TRUE(dv.Is<DecoratedVariable>());
|
||||
}
|
||||
|
||||
TEST_F(DecoratedVariableTest, to_str) {
|
||||
type::F32 t;
|
||||
auto* var = create<Variable>("my_var", StorageClass::kFunction, &t);
|
||||
auto* var = create<Variable>(Source{}, "my_var", StorageClass::kFunction, &t);
|
||||
DecoratedVariable dv(var);
|
||||
dv.set_constructor(create<IdentifierExpression>("expr"));
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ TEST_F(FunctionTest, Creation) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
auto* var = params[0];
|
||||
|
||||
Function f(Source{}, "func", params, &void_type, create<BlockStatement>(),
|
||||
|
@ -53,7 +54,8 @@ TEST_F(FunctionTest, Creation_WithSource) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
|
||||
Function f(Source{Source::Location{20, 2}}, "func", params, &void_type,
|
||||
create<BlockStatement>(), FunctionDecorationList{});
|
||||
|
@ -66,7 +68,7 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) {
|
|||
type::Void void_type;
|
||||
type::I32 i32;
|
||||
|
||||
Variable v("var", StorageClass::kInput, &i32);
|
||||
Variable v(Source{}, "var", StorageClass::kInput, &i32);
|
||||
Function f(Source{}, "func", VariableList{}, &void_type,
|
||||
create<BlockStatement>(), FunctionDecorationList{});
|
||||
|
||||
|
@ -77,7 +79,7 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) {
|
|||
f.add_referenced_module_variable(&v);
|
||||
ASSERT_EQ(f.referenced_module_variables().size(), 1u);
|
||||
|
||||
Variable v2("var2", StorageClass::kOutput, &i32);
|
||||
Variable v2(Source{}, "var2", StorageClass::kOutput, &i32);
|
||||
f.add_referenced_module_variable(&v2);
|
||||
ASSERT_EQ(f.referenced_module_variables().size(), 2u);
|
||||
EXPECT_EQ(f.referenced_module_variables()[1], &v2);
|
||||
|
@ -87,19 +89,21 @@ TEST_F(FunctionTest, GetReferenceLocations) {
|
|||
type::Void void_type;
|
||||
type::I32 i32;
|
||||
|
||||
DecoratedVariable loc1(create<Variable>("loc1", StorageClass::kInput, &i32));
|
||||
DecoratedVariable loc1(
|
||||
create<Variable>(Source{}, "loc1", StorageClass::kInput, &i32));
|
||||
loc1.set_decorations({create<LocationDecoration>(0, Source{})});
|
||||
|
||||
DecoratedVariable loc2(create<Variable>("loc2", StorageClass::kInput, &i32));
|
||||
DecoratedVariable loc2(
|
||||
create<Variable>(Source{}, "loc2", StorageClass::kInput, &i32));
|
||||
loc2.set_decorations({create<LocationDecoration>(1, Source{})});
|
||||
|
||||
DecoratedVariable builtin1(
|
||||
create<Variable>("builtin1", StorageClass::kInput, &i32));
|
||||
create<Variable>(Source{}, "builtin1", StorageClass::kInput, &i32));
|
||||
builtin1.set_decorations(
|
||||
{create<BuiltinDecoration>(Builtin::kPosition, Source{})});
|
||||
|
||||
DecoratedVariable builtin2(
|
||||
create<Variable>("builtin2", StorageClass::kInput, &i32));
|
||||
create<Variable>(Source{}, "builtin2", StorageClass::kInput, &i32));
|
||||
builtin2.set_decorations(
|
||||
{create<BuiltinDecoration>(Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
@ -124,19 +128,21 @@ TEST_F(FunctionTest, GetReferenceBuiltins) {
|
|||
type::Void void_type;
|
||||
type::I32 i32;
|
||||
|
||||
DecoratedVariable loc1(create<Variable>("loc1", StorageClass::kInput, &i32));
|
||||
DecoratedVariable loc1(
|
||||
create<Variable>(Source{}, "loc1", StorageClass::kInput, &i32));
|
||||
loc1.set_decorations({create<LocationDecoration>(0, Source{})});
|
||||
|
||||
DecoratedVariable loc2(create<Variable>("loc2", StorageClass::kInput, &i32));
|
||||
DecoratedVariable loc2(
|
||||
create<Variable>(Source{}, "loc2", StorageClass::kInput, &i32));
|
||||
loc2.set_decorations({create<LocationDecoration>(1, Source{})});
|
||||
|
||||
DecoratedVariable builtin1(
|
||||
create<Variable>("builtin1", StorageClass::kInput, &i32));
|
||||
create<Variable>(Source{}, "builtin1", StorageClass::kInput, &i32));
|
||||
builtin1.set_decorations(
|
||||
{create<BuiltinDecoration>(Builtin::kPosition, Source{})});
|
||||
|
||||
DecoratedVariable builtin2(
|
||||
create<Variable>("builtin2", StorageClass::kInput, &i32));
|
||||
create<Variable>(Source{}, "builtin2", StorageClass::kInput, &i32));
|
||||
builtin2.set_decorations(
|
||||
{create<BuiltinDecoration>(Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
@ -176,7 +182,8 @@ TEST_F(FunctionTest, IsValid) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
@ -192,7 +199,8 @@ TEST_F(FunctionTest, IsValid_EmptyName) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
|
||||
Function f(Source{}, "", params, &void_type, create<BlockStatement>(),
|
||||
FunctionDecorationList{});
|
||||
|
@ -203,7 +211,8 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
|
||||
Function f(Source{}, "func", params, nullptr, create<BlockStatement>(),
|
||||
FunctionDecorationList{});
|
||||
|
@ -215,7 +224,8 @@ TEST_F(FunctionTest, IsValid_NullParam) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
params.push_back(nullptr);
|
||||
|
||||
Function f(Source{}, "func", params, &void_type, create<BlockStatement>(),
|
||||
|
@ -227,7 +237,8 @@ TEST_F(FunctionTest, IsValid_InvalidParam) {
|
|||
type::Void void_type;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, nullptr));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, nullptr));
|
||||
|
||||
Function f(Source{}, "func", params, &void_type, create<BlockStatement>(),
|
||||
FunctionDecorationList{});
|
||||
|
@ -239,7 +250,8 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
@ -256,7 +268,8 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
@ -316,7 +329,8 @@ TEST_F(FunctionTest, ToStr_WithParams) {
|
|||
type::I32 i32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
@ -355,8 +369,10 @@ TEST_F(FunctionTest, TypeName_WithParams) {
|
|||
type::F32 f32;
|
||||
|
||||
VariableList params;
|
||||
params.push_back(create<Variable>("var1", StorageClass::kNone, &i32));
|
||||
params.push_back(create<Variable>("var2", StorageClass::kNone, &f32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var1", StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<Variable>(Source{}, "var2", StorageClass::kNone, &f32));
|
||||
|
||||
Function f(Source{}, "func", params, &void_type, create<BlockStatement>(),
|
||||
FunctionDecorationList{});
|
||||
|
|
|
@ -67,7 +67,7 @@ TEST_F(ModuleTest, IsValid_Empty) {
|
|||
|
||||
TEST_F(ModuleTest, IsValid_GlobalVariable) {
|
||||
type::F32 f32;
|
||||
auto* var = create<Variable>("var", StorageClass::kInput, &f32);
|
||||
auto* var = create<Variable>(Source{}, "var", StorageClass::kInput, &f32);
|
||||
|
||||
Module m;
|
||||
m.AddGlobalVariable(var);
|
||||
|
@ -81,7 +81,7 @@ TEST_F(ModuleTest, IsValid_Null_GlobalVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ModuleTest, IsValid_Invalid_GlobalVariable) {
|
||||
auto* var = create<Variable>("var", StorageClass::kInput, nullptr);
|
||||
auto* var = create<Variable>(Source{}, "var", StorageClass::kInput, nullptr);
|
||||
|
||||
Module m;
|
||||
m.AddGlobalVariable(var);
|
||||
|
|
|
@ -27,9 +27,6 @@ namespace ast {
|
|||
|
||||
Variable::Variable() = default;
|
||||
|
||||
Variable::Variable(const std::string& name, StorageClass sc, type::Type* type)
|
||||
: Base(), name_(name), storage_class_(sc), type_(type) {}
|
||||
|
||||
Variable::Variable(const Source& source,
|
||||
const std::string& name,
|
||||
StorageClass sc,
|
||||
|
@ -41,9 +38,8 @@ Variable::Variable(Variable&&) = default;
|
|||
Variable::~Variable() = default;
|
||||
|
||||
Variable* Variable::Clone(CloneContext* ctx) const {
|
||||
auto* cloned =
|
||||
ctx->mod->create<Variable>(name(), storage_class(), ctx->Clone(type()));
|
||||
cloned->set_source(ctx->Clone(source()));
|
||||
auto* cloned = ctx->mod->create<Variable>(
|
||||
ctx->Clone(source()), name(), storage_class(), ctx->Clone(type()));
|
||||
cloned->set_constructor(ctx->Clone(constructor()));
|
||||
cloned->set_is_const(is_const());
|
||||
return cloned;
|
||||
|
|
|
@ -78,11 +78,6 @@ namespace ast {
|
|||
/// The storage class for a formal parameter is always StorageClass::kNone.
|
||||
class Variable : public Castable<Variable, Node> {
|
||||
public:
|
||||
/// Create a variable
|
||||
/// @param name the variables name
|
||||
/// @param sc the variable storage class
|
||||
/// @param type the value type
|
||||
Variable(const std::string& name, StorageClass sc, type::Type* type);
|
||||
/// Create a variable
|
||||
/// @param source the variable source
|
||||
/// @param name the variables name
|
||||
|
|
|
@ -26,7 +26,7 @@ using VariableDeclStatementTest = TestHelper;
|
|||
|
||||
TEST_F(VariableDeclStatementTest, Creation) {
|
||||
type::F32 f32;
|
||||
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
|
||||
auto* var = create<Variable>(Source{}, "a", StorageClass::kNone, &f32);
|
||||
|
||||
VariableDeclStatement stmt(var);
|
||||
EXPECT_EQ(stmt.variable(), var);
|
||||
|
@ -34,7 +34,7 @@ TEST_F(VariableDeclStatementTest, Creation) {
|
|||
|
||||
TEST_F(VariableDeclStatementTest, Creation_WithSource) {
|
||||
type::F32 f32;
|
||||
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
|
||||
auto* var = create<Variable>(Source{}, "a", StorageClass::kNone, &f32);
|
||||
|
||||
VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var);
|
||||
auto src = stmt.source();
|
||||
|
@ -44,7 +44,7 @@ TEST_F(VariableDeclStatementTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(VariableDeclStatementTest, IsVariableDecl) {
|
||||
type::F32 f32;
|
||||
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
|
||||
auto* var = create<Variable>(Source{}, "a", StorageClass::kNone, &f32);
|
||||
|
||||
VariableDeclStatement s(var);
|
||||
EXPECT_TRUE(s.Is<VariableDeclStatement>());
|
||||
|
@ -52,14 +52,14 @@ TEST_F(VariableDeclStatementTest, IsVariableDecl) {
|
|||
|
||||
TEST_F(VariableDeclStatementTest, IsValid) {
|
||||
type::F32 f32;
|
||||
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
|
||||
auto* var = create<Variable>(Source{}, "a", StorageClass::kNone, &f32);
|
||||
VariableDeclStatement stmt(var);
|
||||
EXPECT_TRUE(stmt.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsValid_InvalidVariable) {
|
||||
type::F32 f32;
|
||||
auto* var = create<Variable>("", StorageClass::kNone, &f32);
|
||||
auto* var = create<Variable>(Source{}, "", StorageClass::kNone, &f32);
|
||||
VariableDeclStatement stmt(var);
|
||||
EXPECT_FALSE(stmt.IsValid());
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ TEST_F(VariableDeclStatementTest, IsValid_NullVariable) {
|
|||
|
||||
TEST_F(VariableDeclStatementTest, ToStr) {
|
||||
type::F32 f32;
|
||||
auto* var = create<Variable>("a", StorageClass::kNone, &f32);
|
||||
auto* var = create<Variable>(Source{}, "a", StorageClass::kNone, &f32);
|
||||
|
||||
VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var);
|
||||
std::ostringstream out;
|
||||
|
|
|
@ -27,7 +27,7 @@ using VariableTest = TestHelper;
|
|||
|
||||
TEST_F(VariableTest, Creation) {
|
||||
type::I32 t;
|
||||
Variable v("my_var", StorageClass::kFunction, &t);
|
||||
Variable v(Source{}, "my_var", StorageClass::kFunction, &t);
|
||||
|
||||
EXPECT_EQ(v.name(), "my_var");
|
||||
EXPECT_EQ(v.storage_class(), StorageClass::kFunction);
|
||||
|
@ -68,43 +68,43 @@ TEST_F(VariableTest, CreationEmpty) {
|
|||
|
||||
TEST_F(VariableTest, IsValid) {
|
||||
type::I32 t;
|
||||
Variable v{"my_var", StorageClass::kNone, &t};
|
||||
Variable v{Source{}, "my_var", StorageClass::kNone, &t};
|
||||
EXPECT_TRUE(v.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_WithConstructor) {
|
||||
type::I32 t;
|
||||
Variable v{"my_var", StorageClass::kNone, &t};
|
||||
Variable v{Source{}, "my_var", StorageClass::kNone, &t};
|
||||
v.set_constructor(create<IdentifierExpression>("ident"));
|
||||
EXPECT_TRUE(v.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_MissinName) {
|
||||
type::I32 t;
|
||||
Variable v{"", StorageClass::kNone, &t};
|
||||
Variable v{Source{}, "", StorageClass::kNone, &t};
|
||||
EXPECT_FALSE(v.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_MissingType) {
|
||||
Variable v{"x", StorageClass::kNone, nullptr};
|
||||
Variable v{Source{}, "x", StorageClass::kNone, nullptr};
|
||||
EXPECT_FALSE(v.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_MissingBoth) {
|
||||
Variable v("", StorageClass::kNone, nullptr);
|
||||
Variable v{Source{}, "", StorageClass::kNone, nullptr};
|
||||
EXPECT_FALSE(v.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_InvalidConstructor) {
|
||||
type::I32 t;
|
||||
Variable v{"my_var", StorageClass::kNone, &t};
|
||||
Variable v{Source{}, "my_var", StorageClass::kNone, &t};
|
||||
v.set_constructor(create<IdentifierExpression>(""));
|
||||
EXPECT_FALSE(v.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, to_str) {
|
||||
type::F32 t;
|
||||
Variable v{"my_var", StorageClass::kFunction, &t};
|
||||
Variable v{Source{}, "my_var", StorageClass::kFunction, &t};
|
||||
std::ostringstream out;
|
||||
v.to_str(out, 2);
|
||||
EXPECT_EQ(out.str(), R"( Variable{
|
||||
|
|
|
@ -114,10 +114,10 @@ class InspectorHelper {
|
|||
for (auto inout : inout_vars) {
|
||||
std::string in, out;
|
||||
std::tie(in, out) = inout;
|
||||
auto* in_var =
|
||||
create<ast::Variable>(in, ast::StorageClass::kInput, u32_type());
|
||||
auto* out_var =
|
||||
create<ast::Variable>(out, ast::StorageClass::kOutput, u32_type());
|
||||
auto* in_var = create<ast::Variable>(
|
||||
Source{}, in, ast::StorageClass::kInput, u32_type());
|
||||
auto* out_var = create<ast::Variable>(
|
||||
Source{}, out, ast::StorageClass::kOutput, u32_type());
|
||||
mod()->AddGlobalVariable(in_var);
|
||||
mod()->AddGlobalVariable(out_var);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class InspectorHelper {
|
|||
ast::type::Type* type,
|
||||
T* val) {
|
||||
auto* dvar = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>(name, ast::StorageClass::kNone, type));
|
||||
create<ast::Variable>(Source{}, name, ast::StorageClass::kNone, type));
|
||||
dvar->set_is_const(true);
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::ConstantIdDecoration>(id, Source{}));
|
||||
|
@ -349,7 +349,7 @@ class InspectorHelper {
|
|||
uint32_t set,
|
||||
uint32_t binding) {
|
||||
auto* var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>(name, storage_class, type));
|
||||
create<ast::Variable>(Source{}, name, storage_class, type));
|
||||
ast::VariableDecorationList decorations;
|
||||
|
||||
decorations.push_back(create<ast::BindingDecoration>(binding, Source{}));
|
||||
|
@ -399,8 +399,9 @@ class InspectorHelper {
|
|||
ast::type::Type* member_type;
|
||||
std::tie(member_idx, member_type) = member;
|
||||
std::string member_name = StructMemberName(member_idx, member_type);
|
||||
body->append(create<ast::VariableDeclStatement>(create<ast::Variable>(
|
||||
"local" + member_name, ast::StorageClass::kNone, member_type)));
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
create<ast::Variable>(Source{}, "local" + member_name,
|
||||
ast::StorageClass::kNone, member_type)));
|
||||
}
|
||||
|
||||
for (auto member : members) {
|
||||
|
@ -494,16 +495,16 @@ class InspectorHelper {
|
|||
}
|
||||
|
||||
void AddGlobalVariable(const std::string& name, ast::type::Type* type) {
|
||||
mod()->AddGlobalVariable(
|
||||
create<ast::Variable>(name, ast::StorageClass::kUniformConstant, type));
|
||||
mod()->AddGlobalVariable(create<ast::Variable>(
|
||||
Source{}, name, ast::StorageClass::kUniformConstant, type));
|
||||
}
|
||||
|
||||
/// Adds a depth texture variable to the module
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
void AddDepthTexture(const std::string& name, ast::type::Type* type) {
|
||||
mod()->AddGlobalVariable(
|
||||
create<ast::Variable>(name, ast::StorageClass::kUniformConstant, type));
|
||||
mod()->AddGlobalVariable(create<ast::Variable>(
|
||||
Source{}, name, ast::StorageClass::kUniformConstant, type));
|
||||
}
|
||||
|
||||
/// Generates a function that references a specific sampler variable
|
||||
|
@ -525,8 +526,9 @@ class InspectorHelper {
|
|||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
||||
auto* call_result = create<ast::Variable>(
|
||||
"sampler_result", ast::StorageClass::kFunction, vec_type(base_type, 4));
|
||||
auto* call_result = create<ast::Variable>(Source{}, "sampler_result",
|
||||
ast::StorageClass::kFunction,
|
||||
vec_type(base_type, 4));
|
||||
body->append(create<ast::VariableDeclStatement>(call_result));
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -565,8 +567,9 @@ class InspectorHelper {
|
|||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
||||
auto* call_result = create<ast::Variable>(
|
||||
"sampler_result", ast::StorageClass::kFunction, vec_type(base_type, 4));
|
||||
auto* call_result = create<ast::Variable>(Source{}, "sampler_result",
|
||||
ast::StorageClass::kFunction,
|
||||
vec_type(base_type, 4));
|
||||
body->append(create<ast::VariableDeclStatement>(call_result));
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -608,7 +611,7 @@ class InspectorHelper {
|
|||
auto* body = create<ast::BlockStatement>();
|
||||
|
||||
auto* call_result = create<ast::Variable>(
|
||||
"sampler_result", ast::StorageClass::kFunction, base_type);
|
||||
Source{}, "sampler_result", ast::StorageClass::kFunction, base_type);
|
||||
body->append(create<ast::VariableDeclStatement>(call_result));
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
|
|
@ -2094,8 +2094,9 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) {
|
|||
const std::string guard_name = block_info.flow_guard_name;
|
||||
if (!guard_name.empty()) {
|
||||
// Declare the guard variable just before the "if", initialized to true.
|
||||
auto* guard_var = create<ast::Variable>(
|
||||
guard_name, ast::StorageClass::kFunction, parser_impl_.Bool());
|
||||
auto* guard_var = create<ast::Variable>(Source{}, guard_name,
|
||||
ast::StorageClass::kFunction,
|
||||
parser_impl_.Bool());
|
||||
guard_var->set_constructor(MakeTrue());
|
||||
auto* guard_decl = create<ast::VariableDeclStatement>(guard_var);
|
||||
AddStatement(guard_decl);
|
||||
|
@ -2637,9 +2638,9 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info,
|
|||
assert(def_inst);
|
||||
const auto phi_var_name = GetDefInfo(id)->phi_var;
|
||||
assert(!phi_var_name.empty());
|
||||
auto* var =
|
||||
create<ast::Variable>(phi_var_name, ast::StorageClass::kFunction,
|
||||
parser_impl_.ConvertType(def_inst->type_id()));
|
||||
auto* var = create<ast::Variable>(
|
||||
Source{}, phi_var_name, ast::StorageClass::kFunction,
|
||||
parser_impl_.ConvertType(def_inst->type_id()));
|
||||
AddStatement(create<ast::VariableDeclStatement>(var));
|
||||
}
|
||||
|
||||
|
|
|
@ -1171,7 +1171,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id,
|
|||
type = ast_module_.create<ast::type::AccessControl>(access, type);
|
||||
}
|
||||
|
||||
auto* ast_var = create<ast::Variable>(namer_.Name(id), sc, type);
|
||||
auto* ast_var = create<ast::Variable>(Source{}, namer_.Name(id), sc, type);
|
||||
|
||||
ast::VariableDecorationList ast_decorations;
|
||||
for (auto& deco : GetDecorationsFor(id)) {
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_F(ScopeStackTest, Global) {
|
|||
|
||||
TEST_F(ScopeStackTest, Global_SetWithPointer) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("test", ast::StorageClass::kNone, &f32);
|
||||
ast::Variable v(Source{}, "test", ast::StorageClass::kNone, &f32);
|
||||
v.set_name("my_var");
|
||||
|
||||
ScopeStack<ast::Variable*> s;
|
||||
|
|
|
@ -52,7 +52,7 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) {
|
|||
// Declare the pointsize builtin output variable.
|
||||
auto* pointsize_var =
|
||||
mod->create<ast::DecoratedVariable>(mod->create<ast::Variable>(
|
||||
kPointSizeVar, ast::StorageClass::kOutput, f32));
|
||||
Source{}, kPointSizeVar, ast::StorageClass::kOutput, f32));
|
||||
pointsize_var->set_decorations({
|
||||
mod->create<ast::BuiltinDecoration>(ast::Builtin::kPointSize, Source{}),
|
||||
});
|
||||
|
|
|
@ -159,7 +159,7 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() {
|
|||
vertex_index_name = kDefaultVertexIndexName;
|
||||
|
||||
auto* var = mod->create<ast::DecoratedVariable>(mod->create<ast::Variable>(
|
||||
vertex_index_name, ast::StorageClass::kInput, GetI32Type()));
|
||||
Source{}, vertex_index_name, ast::StorageClass::kInput, GetI32Type()));
|
||||
|
||||
ast::VariableDecorationList decorations;
|
||||
decorations.push_back(
|
||||
|
@ -203,7 +203,7 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() {
|
|||
instance_index_name = kDefaultInstanceIndexName;
|
||||
|
||||
auto* var = mod->create<ast::DecoratedVariable>(mod->create<ast::Variable>(
|
||||
instance_index_name, ast::StorageClass::kInput, GetI32Type()));
|
||||
Source{}, instance_index_name, ast::StorageClass::kInput, GetI32Type()));
|
||||
|
||||
ast::VariableDecorationList decorations;
|
||||
decorations.push_back(mod->create<ast::BuiltinDecoration>(
|
||||
|
@ -226,8 +226,8 @@ void VertexPulling::State::ConvertVertexInputVariablesToPrivate() {
|
|||
// This is where the replacement happens. Expressions use identifier
|
||||
// strings instead of pointers, so we don't need to update any other
|
||||
// place in the AST.
|
||||
v = mod->create<ast::Variable>(v->name(), ast::StorageClass::kPrivate,
|
||||
v->type());
|
||||
v = mod->create<ast::Variable>(
|
||||
Source{}, v->name(), ast::StorageClass::kPrivate, v->type());
|
||||
location_to_var[location] = v;
|
||||
break;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ void VertexPulling::State::AddVertexStorageBuffers() {
|
|||
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
||||
// The decorated variable with struct type
|
||||
auto* var = mod->create<ast::DecoratedVariable>(mod->create<ast::Variable>(
|
||||
GetVertexBufferName(i), ast::StorageClass::kStorageBuffer,
|
||||
Source{}, GetVertexBufferName(i), ast::StorageClass::kStorageBuffer,
|
||||
struct_type));
|
||||
|
||||
// Add decorations
|
||||
|
@ -289,9 +289,9 @@ void VertexPulling::State::AddVertexPullingPreamble(
|
|||
auto* block = mod->create<ast::BlockStatement>();
|
||||
|
||||
// Declare the |kPullingPosVarName| variable in the shader
|
||||
auto* pos_declaration =
|
||||
mod->create<ast::VariableDeclStatement>(mod->create<ast::Variable>(
|
||||
kPullingPosVarName, ast::StorageClass::kFunction, GetI32Type()));
|
||||
auto* pos_declaration = mod->create<ast::VariableDeclStatement>(
|
||||
mod->create<ast::Variable>(Source{}, kPullingPosVarName,
|
||||
ast::StorageClass::kFunction, GetI32Type()));
|
||||
|
||||
// |kPullingPosVarName| refers to the byte location of the current read. We
|
||||
// declare a variable in the shader to avoid having to reuse Expression
|
||||
|
|
|
@ -70,7 +70,7 @@ class VertexPullingHelper {
|
|||
std::string name,
|
||||
ast::type::Type* type) {
|
||||
auto* var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>(name, ast::StorageClass::kInput, type));
|
||||
create<ast::Variable>(Source{}, name, ast::StorageClass::kInput, type));
|
||||
|
||||
ast::VariableDecorationList decorations;
|
||||
decorations.push_back(create<ast::LocationDecoration>(location, Source{}));
|
||||
|
@ -419,7 +419,7 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) {
|
|||
{
|
||||
auto* vertex_index_var =
|
||||
create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"custom_vertex_index", ast::StorageClass::kInput, &i32));
|
||||
Source{}, "custom_vertex_index", ast::StorageClass::kInput, &i32));
|
||||
|
||||
ast::VariableDecorationList decorations;
|
||||
decorations.push_back(
|
||||
|
@ -430,9 +430,9 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) {
|
|||
}
|
||||
|
||||
{
|
||||
auto* instance_index_var =
|
||||
create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"custom_instance_index", ast::StorageClass::kInput, &i32));
|
||||
auto* instance_index_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>(Source{}, "custom_instance_index",
|
||||
ast::StorageClass::kInput, &i32));
|
||||
|
||||
ast::VariableDecorationList decorations;
|
||||
decorations.push_back(
|
||||
|
|
|
@ -389,7 +389,8 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Stmt_VariableDecl) {
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
auto* init = var->constructor();
|
||||
|
@ -403,7 +404,8 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) {
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
auto* init = var->constructor();
|
||||
|
@ -430,8 +432,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) {
|
|||
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
auto* var =
|
||||
create<ast::Variable>("my_var", ast::StorageClass::kFunction, &ary);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_var",
|
||||
ast::StorageClass::kFunction, &ary);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -455,8 +457,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) {
|
|||
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
auto* var =
|
||||
create<ast::Variable>("my_var", ast::StorageClass::kFunction, &aary);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_var",
|
||||
ast::StorageClass::kFunction, &aary);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -479,8 +481,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) {
|
|||
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
auto* var =
|
||||
create<ast::Variable>("my_var", ast::StorageClass::kFunction, &ary);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_var",
|
||||
ast::StorageClass::kFunction, &ary);
|
||||
var->set_is_const(true);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
|
@ -502,7 +504,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) {
|
|||
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &mat);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &mat);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -528,7 +531,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) {
|
|||
create<ast::SintLiteral>(&i32, 2));
|
||||
auto* idx2 = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1));
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &mat);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &mat);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -554,7 +558,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) {
|
|||
|
||||
auto* idx = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &vec);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -575,7 +580,7 @@ TEST_F(TypeDeterminerTest, Expr_Bitcast) {
|
|||
ast::BitcastExpression bitcast(&f32,
|
||||
create<ast::IdentifierExpression>("name"));
|
||||
|
||||
ast::Variable v("name", ast::StorageClass::kPrivate, &f32);
|
||||
ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32);
|
||||
td()->RegisterVariableForTesting(&v);
|
||||
|
||||
EXPECT_TRUE(td()->DetermineResultType(&bitcast));
|
||||
|
@ -653,7 +658,7 @@ TEST_F(TypeDeterminerTest, Expr_Cast) {
|
|||
params.push_back(create<ast::IdentifierExpression>("name"));
|
||||
ast::TypeConstructorExpression cast(&f32, params);
|
||||
|
||||
ast::Variable v("name", ast::StorageClass::kPrivate, &f32);
|
||||
ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32);
|
||||
td()->RegisterVariableForTesting(&v);
|
||||
|
||||
EXPECT_TRUE(td()->DetermineResultType(&cast));
|
||||
|
@ -694,7 +699,8 @@ TEST_F(TypeDeterminerTest, Expr_Constructor_Type) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &f32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -712,7 +718,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &f32);
|
||||
var->set_is_const(true);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
|
@ -730,7 +737,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) {
|
|||
|
||||
auto* my_var = create<ast::IdentifierExpression>("my_var");
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &f32);
|
||||
var->set_is_const(true);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
@ -753,8 +761,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) {
|
|||
auto* my_var = create<ast::IdentifierExpression>("my_var");
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32)));
|
||||
body->append(create<ast::VariableDeclStatement>(create<ast::Variable>(
|
||||
Source{}, "my_var", ast::StorageClass::kNone, &f32)));
|
||||
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
my_var, create<ast::IdentifierExpression>("my_var")));
|
||||
|
@ -779,8 +787,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) {
|
|||
auto* my_var = create<ast::IdentifierExpression>("my_var");
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
create<ast::Variable>("my_var", ast::StorageClass::kNone, &ptr)));
|
||||
body->append(create<ast::VariableDeclStatement>(create<ast::Variable>(
|
||||
Source{}, "my_var", ast::StorageClass::kNone, &ptr)));
|
||||
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
my_var, create<ast::IdentifierExpression>("my_var")));
|
||||
|
@ -824,16 +832,16 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) {
|
|||
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* in_var =
|
||||
create<ast::Variable>("in_var", ast::StorageClass::kInput, &f32);
|
||||
auto* out_var =
|
||||
create<ast::Variable>("out_var", ast::StorageClass::kOutput, &f32);
|
||||
auto* sb_var =
|
||||
create<ast::Variable>("sb_var", ast::StorageClass::kStorageBuffer, &f32);
|
||||
auto* wg_var =
|
||||
create<ast::Variable>("wg_var", ast::StorageClass::kWorkgroup, &f32);
|
||||
auto* priv_var =
|
||||
create<ast::Variable>("priv_var", ast::StorageClass::kPrivate, &f32);
|
||||
auto* in_var = create<ast::Variable>(Source{}, "in_var",
|
||||
ast::StorageClass::kInput, &f32);
|
||||
auto* out_var = create<ast::Variable>(Source{}, "out_var",
|
||||
ast::StorageClass::kOutput, &f32);
|
||||
auto* sb_var = create<ast::Variable>(Source{}, "sb_var",
|
||||
ast::StorageClass::kStorageBuffer, &f32);
|
||||
auto* wg_var = create<ast::Variable>(Source{}, "wg_var",
|
||||
ast::StorageClass::kWorkgroup, &f32);
|
||||
auto* priv_var = create<ast::Variable>(Source{}, "priv_var",
|
||||
ast::StorageClass::kPrivate, &f32);
|
||||
|
||||
mod->AddGlobalVariable(in_var);
|
||||
mod->AddGlobalVariable(out_var);
|
||||
|
@ -875,16 +883,16 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
|
|||
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* in_var =
|
||||
create<ast::Variable>("in_var", ast::StorageClass::kInput, &f32);
|
||||
auto* out_var =
|
||||
create<ast::Variable>("out_var", ast::StorageClass::kOutput, &f32);
|
||||
auto* sb_var =
|
||||
create<ast::Variable>("sb_var", ast::StorageClass::kStorageBuffer, &f32);
|
||||
auto* wg_var =
|
||||
create<ast::Variable>("wg_var", ast::StorageClass::kWorkgroup, &f32);
|
||||
auto* priv_var =
|
||||
create<ast::Variable>("priv_var", ast::StorageClass::kPrivate, &f32);
|
||||
auto* in_var = create<ast::Variable>(Source{}, "in_var",
|
||||
ast::StorageClass::kInput, &f32);
|
||||
auto* out_var = create<ast::Variable>(Source{}, "out_var",
|
||||
ast::StorageClass::kOutput, &f32);
|
||||
auto* sb_var = create<ast::Variable>(Source{}, "sb_var",
|
||||
ast::StorageClass::kStorageBuffer, &f32);
|
||||
auto* wg_var = create<ast::Variable>(Source{}, "wg_var",
|
||||
ast::StorageClass::kWorkgroup, &f32);
|
||||
auto* priv_var = create<ast::Variable>(Source{}, "priv_var",
|
||||
ast::StorageClass::kPrivate, &f32);
|
||||
|
||||
mod->AddGlobalVariable(in_var);
|
||||
mod->AddGlobalVariable(out_var);
|
||||
|
@ -936,8 +944,8 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
|
|||
TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>("in_var", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "in_var",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
@ -952,7 +960,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) {
|
|||
|
||||
mod->AddFunction(func);
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kFunction, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kFunction, &f32);
|
||||
td()->RegisterVariableForTesting(&v);
|
||||
|
||||
// Register the function
|
||||
|
@ -974,7 +982,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) {
|
|||
|
||||
ast::type::Struct st("S", strct);
|
||||
|
||||
auto* var = create<ast::Variable>("my_struct", ast::StorageClass::kNone, &st);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_struct",
|
||||
ast::StorageClass::kNone, &st);
|
||||
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
|
@ -1007,8 +1016,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) {
|
|||
auto st = std::make_unique<ast::type::Struct>("alias", strct);
|
||||
ast::type::Alias alias("alias", st.get());
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>("my_struct", ast::StorageClass::kNone, &alias);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_struct",
|
||||
ast::StorageClass::kNone, &alias);
|
||||
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
|
@ -1031,7 +1040,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("my_vec", ast::StorageClass::kNone, &vec3);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_vec",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1053,7 +1063,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("my_vec", ast::StorageClass::kNone, &vec3);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_vec",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1117,7 +1128,8 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) {
|
|||
|
||||
ast::type::Struct stA("A", strctA);
|
||||
|
||||
auto* var = create<ast::Variable>("c", ast::StorageClass::kNone, &stA);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "c", ast::StorageClass::kNone, &stA);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1151,7 +1163,8 @@ TEST_P(Expr_Binary_BitwiseTest, Scalar) {
|
|||
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kNone, &i32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1171,7 +1184,8 @@ TEST_P(Expr_Binary_BitwiseTest, Vector) {
|
|||
ast::type::I32 i32;
|
||||
ast::type::Vector vec3(&i32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &vec3);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1207,8 +1221,8 @@ TEST_P(Expr_Binary_LogicalTest, Scalar) {
|
|||
|
||||
ast::type::Bool bool_type;
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>("val", ast::StorageClass::kNone, &bool_type);
|
||||
auto* var = create<ast::Variable>(Source{}, "val", ast::StorageClass::kNone,
|
||||
&bool_type);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1228,7 +1242,8 @@ TEST_P(Expr_Binary_LogicalTest, Vector) {
|
|||
ast::type::Bool bool_type;
|
||||
ast::type::Vector vec3(&bool_type, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &vec3);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1257,7 +1272,8 @@ TEST_P(Expr_Binary_CompareTest, Scalar) {
|
|||
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kNone, &i32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1277,7 +1293,8 @@ TEST_P(Expr_Binary_CompareTest, Vector) {
|
|||
ast::type::I32 i32;
|
||||
ast::type::Vector vec3(&i32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &vec3);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1307,7 +1324,8 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
|||
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("val", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kNone, &i32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1327,9 +1345,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* scalar =
|
||||
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* vector =
|
||||
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
|
||||
create<ast::Variable>(Source{}, "scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* vector = create<ast::Variable>(Source{}, "vector",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(scalar);
|
||||
mod->AddGlobalVariable(vector);
|
||||
|
||||
|
@ -1355,9 +1373,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* scalar =
|
||||
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* vector =
|
||||
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
|
||||
create<ast::Variable>(Source{}, "scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* vector = create<ast::Variable>(Source{}, "vector",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(scalar);
|
||||
mod->AddGlobalVariable(vector);
|
||||
|
||||
|
@ -1382,8 +1400,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* vector =
|
||||
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
|
||||
auto* vector = create<ast::Variable>(Source{}, "vector",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(vector);
|
||||
|
||||
// Register the global
|
||||
|
@ -1408,9 +1426,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) {
|
|||
ast::type::Matrix mat3x2(&f32, 3, 2);
|
||||
|
||||
auto* scalar =
|
||||
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* matrix =
|
||||
create<ast::Variable>("matrix", ast::StorageClass::kNone, &mat3x2);
|
||||
create<ast::Variable>(Source{}, "scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* matrix = create<ast::Variable>(Source{}, "matrix",
|
||||
ast::StorageClass::kNone, &mat3x2);
|
||||
mod->AddGlobalVariable(scalar);
|
||||
mod->AddGlobalVariable(matrix);
|
||||
|
||||
|
@ -1436,9 +1454,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) {
|
|||
ast::type::Matrix mat3x2(&f32, 3, 2);
|
||||
|
||||
auto* scalar =
|
||||
create<ast::Variable>("scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* matrix =
|
||||
create<ast::Variable>("matrix", ast::StorageClass::kNone, &mat3x2);
|
||||
create<ast::Variable>(Source{}, "scalar", ast::StorageClass::kNone, &f32);
|
||||
auto* matrix = create<ast::Variable>(Source{}, "matrix",
|
||||
ast::StorageClass::kNone, &mat3x2);
|
||||
mod->AddGlobalVariable(scalar);
|
||||
mod->AddGlobalVariable(matrix);
|
||||
|
||||
|
@ -1464,10 +1482,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) {
|
|||
ast::type::Vector vec3(&f32, 2);
|
||||
ast::type::Matrix mat3x2(&f32, 3, 2);
|
||||
|
||||
auto* vector =
|
||||
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
|
||||
auto* matrix =
|
||||
create<ast::Variable>("matrix", ast::StorageClass::kNone, &mat3x2);
|
||||
auto* vector = create<ast::Variable>(Source{}, "vector",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
auto* matrix = create<ast::Variable>(Source{}, "matrix",
|
||||
ast::StorageClass::kNone, &mat3x2);
|
||||
mod->AddGlobalVariable(vector);
|
||||
mod->AddGlobalVariable(matrix);
|
||||
|
||||
|
@ -1493,10 +1511,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Matrix mat3x2(&f32, 3, 2);
|
||||
|
||||
auto* vector =
|
||||
create<ast::Variable>("vector", ast::StorageClass::kNone, &vec3);
|
||||
auto* matrix =
|
||||
create<ast::Variable>("matrix", ast::StorageClass::kNone, &mat3x2);
|
||||
auto* vector = create<ast::Variable>(Source{}, "vector",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
auto* matrix = create<ast::Variable>(Source{}, "matrix",
|
||||
ast::StorageClass::kNone, &mat3x2);
|
||||
mod->AddGlobalVariable(vector);
|
||||
mod->AddGlobalVariable(matrix);
|
||||
|
||||
|
@ -1522,10 +1540,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) {
|
|||
ast::type::Matrix mat4x3(&f32, 4, 3);
|
||||
ast::type::Matrix mat3x4(&f32, 3, 4);
|
||||
|
||||
auto* matrix1 =
|
||||
create<ast::Variable>("mat4x3", ast::StorageClass::kNone, &mat4x3);
|
||||
auto* matrix2 =
|
||||
create<ast::Variable>("mat3x4", ast::StorageClass::kNone, &mat3x4);
|
||||
auto* matrix1 = create<ast::Variable>(Source{}, "mat4x3",
|
||||
ast::StorageClass::kNone, &mat4x3);
|
||||
auto* matrix2 = create<ast::Variable>(Source{}, "mat3x4",
|
||||
ast::StorageClass::kNone, &mat3x4);
|
||||
mod->AddGlobalVariable(matrix1);
|
||||
mod->AddGlobalVariable(matrix2);
|
||||
|
||||
|
@ -1552,7 +1570,8 @@ TEST_P(IntrinsicDerivativeTest, Scalar) {
|
|||
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var = create<ast::Variable>("ident", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "ident", ast::StorageClass::kNone, &f32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1575,7 +1594,8 @@ TEST_P(IntrinsicDerivativeTest, Vector) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* var = create<ast::Variable>("ident", ast::StorageClass::kNone, &vec4);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "ident", ast::StorageClass::kNone, &vec4);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -1619,8 +1639,10 @@ TEST_P(IntrinsicDerivativeTest, ToomManyParams) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* var1 = create<ast::Variable>("ident1", ast::StorageClass::kNone, &vec4);
|
||||
auto* var2 = create<ast::Variable>("ident2", ast::StorageClass::kNone, &vec4);
|
||||
auto* var1 = create<ast::Variable>(Source{}, "ident1",
|
||||
ast::StorageClass::kNone, &vec4);
|
||||
auto* var2 = create<ast::Variable>(Source{}, "ident2",
|
||||
ast::StorageClass::kNone, &vec4);
|
||||
mod->AddGlobalVariable(var1);
|
||||
mod->AddGlobalVariable(var2);
|
||||
|
||||
|
@ -1655,7 +1677,8 @@ TEST_P(Intrinsic, Test) {
|
|||
ast::type::Bool bool_type;
|
||||
ast::type::Vector vec3(&bool_type, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_var",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -1682,7 +1705,8 @@ TEST_P(Intrinsic_FloatMethod, Vector) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_var",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -1709,7 +1733,8 @@ TEST_P(Intrinsic_FloatMethod, Scalar) {
|
|||
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &f32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -1730,7 +1755,8 @@ TEST_P(Intrinsic_FloatMethod, MissingParam) {
|
|||
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &f32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -1748,7 +1774,8 @@ TEST_P(Intrinsic_FloatMethod, TooManyParams) {
|
|||
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "my_var", ast::StorageClass::kNone, &f32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -1817,7 +1844,8 @@ class Intrinsic_TextureOperation
|
|||
void add_call_param(std::string name,
|
||||
ast::type::Type* type,
|
||||
ast::ExpressionList* call_params) {
|
||||
auto* var = create<ast::Variable>(name, ast::StorageClass::kNone, type);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, name, ast::StorageClass::kNone, type);
|
||||
mod->AddGlobalVariable(var);
|
||||
call_params->push_back(create<ast::IdentifierExpression>(name));
|
||||
}
|
||||
|
@ -1969,7 +1997,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Dot) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_var",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -1992,9 +2021,10 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Vector bool_vec3(&bool_type, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("my_var", ast::StorageClass::kNone, &vec3);
|
||||
auto* bool_var =
|
||||
create<ast::Variable>("bool_var", ast::StorageClass::kNone, &bool_vec3);
|
||||
auto* var = create<ast::Variable>(Source{}, "my_var",
|
||||
ast::StorageClass::kNone, &vec3);
|
||||
auto* bool_var = create<ast::Variable>(Source{}, "bool_var",
|
||||
ast::StorageClass::kNone, &bool_vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
mod->AddGlobalVariable(bool_var);
|
||||
|
||||
|
@ -2022,7 +2052,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kNone, &vec3);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -2042,7 +2073,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooManyParams) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kNone, &vec3);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kNone, &vec3);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -2066,8 +2098,10 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Vector vec2(&f32, 2);
|
||||
|
||||
auto* var1 = create<ast::Variable>("v3", ast::StorageClass::kNone, &vec3);
|
||||
auto* var2 = create<ast::Variable>("v2", ast::StorageClass::kNone, &vec2);
|
||||
auto* var1 =
|
||||
create<ast::Variable>(Source{}, "v3", ast::StorageClass::kNone, &vec3);
|
||||
auto* var2 =
|
||||
create<ast::Variable>(Source{}, "v2", ast::StorageClass::kNone, &vec2);
|
||||
mod->AddGlobalVariable(var1);
|
||||
mod->AddGlobalVariable(var2);
|
||||
|
||||
|
@ -2096,7 +2130,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooFewParams) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Vector vec2(&f32, 2);
|
||||
|
||||
auto* var2 = create<ast::Variable>("v2", ast::StorageClass::kNone, &vec2);
|
||||
auto* var2 =
|
||||
create<ast::Variable>(Source{}, "v2", ast::StorageClass::kNone, &vec2);
|
||||
mod->AddGlobalVariable(var2);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -2116,7 +2151,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooManyParams) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Vector vec2(&f32, 2);
|
||||
|
||||
auto* var2 = create<ast::Variable>("v2", ast::StorageClass::kNone, &vec2);
|
||||
auto* var2 =
|
||||
create<ast::Variable>(Source{}, "v2", ast::StorageClass::kNone, &vec2);
|
||||
mod->AddGlobalVariable(var2);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
@ -2141,7 +2177,8 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) {
|
|||
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* var = create<ast::Variable>("ident", ast::StorageClass::kNone, &vec4);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "ident", ast::StorageClass::kNone, &vec4);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -2163,7 +2200,8 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
|||
TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kNone, &i32);
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
@ -2180,7 +2218,8 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) {
|
|||
TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kNone, &i32);
|
||||
var->set_is_const(true);
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
@ -2198,7 +2237,8 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) {
|
|||
TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kWorkgroup, &i32);
|
||||
auto* var = create<ast::Variable>(Source{}, "var",
|
||||
ast::StorageClass::kWorkgroup, &i32);
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
@ -4255,7 +4295,8 @@ TEST_F(TypeDeterminerTest, ImportData_GLSL_Determinant) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
|
||||
auto* var = create<ast::Variable>(Source{}, "var",
|
||||
ast::StorageClass::kFunction, &mat);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -4280,7 +4321,8 @@ TEST_P(ImportData_Matrix_OneParam_Test, Error_Float) {
|
|||
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "var",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -4316,7 +4358,8 @@ TEST_P(ImportData_Matrix_OneParam_Test, TooManyParams) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
|
||||
auto* var = create<ast::Variable>(Source{}, "var",
|
||||
ast::StorageClass::kFunction, &mat);
|
||||
mod->AddGlobalVariable(var);
|
||||
|
||||
// Register the global
|
||||
|
@ -4406,16 +4449,16 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) {
|
|||
mod->AddFunction(ep_1);
|
||||
mod->AddFunction(ep_2);
|
||||
|
||||
mod->AddGlobalVariable(
|
||||
create<ast::Variable>("first", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(
|
||||
create<ast::Variable>("second", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(
|
||||
create<ast::Variable>("call_a", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(
|
||||
create<ast::Variable>("call_b", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(
|
||||
create<ast::Variable>("call_c", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(create<ast::Variable>(
|
||||
Source{}, "first", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(create<ast::Variable>(
|
||||
Source{}, "second", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(create<ast::Variable>(
|
||||
Source{}, "call_a", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(create<ast::Variable>(
|
||||
Source{}, "call_b", ast::StorageClass::kPrivate, &f32));
|
||||
mod->AddGlobalVariable(create<ast::Variable>(
|
||||
Source{}, "call_c", ast::StorageClass::kPrivate, &f32));
|
||||
|
||||
// Register the functions and calculate the callers
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
|
|
@ -43,7 +43,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
|||
// default: {}
|
||||
// }
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&f32, 3.14f)));
|
||||
|
||||
|
@ -71,7 +72,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
|
|||
// case 1: {}
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -102,7 +104,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
|||
// default: {}
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -145,7 +148,8 @@ TEST_F(ValidateControlBlockTest,
|
|||
// }
|
||||
ast::type::U32 u32;
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -181,7 +185,8 @@ TEST_F(ValidateControlBlockTest,
|
|||
// }
|
||||
ast::type::U32 u32;
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &u32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &u32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 2)));
|
||||
|
||||
|
@ -216,7 +221,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
|||
// default: {}
|
||||
// }
|
||||
ast::type::U32 u32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &u32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &u32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 3)));
|
||||
|
||||
|
@ -257,7 +263,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
|
|||
// default: {}
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -298,7 +305,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
|
|||
// default: { fallthrough; }
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -328,7 +336,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
|||
// case 5: {}
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -361,7 +370,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
|||
ast::type::U32 u32;
|
||||
ast::type::Alias my_int{"MyInt", &u32};
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &my_int);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &my_int);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&u32, 2)));
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
|||
// [[stage(vertex)]]
|
||||
// fn func -> void { var a:i32 = 2; }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -80,7 +81,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
|||
// fn func -> int { var a:i32 = 2; }
|
||||
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -237,7 +239,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
|
|||
TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
||||
// fn func() -> i32 {var a: i32 = func(); return 2; }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}},
|
||||
|
@ -288,7 +291,8 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
|
|||
ast::type::I32 i32;
|
||||
ast::type::Void void_type;
|
||||
ast::VariableList params;
|
||||
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>());
|
||||
auto* func = create<ast::Function>(
|
||||
|
|
|
@ -115,7 +115,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
|
|||
// var a :i32 = 2;
|
||||
// a = 2
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -139,7 +140,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
|
@ -165,7 +167,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
|||
// a = 2
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
|
@ -193,7 +196,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
|
@ -274,8 +278,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
|||
// not_global_var = 3.14f;
|
||||
// }
|
||||
ast::type::F32 f32;
|
||||
auto* global_var =
|
||||
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
|
||||
auto* global_var = create<ast::Variable>(Source{}, "global_var",
|
||||
ast::StorageClass::kPrivate, &f32);
|
||||
global_var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)));
|
||||
mod()->AddGlobalVariable(global_var);
|
||||
|
@ -307,8 +311,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Void void_type;
|
||||
|
||||
auto* global_var =
|
||||
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
|
||||
auto* global_var = create<ast::Variable>(Source{}, "global_var",
|
||||
ast::StorageClass::kPrivate, &f32);
|
||||
global_var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)));
|
||||
mod()->AddGlobalVariable(global_var);
|
||||
|
@ -340,7 +344,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
|||
// a = 3.14;
|
||||
// }
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)));
|
||||
|
||||
|
@ -374,7 +379,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
|||
// if (true) { a = 3.14; }
|
||||
// }
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)));
|
||||
|
||||
|
@ -405,8 +411,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
|||
// var global_var1 : i32 = 0;
|
||||
ast::type::F32 f32;
|
||||
ast::type::I32 i32;
|
||||
auto* var0 =
|
||||
create<ast::Variable>("global_var0", ast::StorageClass::kPrivate, &f32);
|
||||
auto* var0 = create<ast::Variable>(Source{}, "global_var0",
|
||||
ast::StorageClass::kPrivate, &f32);
|
||||
var0->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)));
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
@ -427,8 +433,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
|||
// var global_var : i32 = 0;
|
||||
ast::type::F32 f32;
|
||||
ast::type::I32 i32;
|
||||
auto* var0 =
|
||||
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
|
||||
auto* var0 = create<ast::Variable>(Source{}, "global_var",
|
||||
ast::StorageClass::kPrivate, &f32);
|
||||
var0->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)));
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
@ -451,7 +457,8 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
|||
// a = 2
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
var->set_is_const(true);
|
||||
|
@ -483,12 +490,13 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
|||
ast::type::Void void_type;
|
||||
ast::type::F32 f32;
|
||||
auto* global_var =
|
||||
create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &f32);
|
||||
global_var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)));
|
||||
mod()->AddGlobalVariable(global_var);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)));
|
||||
ast::VariableList params;
|
||||
|
@ -514,12 +522,13 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
|||
ast::type::Void void_type;
|
||||
ast::type::I32 i32;
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
|
||||
auto* var_a_float =
|
||||
create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var_a_float->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)));
|
||||
|
||||
|
@ -545,7 +554,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
|||
// var a : f32 = 3.14;
|
||||
// }
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)));
|
||||
|
||||
|
@ -556,7 +566,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
|||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
auto* var_a_float =
|
||||
create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var_a_float->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)));
|
||||
|
||||
|
@ -579,11 +589,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
|||
// }
|
||||
ast::type::F32 f32;
|
||||
auto* var_a_float =
|
||||
create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var_a_float->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)));
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)));
|
||||
|
||||
|
@ -609,11 +620,13 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
|||
// func1 { var a : f32 = 3.0; return; }
|
||||
ast::type::F32 f32;
|
||||
ast::type::Void void_type;
|
||||
auto* var0 = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var0 =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var0->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)));
|
||||
|
||||
auto* var1 = create<ast::Variable>("a", ast::StorageClass::kNone, &void_type);
|
||||
auto* var1 = create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone,
|
||||
&void_type);
|
||||
var1->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0)));
|
||||
|
||||
|
@ -649,7 +662,8 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
|||
// a = 2;
|
||||
// }
|
||||
ast::type::I32 i32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32);
|
||||
|
||||
td()->RegisterVariableForTesting(var);
|
||||
auto* lhs = create<ast::IdentifierExpression>("a");
|
||||
|
|
|
@ -193,7 +193,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
|
|||
ast::type::I32 i32;
|
||||
ast::type::Array array(&i32);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &array);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &array);
|
||||
ast::VariableList params;
|
||||
ast::type::Void void_type;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
|
|
@ -62,10 +62,10 @@ TEST_P(HlslBinaryTest, Emit_f32) {
|
|||
|
||||
auto params = GetParam();
|
||||
|
||||
auto* left_var =
|
||||
create<ast::Variable>("left", ast::StorageClass::kFunction, &f32);
|
||||
auto* right_var =
|
||||
create<ast::Variable>("right", ast::StorageClass::kFunction, &f32);
|
||||
auto* left_var = create<ast::Variable>(Source{}, "left",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
auto* right_var = create<ast::Variable>(Source{}, "right",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
|
||||
auto* left = create<ast::IdentifierExpression>("left");
|
||||
auto* right = create<ast::IdentifierExpression>("right");
|
||||
|
@ -84,10 +84,10 @@ TEST_P(HlslBinaryTest, Emit_u32) {
|
|||
|
||||
auto params = GetParam();
|
||||
|
||||
auto* left_var =
|
||||
create<ast::Variable>("left", ast::StorageClass::kFunction, &u32);
|
||||
auto* right_var =
|
||||
create<ast::Variable>("right", ast::StorageClass::kFunction, &u32);
|
||||
auto* left_var = create<ast::Variable>(Source{}, "left",
|
||||
ast::StorageClass::kFunction, &u32);
|
||||
auto* right_var = create<ast::Variable>(Source{}, "right",
|
||||
ast::StorageClass::kFunction, &u32);
|
||||
|
||||
auto* left = create<ast::IdentifierExpression>("left");
|
||||
auto* right = create<ast::IdentifierExpression>("right");
|
||||
|
@ -106,10 +106,10 @@ TEST_P(HlslBinaryTest, Emit_i32) {
|
|||
|
||||
auto params = GetParam();
|
||||
|
||||
auto* left_var =
|
||||
create<ast::Variable>("left", ast::StorageClass::kFunction, &i32);
|
||||
auto* right_var =
|
||||
create<ast::Variable>("right", ast::StorageClass::kFunction, &i32);
|
||||
auto* left_var = create<ast::Variable>(Source{}, "left",
|
||||
ast::StorageClass::kFunction, &i32);
|
||||
auto* right_var = create<ast::Variable>(Source{}, "right",
|
||||
ast::StorageClass::kFunction, &i32);
|
||||
|
||||
auto* left = create<ast::IdentifierExpression>("left");
|
||||
auto* right = create<ast::IdentifierExpression>("right");
|
||||
|
@ -199,7 +199,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::IdentifierExpression>("mat");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
|
@ -217,7 +218,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
auto* rhs = create<ast::IdentifierExpression>("mat");
|
||||
|
@ -236,7 +238,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::IdentifierExpression>("mat");
|
||||
|
||||
ast::ExpressionList vals;
|
||||
|
@ -262,7 +265,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
|
@ -289,7 +293,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::IdentifierExpression>("mat");
|
||||
auto* rhs = create<ast::IdentifierExpression>("mat");
|
||||
|
||||
|
@ -482,8 +487,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) {
|
|||
auto* c = create<ast::IdentifierExpression>("c");
|
||||
auto* d = create<ast::IdentifierExpression>("d");
|
||||
|
||||
auto* var =
|
||||
create<ast::Variable>("a", ast::StorageClass::kFunction, &bool_type);
|
||||
auto* var = create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction,
|
||||
&bool_type);
|
||||
var->set_constructor(create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLogicalOr,
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, b, c), d));
|
||||
|
|
|
@ -53,11 +53,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kInput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kInput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -109,11 +109,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kOutput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -166,11 +166,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kInput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kInput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -223,11 +223,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kOutput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -276,14 +276,14 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::LocationDecoration>(0, Source{}));
|
||||
foo_var->set_decorations(decos);
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kInput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kInput, &i32));
|
||||
decos.push_back(create<ast::LocationDecoration>(1, Source{}));
|
||||
bar_var->set_decorations(decos);
|
||||
|
||||
|
@ -328,14 +328,14 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kOutput, &f32));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::LocationDecoration>(0, Source{}));
|
||||
foo_var->set_decorations(decos);
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &i32));
|
||||
decos.push_back(create<ast::LocationDecoration>(1, Source{}));
|
||||
bar_var->set_decorations(decos);
|
||||
|
||||
|
@ -386,13 +386,13 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
ast::type::Void void_type;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kInput, &vec4));
|
||||
coord_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord, Source{})});
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
depth_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
|
|
@ -98,8 +98,10 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &f32));
|
||||
params.push_back(create<ast::Variable>("b", ast::StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kNone, &i32));
|
||||
|
||||
ast::type::Void void_type;
|
||||
|
||||
|
@ -125,11 +127,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &f32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -177,14 +179,14 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kInput, &vec4));
|
||||
|
||||
coord_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord, Source{})});
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
depth_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
@ -235,8 +237,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kUniform, &vec4));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -247,7 +249,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("coord"),
|
||||
create<ast::IdentifierExpression>("x")));
|
||||
|
@ -291,8 +294,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
ast::type::Struct s("Uniforms", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("uniforms", ast::StorageClass::kUniform, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "uniforms", ast::StorageClass::kUniform, &s));
|
||||
|
||||
mod.AddConstructedType(&s);
|
||||
|
||||
|
@ -305,7 +308,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("uniforms"),
|
||||
|
@ -359,8 +363,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::Struct s("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -371,7 +375,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("coord"),
|
||||
create<ast::IdentifierExpression>("b")));
|
||||
|
@ -419,8 +424,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::Struct s("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -431,7 +436,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("coord"),
|
||||
create<ast::IdentifierExpression>("b")));
|
||||
|
@ -479,8 +485,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::Struct s("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -529,15 +535,15 @@ TEST_F(
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &f32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
auto* val_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("val", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kOutput, &f32));
|
||||
val_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -549,8 +555,8 @@ TEST_F(
|
|||
mod.AddGlobalVariable(val_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -616,8 +622,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(
|
||||
|
@ -629,8 +635,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod.AddGlobalVariable(depth_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -684,13 +690,13 @@ TEST_F(
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kInput, &vec4));
|
||||
coord_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord, Source{})});
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
depth_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
@ -701,8 +707,8 @@ TEST_F(
|
|||
mod.AddGlobalVariable(depth_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -765,8 +771,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kUniform, &vec4));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -778,8 +784,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -795,7 +801,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("sub_func"), expr));
|
||||
|
||||
|
@ -834,8 +841,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &vec4);
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -847,8 +854,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -864,7 +871,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("sub_func"), expr));
|
||||
|
||||
|
@ -902,7 +910,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &f32));
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::LocationDecoration>(1, Source{}));
|
||||
bar_var->set_decorations(decos);
|
||||
|
@ -1032,7 +1040,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
|
|||
ast::type::Array ary(&f32, 5);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &ary));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &ary));
|
||||
|
||||
ast::type::Void void_type;
|
||||
|
||||
|
@ -1086,8 +1095,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
ast::type::Struct s("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||
|
||||
auto* data_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* data_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -1100,7 +1109,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
@ -1120,7 +1130,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
|
|
@ -268,7 +268,8 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
|
||||
auto* var = create<ast::Variable>(Source{}, "var",
|
||||
ast::StorageClass::kFunction, &mat);
|
||||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::IdentifierExpression>("var"));
|
||||
|
|
|
@ -75,8 +75,10 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_OuterProduct) {
|
|||
ast::type::Vector vec2(&f32, 2);
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kNone, &vec2);
|
||||
auto* b = create<ast::Variable>("b", ast::StorageClass::kNone, &vec3);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &vec2);
|
||||
auto* b =
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kNone, &vec3);
|
||||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::IdentifierExpression>("a"));
|
||||
|
@ -113,8 +115,8 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) {
|
|||
|
||||
ast::CallExpression call(create<ast::IdentifierExpression>("dot"), params);
|
||||
|
||||
ast::Variable v1("param1", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable v2("param2", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable v2(Source{}, "param2", ast::StorageClass::kFunction, &vec);
|
||||
|
||||
td.RegisterVariableForTesting(&v1);
|
||||
td.RegisterVariableForTesting(&v2);
|
||||
|
|
|
@ -144,14 +144,15 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
|
|||
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var = create<ast::Variable>("lhs", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "lhs",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.4)));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
create<ast::Variable>("other", ast::StorageClass::kFunction, &f32)));
|
||||
body->append(create<ast::VariableDeclStatement>(create<ast::Variable>(
|
||||
Source{}, "other", ast::StorageClass::kFunction, &f32)));
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
|
|
|
@ -58,7 +58,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
|
|||
ast::type::Struct s("Str", strct);
|
||||
|
||||
auto* str_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("str", ast::StorageClass::kPrivate, &s));
|
||||
create<ast::Variable>(Source{}, "str", ast::StorageClass::kPrivate, &s));
|
||||
|
||||
auto* str = create<ast::IdentifierExpression>("str");
|
||||
auto* mem = create<ast::IdentifierExpression>("mem");
|
||||
|
@ -100,8 +100,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("b"));
|
||||
|
@ -143,8 +143,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("a"));
|
||||
|
@ -189,10 +189,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* b_var = create<ast::Variable>("b", ast::StorageClass::kPrivate, &mat);
|
||||
auto* b_var =
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kPrivate, &mat);
|
||||
|
||||
auto* coord_var =
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s);
|
||||
auto* coord_var = create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s);
|
||||
|
||||
auto* lhs = create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
|
@ -248,8 +249,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
auto* lhs = create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
|
@ -303,8 +304,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("a"));
|
||||
|
@ -353,8 +354,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("a"));
|
||||
|
@ -395,8 +396,8 @@ TEST_F(
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("a"));
|
||||
|
@ -441,8 +442,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::ArrayAccessorExpression expr(
|
||||
create<ast::ArrayAccessorExpression>(
|
||||
|
@ -488,8 +489,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::ArrayAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -532,8 +533,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
ast::ArrayAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -588,8 +589,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -634,8 +635,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -686,8 +687,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -737,8 +738,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -783,8 +784,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
ast::type::Struct s("Data", str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &s));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &s));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -860,7 +861,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::type::Struct pre_struct("Pre", pre_str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -930,7 +931,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::type::Struct pre_struct("Pre", pre_str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -1000,7 +1001,7 @@ TEST_F(
|
|||
ast::type::Struct pre_struct("Pre", pre_str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -1069,7 +1070,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::type::Struct pre_struct("Pre", pre_str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -1139,7 +1140,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::type::Struct pre_struct("Pre", pre_str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
@ -1220,7 +1221,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
ast::type::Struct pre_struct("Pre", pre_str);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
"data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct));
|
||||
|
||||
td.RegisterVariableForTesting(coord_var);
|
||||
gen.register_global(coord_var);
|
||||
|
|
|
@ -45,7 +45,8 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
|||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>("pos", ast::StorageClass::kNone, &ary);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "pos", ast::StorageClass::kNone, &ary);
|
||||
var->set_is_const(true);
|
||||
var->set_constructor(create<ast::TypeConstructorExpression>(&ary, exprs));
|
||||
|
||||
|
@ -60,7 +61,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
|||
decos.push_back(create<ast::ConstantIdDecoration>(23, Source{}));
|
||||
|
||||
auto* var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("pos", ast::StorageClass::kNone, &f32));
|
||||
create<ast::Variable>(Source{}, "pos", ast::StorageClass::kNone, &f32));
|
||||
var->set_decorations(decos);
|
||||
var->set_is_const(true);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
|
@ -82,7 +83,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) {
|
|||
decos.push_back(create<ast::ConstantIdDecoration>(23, Source{}));
|
||||
|
||||
auto* var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("pos", ast::StorageClass::kNone, &f32));
|
||||
create<ast::Variable>(Source{}, "pos", ast::StorageClass::kNone, &f32));
|
||||
var->set_decorations(decos);
|
||||
var->set_is_const(true);
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ using HlslGeneratorImplTest_VariableDecl = TestHelper;
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
gen.increment_indent();
|
||||
|
@ -45,7 +46,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_is_const(true);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
@ -59,7 +61,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Array ary(&f32, 5);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &ary);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &ary);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
gen.increment_indent();
|
||||
|
@ -71,7 +74,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
|
|||
TEST_F(HlslGeneratorImplTest_VariableDecl,
|
||||
Emit_VariableDeclStatement_Function) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
gen.increment_indent();
|
||||
|
@ -82,7 +86,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl,
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
gen.increment_indent();
|
||||
|
@ -96,7 +101,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl,
|
|||
auto* ident = create<ast::IdentifierExpression>("initializer");
|
||||
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(ident);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
@ -113,7 +119,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl,
|
|||
ast::ExpressionList values;
|
||||
auto* zero_vec = create<ast::TypeConstructorExpression>(&vec, values);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &vec);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &vec);
|
||||
var->set_constructor(zero_vec);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
@ -130,7 +137,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl,
|
|||
ast::ExpressionList values;
|
||||
auto* zero_mat = create<ast::TypeConstructorExpression>(&mat, values);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &mat);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &mat);
|
||||
var->set_constructor(zero_mat);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
|
|
@ -52,11 +52,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kInput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kInput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -106,11 +106,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kOutput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -160,11 +160,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kInput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kInput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -213,11 +213,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kOutput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &i32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -264,14 +264,14 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::LocationDecoration>(0, Source{}));
|
||||
foo_var->set_decorations(decos);
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kInput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kInput, &i32));
|
||||
decos.push_back(create<ast::LocationDecoration>(1, Source{}));
|
||||
bar_var->set_decorations(decos);
|
||||
|
||||
|
@ -314,14 +314,14 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kOutput, &f32));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::LocationDecoration>(0, Source{}));
|
||||
foo_var->set_decorations(decos);
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &i32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &i32));
|
||||
decos.push_back(create<ast::LocationDecoration>(1, Source{}));
|
||||
bar_var->set_decorations(decos);
|
||||
|
||||
|
@ -369,13 +369,13 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) {
|
|||
ast::type::Void void_type;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kInput, &vec4));
|
||||
coord_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord, Source{})});
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
depth_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
|
|
@ -105,8 +105,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &f32));
|
||||
params.push_back(create<ast::Variable>("b", ast::StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kNone, &i32));
|
||||
|
||||
ast::type::Void void_type;
|
||||
|
||||
|
@ -133,11 +135,11 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) {
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &f32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -188,13 +190,13 @@ TEST_F(MslGeneratorImplTest,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kInput, &vec4));
|
||||
coord_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord, Source{})});
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
depth_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
@ -244,8 +246,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kUniform, &vec4));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -257,7 +259,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) {
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("coord"),
|
||||
create<ast::IdentifierExpression>("x")));
|
||||
|
@ -309,8 +312,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
mod.AddConstructedType(&s);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -322,7 +325,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("coord"),
|
||||
create<ast::IdentifierExpression>("b")));
|
||||
|
@ -378,8 +382,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
mod.AddConstructedType(&s);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -392,7 +396,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
ast::VariableList params;
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("coord"),
|
||||
create<ast::IdentifierExpression>("b")));
|
||||
|
@ -434,15 +439,15 @@ TEST_F(
|
|||
ast::type::F32 f32;
|
||||
|
||||
auto* foo_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("foo", ast::StorageClass::kInput, &f32));
|
||||
create<ast::Variable>(Source{}, "foo", ast::StorageClass::kInput, &f32));
|
||||
foo_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &f32));
|
||||
bar_var->set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
|
||||
auto* val_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("val", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "val", ast::StorageClass::kOutput, &f32));
|
||||
val_var->set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -454,8 +459,8 @@ TEST_F(
|
|||
mod.AddGlobalVariable(val_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -524,8 +529,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(
|
||||
|
@ -537,8 +542,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod.AddGlobalVariable(depth_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -596,13 +601,13 @@ TEST_F(
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kInput, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kInput, &vec4));
|
||||
coord_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord, Source{})});
|
||||
|
||||
auto* depth_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("depth", ast::StorageClass::kOutput, &f32));
|
||||
auto* depth_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "depth", ast::StorageClass::kOutput, &f32));
|
||||
depth_var->set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
|
||||
|
@ -613,8 +618,8 @@ TEST_F(
|
|||
mod.AddGlobalVariable(depth_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
|
@ -675,8 +680,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec4(&f32, 4);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kUniform, &vec4));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kUniform, &vec4));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -688,8 +693,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -705,7 +710,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("sub_func"), expr));
|
||||
|
||||
|
@ -759,8 +765,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
mod.AddConstructedType(&s);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -771,8 +777,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -788,7 +794,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("sub_func"), expr));
|
||||
|
||||
|
@ -848,8 +855,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
mod.AddConstructedType(&s);
|
||||
|
||||
auto* coord_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* coord_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -860,8 +867,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod.AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
create<ast::Variable>("param", ast::StorageClass::kFunction, &f32));
|
||||
params.push_back(create<ast::Variable>(Source{}, "param",
|
||||
ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -877,7 +884,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
expr.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("sub_func"), expr));
|
||||
|
||||
|
@ -922,7 +930,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
ast::type::I32 i32;
|
||||
|
||||
auto* bar_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("bar", ast::StorageClass::kOutput, &f32));
|
||||
create<ast::Variable>(Source{}, "bar", ast::StorageClass::kOutput, &f32));
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::LocationDecoration>(1, Source{}));
|
||||
bar_var->set_decorations(decos);
|
||||
|
@ -1006,7 +1014,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) {
|
|||
ast::type::Array ary(&f32, 5);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &ary));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &ary));
|
||||
|
||||
ast::type::Void void_type;
|
||||
|
||||
|
@ -1063,8 +1072,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
ast::type::Struct s("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||
|
||||
auto* data_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* data_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -1078,7 +1087,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
@ -1099,7 +1109,8 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
|
|
@ -267,7 +267,8 @@ TEST_F(MslGeneratorImplTest, MslImportData_Determinant) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("var", ast::StorageClass::kFunction, &mat);
|
||||
auto* var = create<ast::Variable>(Source{}, "var",
|
||||
ast::StorageClass::kFunction, &mat);
|
||||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::IdentifierExpression>("var"));
|
||||
|
|
|
@ -70,8 +70,10 @@ TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) {
|
|||
ast::type::Vector vec2(&f32, 2);
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kNone, &vec2);
|
||||
auto* b = create<ast::Variable>("b", ast::StorageClass::kNone, &vec3);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &vec2);
|
||||
auto* b =
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kNone, &vec3);
|
||||
|
||||
ast::ExpressionList params;
|
||||
params.push_back(create<ast::IdentifierExpression>("a"));
|
||||
|
@ -108,8 +110,8 @@ TEST_F(MslGeneratorImplTest, Intrinsic_Call) {
|
|||
|
||||
ast::CallExpression call(create<ast::IdentifierExpression>("dot"), params);
|
||||
|
||||
ast::Variable v1("param1", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable v2("param2", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable v2(Source{}, "param2", ast::StorageClass::kFunction, &vec);
|
||||
|
||||
td.RegisterVariableForTesting(&v1);
|
||||
td.RegisterVariableForTesting(&v2);
|
||||
|
|
|
@ -149,14 +149,15 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
|
|||
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var = create<ast::Variable>("lhs", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "lhs",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.4)));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
create<ast::Variable>("other", ast::StorageClass::kFunction, &f32)));
|
||||
body->append(create<ast::VariableDeclStatement>(create<ast::Variable>(
|
||||
Source{}, "other", ast::StorageClass::kFunction, &f32)));
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
|
|
|
@ -47,7 +47,8 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
|||
exprs.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.0f)));
|
||||
|
||||
auto* var = create<ast::Variable>("pos", ast::StorageClass::kNone, &ary);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "pos", ast::StorageClass::kNone, &ary);
|
||||
var->set_is_const(true);
|
||||
var->set_constructor(create<ast::TypeConstructorExpression>(&ary, exprs));
|
||||
|
||||
|
@ -62,7 +63,7 @@ TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
|
|||
decos.push_back(create<ast::ConstantIdDecoration>(23, Source{}));
|
||||
|
||||
auto* var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("pos", ast::StorageClass::kNone, &f32));
|
||||
create<ast::Variable>(Source{}, "pos", ast::StorageClass::kNone, &f32));
|
||||
var->set_decorations(decos);
|
||||
var->set_is_const(true);
|
||||
var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
|
|
|
@ -42,7 +42,8 @@ using MslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -54,7 +55,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_is_const(true);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
@ -69,7 +71,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Array ary(&f32, 5);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &ary);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &ary);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -94,7 +97,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) {
|
|||
|
||||
ast::type::Struct s("S", str);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &s);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &s);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -109,7 +113,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec(&f32, 2);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &vec);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction, &vec);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -122,7 +127,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) {
|
|||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) {
|
||||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat(&f32, 2, 3);
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &mat);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction, &mat);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -134,7 +140,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -148,7 +155,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
|
|||
auto* ident = create<ast::IdentifierExpression>("initializer");
|
||||
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
var->set_constructor(ident);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
@ -165,7 +173,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec) {
|
|||
ast::ExpressionList values;
|
||||
auto* zero_vec = create<ast::TypeConstructorExpression>(&vec, values);
|
||||
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &vec);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &vec);
|
||||
var->set_constructor(zero_vec);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
|
|
@ -53,7 +53,7 @@ TEST_F(BuilderTest, ArrayAccessor) {
|
|||
// vec3<f32> ary;
|
||||
// ary[1] -> ptr<f32>
|
||||
|
||||
ast::Variable var("ary", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3);
|
||||
|
||||
auto* ary = create<ast::IdentifierExpression>("ary");
|
||||
auto* idx_expr = create<ast::ScalarConstructorExpression>(
|
||||
|
@ -94,8 +94,8 @@ TEST_F(BuilderTest, Accessor_Array_LoadIndex) {
|
|||
// idx : i32;
|
||||
// ary[idx] -> ptr<f32>
|
||||
|
||||
ast::Variable var("ary", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable idx("idx", ast::StorageClass::kFunction, &i32);
|
||||
ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable idx(Source{}, "idx", ast::StorageClass::kFunction, &i32);
|
||||
|
||||
auto* ary = create<ast::IdentifierExpression>("ary");
|
||||
auto* idx_expr = create<ast::IdentifierExpression>("idx");
|
||||
|
@ -139,7 +139,7 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) {
|
|||
// vec3<f32> ary;
|
||||
// ary[1 + 2] -> ptr<f32>
|
||||
|
||||
ast::Variable var("ary", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3);
|
||||
|
||||
auto* ary = create<ast::IdentifierExpression>("ary");
|
||||
|
||||
|
@ -186,7 +186,7 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) {
|
|||
// ary = array<vec3<f32>, 4>
|
||||
// ary[3][2];
|
||||
|
||||
ast::Variable var("ary", ast::StorageClass::kFunction, &ary4);
|
||||
ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &ary4);
|
||||
|
||||
ast::ArrayAccessorExpression expr(
|
||||
create<ast::ArrayAccessorExpression>(
|
||||
|
@ -233,7 +233,7 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) {
|
|||
// var a : array<vec3<f32>, 4>;
|
||||
// a[2].xy;
|
||||
|
||||
ast::Variable var("ary", ast::StorageClass::kFunction, &ary4);
|
||||
ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &ary4);
|
||||
|
||||
ast::MemberAccessorExpression expr(
|
||||
create<ast::ArrayAccessorExpression>(
|
||||
|
@ -289,7 +289,7 @@ TEST_F(BuilderTest, MemberAccessor) {
|
|||
auto* s = create<ast::Struct>(members);
|
||||
ast::type::Struct s_type("my_struct", s);
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type);
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("ident"),
|
||||
create<ast::IdentifierExpression>("b"));
|
||||
|
@ -343,7 +343,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested) {
|
|||
|
||||
ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members));
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type);
|
||||
|
||||
ast::MemberAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -403,7 +403,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
|
|||
|
||||
ast::type::Struct s_type("Outer", create<ast::Struct>(outer_members));
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type);
|
||||
|
||||
ast::MemberAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -462,7 +462,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) {
|
|||
|
||||
ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members));
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type);
|
||||
|
||||
auto* lhs = create<ast::MemberAccessorExpression>(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -528,8 +528,8 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) {
|
|||
|
||||
ast::type::Struct s_type("my_struct", create<ast::Struct>(outer_members));
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &s_type);
|
||||
ast::Variable store("store", ast::StorageClass::kFunction, &f32);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type);
|
||||
ast::Variable store(Source{}, "store", ast::StorageClass::kFunction, &f32);
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("store");
|
||||
|
||||
|
@ -578,7 +578,7 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_Single) {
|
|||
|
||||
// ident.y
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3);
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("ident"),
|
||||
create<ast::IdentifierExpression>("y"));
|
||||
|
@ -613,7 +613,7 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_MultipleNames) {
|
|||
|
||||
// ident.yx
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3);
|
||||
|
||||
ast::MemberAccessorExpression expr(create<ast::IdentifierExpression>("ident"),
|
||||
create<ast::IdentifierExpression>("yx"));
|
||||
|
@ -647,7 +647,7 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_of_Swizzle) {
|
|||
|
||||
// ident.yxz.xz
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3);
|
||||
|
||||
ast::MemberAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -685,7 +685,7 @@ TEST_F(BuilderTest, MemberAccessor_Member_of_Swizzle) {
|
|||
|
||||
// ident.yxz.x
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3);
|
||||
|
||||
ast::MemberAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -723,7 +723,7 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) {
|
|||
|
||||
// index.yxz[1]
|
||||
|
||||
ast::Variable var("ident", ast::StorageClass::kFunction, &vec3);
|
||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3);
|
||||
|
||||
ast::ArrayAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -792,7 +792,8 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
|
|||
|
||||
ast::type::Array a_ary_type(&a_type, 2);
|
||||
|
||||
ast::Variable var("index", ast::StorageClass::kFunction, &a_ary_type);
|
||||
ast::Variable var(Source{}, "index", ast::StorageClass::kFunction,
|
||||
&a_ary_type);
|
||||
|
||||
ast::MemberAccessorExpression expr(
|
||||
create<ast::MemberAccessorExpression>(
|
||||
|
@ -884,7 +885,7 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) {
|
|||
create<ast::FloatLiteral>(&f32, -0.5)),
|
||||
}));
|
||||
|
||||
ast::Variable var("pos", ast::StorageClass::kPrivate, &arr);
|
||||
ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &arr);
|
||||
var.set_is_const(true);
|
||||
var.set_constructor(create<ast::TypeConstructorExpression>(&arr, ary_params));
|
||||
|
||||
|
@ -940,7 +941,7 @@ TEST_F(BuilderTest, Accessor_Const_Vec) {
|
|||
vec_params.push_back(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.5)));
|
||||
|
||||
ast::Variable var("pos", ast::StorageClass::kPrivate, &vec);
|
||||
ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &vec);
|
||||
var.set_is_const(true);
|
||||
var.set_constructor(
|
||||
create<ast::TypeConstructorExpression>(&vec, std::move(vec_params)));
|
||||
|
|
|
@ -44,7 +44,7 @@ using BuilderTest = TestHelper;
|
|||
TEST_F(BuilderTest, Assign_Var) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
|
||||
auto* ident = create<ast::IdentifierExpression>("var");
|
||||
auto* val = create<ast::ScalarConstructorExpression>(
|
||||
|
@ -78,7 +78,7 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec(&f32, 3);
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &vec);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec);
|
||||
|
||||
auto* ident = create<ast::IdentifierExpression>("var");
|
||||
ast::ExpressionList vals;
|
||||
|
@ -128,7 +128,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) {
|
|||
create<ast::FloatLiteral>(&f32, 3.0f)),
|
||||
});
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &vec3);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3);
|
||||
|
||||
ast::AssignmentStatement assign(create<ast::IdentifierExpression>("var"),
|
||||
init);
|
||||
|
@ -176,7 +176,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) {
|
|||
|
||||
auto* init = create<ast::TypeConstructorExpression>(&vec3, vals);
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &vec3);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3);
|
||||
|
||||
ast::AssignmentStatement assign(create<ast::IdentifierExpression>("var"),
|
||||
init);
|
||||
|
@ -223,7 +223,7 @@ TEST_F(BuilderTest, Assign_StructMember) {
|
|||
auto* s = create<ast::Struct>(members);
|
||||
ast::type::Struct s_type("my_struct", s);
|
||||
|
||||
ast::Variable v("ident", ast::StorageClass::kFunction, &s_type);
|
||||
ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type);
|
||||
|
||||
auto* ident = create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("ident"),
|
||||
|
@ -265,7 +265,7 @@ TEST_F(BuilderTest, Assign_Vector) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec3(&f32, 3);
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &vec3);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3);
|
||||
|
||||
auto* ident = create<ast::IdentifierExpression>("var");
|
||||
|
||||
|
@ -312,7 +312,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) {
|
|||
|
||||
// var.y = 1
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &vec3);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3);
|
||||
|
||||
auto* ident = create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("var"),
|
||||
|
@ -357,7 +357,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) {
|
|||
|
||||
// var[1] = 1
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &vec3);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3);
|
||||
|
||||
auto* ident = create<ast::ArrayAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("var"),
|
||||
|
|
|
@ -121,7 +121,7 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar_Loads) {
|
|||
|
||||
ast::type::I32 i32;
|
||||
|
||||
ast::Variable var("param", ast::StorageClass::kFunction, &i32);
|
||||
ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &i32);
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>("param");
|
||||
auto* rhs = create<ast::IdentifierExpression>("param");
|
||||
|
@ -633,7 +633,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::IdentifierExpression>("mat");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
|
@ -665,7 +666,8 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.f));
|
||||
auto* rhs = create<ast::IdentifierExpression>("mat");
|
||||
|
@ -698,7 +700,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::IdentifierExpression>("mat");
|
||||
|
||||
ast::ExpressionList vals;
|
||||
|
@ -739,7 +742,8 @@ TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
|
||||
ast::ExpressionList vals;
|
||||
vals.push_back(create<ast::ScalarConstructorExpression>(
|
||||
|
@ -781,7 +785,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) {
|
|||
ast::type::Vector vec3(&f32, 3);
|
||||
ast::type::Matrix mat3(&f32, 3, 3);
|
||||
|
||||
auto* var = create<ast::Variable>("mat", ast::StorageClass::kFunction, &mat3);
|
||||
auto* var = create<ast::Variable>(Source{}, "mat",
|
||||
ast::StorageClass::kFunction, &mat3);
|
||||
auto* lhs = create<ast::IdentifierExpression>("mat");
|
||||
auto* rhs = create<ast::IdentifierExpression>("mat");
|
||||
|
||||
|
@ -856,12 +861,12 @@ OpBranch %7
|
|||
TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) {
|
||||
ast::type::Bool bool_type;
|
||||
|
||||
auto* a_var =
|
||||
create<ast::Variable>("a", ast::StorageClass::kFunction, &bool_type);
|
||||
auto* a_var = create<ast::Variable>(Source{}, "a",
|
||||
ast::StorageClass::kFunction, &bool_type);
|
||||
a_var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true)));
|
||||
auto* b_var =
|
||||
create<ast::Variable>("b", ast::StorageClass::kFunction, &bool_type);
|
||||
auto* b_var = create<ast::Variable>(Source{}, "b",
|
||||
ast::StorageClass::kFunction, &bool_type);
|
||||
b_var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, false)));
|
||||
|
||||
|
@ -1042,12 +1047,12 @@ OpBranch %7
|
|||
TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) {
|
||||
ast::type::Bool bool_type;
|
||||
|
||||
auto* a_var =
|
||||
create<ast::Variable>("a", ast::StorageClass::kFunction, &bool_type);
|
||||
auto* a_var = create<ast::Variable>(Source{}, "a",
|
||||
ast::StorageClass::kFunction, &bool_type);
|
||||
a_var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true)));
|
||||
auto* b_var =
|
||||
create<ast::Variable>("b", ast::StorageClass::kFunction, &bool_type);
|
||||
auto* b_var = create<ast::Variable>(Source{}, "b",
|
||||
ast::StorageClass::kFunction, &bool_type);
|
||||
b_var->set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, false)));
|
||||
|
||||
|
|
|
@ -41,16 +41,16 @@ TEST_F(BuilderTest, Block) {
|
|||
// serves to prove the block code is pushing new scopes as needed.
|
||||
ast::BlockStatement outer;
|
||||
|
||||
outer.append(create<ast::VariableDeclStatement>(
|
||||
create<ast::Variable>("var", ast::StorageClass::kFunction, &f32)));
|
||||
outer.append(create<ast::VariableDeclStatement>(create<ast::Variable>(
|
||||
Source{}, "var", ast::StorageClass::kFunction, &f32)));
|
||||
outer.append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>("var"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0f))));
|
||||
|
||||
auto* inner = create<ast::BlockStatement>();
|
||||
inner->append(create<ast::VariableDeclStatement>(
|
||||
create<ast::Variable>("var", ast::StorageClass::kFunction, &f32)));
|
||||
inner->append(create<ast::VariableDeclStatement>(create<ast::Variable>(
|
||||
Source{}, "var", ast::StorageClass::kFunction, &f32)));
|
||||
inner->append(create<ast::AssignmentStatement>(
|
||||
create<ast::IdentifierExpression>("var"),
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
|
|
|
@ -44,9 +44,9 @@ TEST_F(BuilderTest, Expression_Call) {
|
|||
|
||||
ast::VariableList func_params;
|
||||
func_params.push_back(
|
||||
create<ast::Variable>("a", ast::StorageClass::kFunction, &f32));
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction, &f32));
|
||||
func_params.push_back(
|
||||
create<ast::Variable>("b", ast::StorageClass::kFunction, &f32));
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>(create<ast::BinaryExpression>(
|
||||
|
@ -108,9 +108,9 @@ TEST_F(BuilderTest, Statement_Call) {
|
|||
|
||||
ast::VariableList func_params;
|
||||
func_params.push_back(
|
||||
create<ast::Variable>("a", ast::StorageClass::kFunction, &f32));
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction, &f32));
|
||||
func_params.push_back(
|
||||
create<ast::Variable>("b", ast::StorageClass::kFunction, &f32));
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kFunction, &f32));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::ReturnStatement>(create<ast::BinaryExpression>(
|
||||
|
|
|
@ -102,11 +102,12 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) {
|
|||
create<ast::StageDecoration>(ast::PipelineStage::kVertex, Source{}),
|
||||
});
|
||||
|
||||
auto* v_in = create<ast::Variable>("my_in", ast::StorageClass::kInput, &f32);
|
||||
auto* v_out =
|
||||
create<ast::Variable>("my_out", ast::StorageClass::kOutput, &f32);
|
||||
auto* v_wg =
|
||||
create<ast::Variable>("my_wg", ast::StorageClass::kWorkgroup, &f32);
|
||||
auto* v_in =
|
||||
create<ast::Variable>(Source{}, "my_in", ast::StorageClass::kInput, &f32);
|
||||
auto* v_out = create<ast::Variable>(Source{}, "my_out",
|
||||
ast::StorageClass::kOutput, &f32);
|
||||
auto* v_wg = create<ast::Variable>(Source{}, "my_wg",
|
||||
ast::StorageClass::kWorkgroup, &f32);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(v_in)) << b.error();
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(v_out)) << b.error();
|
||||
|
@ -161,11 +162,12 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) {
|
|||
create<ast::IdentifierExpression>("my_in")));
|
||||
func.set_body(body);
|
||||
|
||||
auto* v_in = create<ast::Variable>("my_in", ast::StorageClass::kInput, &f32);
|
||||
auto* v_out =
|
||||
create<ast::Variable>("my_out", ast::StorageClass::kOutput, &f32);
|
||||
auto* v_wg =
|
||||
create<ast::Variable>("my_wg", ast::StorageClass::kWorkgroup, &f32);
|
||||
auto* v_in =
|
||||
create<ast::Variable>(Source{}, "my_in", ast::StorageClass::kInput, &f32);
|
||||
auto* v_out = create<ast::Variable>(Source{}, "my_out",
|
||||
ast::StorageClass::kOutput, &f32);
|
||||
auto* v_wg = create<ast::Variable>(Source{}, "my_wg",
|
||||
ast::StorageClass::kWorkgroup, &f32);
|
||||
|
||||
td.RegisterVariableForTesting(v_in);
|
||||
td.RegisterVariableForTesting(v_out);
|
||||
|
|
|
@ -87,7 +87,8 @@ TEST_F(BuilderTest, Function_Terminator_ReturnValue) {
|
|||
ast::type::Void void_type;
|
||||
ast::type::F32 f32;
|
||||
|
||||
auto* var_a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
|
||||
auto* var_a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &f32);
|
||||
td.RegisterVariableForTesting(var_a);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
|
@ -142,10 +143,12 @@ TEST_F(BuilderTest, Function_WithParams) {
|
|||
ast::type::I32 i32;
|
||||
|
||||
ast::VariableList params;
|
||||
auto* var_a = create<ast::Variable>("a", ast::StorageClass::kFunction, &f32);
|
||||
auto* var_a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction, &f32);
|
||||
var_a->set_is_const(true);
|
||||
params.push_back(var_a);
|
||||
auto* var_b = create<ast::Variable>("b", ast::StorageClass::kFunction, &i32);
|
||||
auto* var_b =
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kFunction, &i32);
|
||||
var_b->set_is_const(true);
|
||||
params.push_back(var_b);
|
||||
|
||||
|
@ -256,8 +259,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
ast::type::Struct s("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||
|
||||
auto* data_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* data_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -271,7 +274,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
@ -292,7 +296,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
|
|
@ -47,7 +47,7 @@ using BuilderTest = TestHelper;
|
|||
|
||||
TEST_F(BuilderTest, FunctionVar_NoStorageClass) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("var", ast::StorageClass::kNone, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kNone, &f32);
|
||||
|
||||
b.push_function(Function{});
|
||||
EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error();
|
||||
|
@ -80,7 +80,7 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
@ -126,7 +126,7 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kFunction, &vec);
|
||||
v.set_constructor(init);
|
||||
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
@ -164,11 +164,11 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("v", ast::StorageClass::kFunction, &f32);
|
||||
ast::Variable v(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
v.set_constructor(init);
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
||||
ast::Variable v2("v2", ast::StorageClass::kFunction, &f32);
|
||||
ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32);
|
||||
v2.set_constructor(create<ast::IdentifierExpression>("v"));
|
||||
td.RegisterVariableForTesting(&v2);
|
||||
|
||||
|
@ -209,11 +209,11 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("v", ast::StorageClass::kFunction, &f32);
|
||||
ast::Variable v(Source{}, "v", ast::StorageClass::kFunction, &f32);
|
||||
v.set_constructor(init);
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
||||
ast::Variable v2("v2", ast::StorageClass::kFunction, &f32);
|
||||
ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32);
|
||||
v2.set_is_const(true);
|
||||
v2.set_constructor(create<ast::IdentifierExpression>("v"));
|
||||
td.RegisterVariableForTesting(&v2);
|
||||
|
@ -257,7 +257,7 @@ TEST_F(BuilderTest, FunctionVar_Const) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
v.set_is_const(true);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ using BuilderTest = TestHelper;
|
|||
|
||||
TEST_F(BuilderTest, GlobalVar_NoStorageClass) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("var", ast::StorageClass::kNone, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kNone, &f32);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
|
||||
|
@ -66,7 +66,7 @@ TEST_F(BuilderTest, GlobalVar_NoStorageClass) {
|
|||
|
||||
TEST_F(BuilderTest, GlobalVar_WithStorageClass) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
|
||||
|
@ -80,7 +80,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass) {
|
|||
|
||||
TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("var", ast::StorageClass::kInput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kInput, &f32);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
|
||||
|
@ -107,7 +107,7 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
||||
|
@ -142,7 +142,7 @@ TEST_F(BuilderTest, GlobalVar_Const) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
v.set_is_const(true);
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
@ -175,7 +175,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
v.set_is_const(true);
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
@ -214,7 +214,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
v.set_is_const(true);
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
@ -240,7 +240,8 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
|
|||
|
||||
TEST_F(BuilderTest, GlobalVar_WithLocation) {
|
||||
ast::type::F32 f32;
|
||||
auto* v = create<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::LocationDecoration>(5, Source{}));
|
||||
|
||||
|
@ -261,7 +262,8 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) {
|
|||
|
||||
TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) {
|
||||
ast::type::F32 f32;
|
||||
auto* v = create<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(2, Source{}));
|
||||
decos.push_back(create<ast::SetDecoration>(3, Source{}));
|
||||
|
@ -284,7 +286,8 @@ OpDecorate %1 DescriptorSet 3
|
|||
|
||||
TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
|
||||
ast::type::F32 f32;
|
||||
auto* v = create<ast::Variable>("var", ast::StorageClass::kOutput, &f32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kPosition, Source{}));
|
||||
|
@ -310,8 +313,8 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
|
|||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::ConstantIdDecoration>(1200, Source{}));
|
||||
|
||||
ast::DecoratedVariable v(
|
||||
create<ast::Variable>("var", ast::StorageClass::kNone, &bool_type));
|
||||
ast::DecoratedVariable v(create<ast::Variable>(
|
||||
Source{}, "var", ast::StorageClass::kNone, &bool_type));
|
||||
v.set_decorations(decos);
|
||||
v.set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true)));
|
||||
|
@ -334,8 +337,8 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
|
|||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::ConstantIdDecoration>(1200, Source{}));
|
||||
|
||||
ast::DecoratedVariable v(
|
||||
create<ast::Variable>("var", ast::StorageClass::kNone, &bool_type));
|
||||
ast::DecoratedVariable v(create<ast::Variable>(
|
||||
Source{}, "var", ast::StorageClass::kNone, &bool_type));
|
||||
v.set_decorations(decos);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
|
||||
|
@ -357,7 +360,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
|
|||
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
|
||||
|
||||
ast::DecoratedVariable v(
|
||||
create<ast::Variable>("var", ast::StorageClass::kNone, &f32));
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kNone, &f32));
|
||||
v.set_decorations(decos);
|
||||
v.set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)));
|
||||
|
@ -381,7 +384,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
|
|||
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
|
||||
|
||||
ast::DecoratedVariable v(
|
||||
create<ast::Variable>("var", ast::StorageClass::kNone, &f32));
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kNone, &f32));
|
||||
v.set_decorations(decos);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
|
||||
|
@ -403,7 +406,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
|
|||
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
|
||||
|
||||
ast::DecoratedVariable v(
|
||||
create<ast::Variable>("var", ast::StorageClass::kNone, &i32));
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kNone, &i32));
|
||||
v.set_decorations(decos);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
|
||||
|
@ -425,7 +428,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) {
|
|||
decos.push_back(create<ast::ConstantIdDecoration>(0, Source{}));
|
||||
|
||||
ast::DecoratedVariable v(
|
||||
create<ast::Variable>("var", ast::StorageClass::kNone, &u32));
|
||||
create<ast::Variable>(Source{}, "var", ast::StorageClass::kNone, &u32));
|
||||
v.set_decorations(decos);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error();
|
||||
|
@ -490,7 +493,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
|
|||
ast::type::Struct A("A", create<ast::Struct>(members));
|
||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
|
||||
|
||||
ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac);
|
||||
ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&var)) << b.error();
|
||||
|
||||
|
@ -526,7 +529,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
|
|||
ast::type::Alias B("B", &A);
|
||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B};
|
||||
|
||||
ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac);
|
||||
ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&var)) << b.error();
|
||||
|
||||
|
@ -560,7 +563,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
|
|||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
|
||||
ast::type::Alias B("B", &ac);
|
||||
|
||||
ast::Variable var("b", ast::StorageClass::kStorageBuffer, &B);
|
||||
ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &B);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&var)) << b.error();
|
||||
|
||||
|
@ -594,8 +597,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
|
|||
ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A};
|
||||
ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A};
|
||||
|
||||
ast::Variable var_b("b", ast::StorageClass::kStorageBuffer, &read);
|
||||
ast::Variable var_c("c", ast::StorageClass::kStorageBuffer, &rw);
|
||||
ast::Variable var_b(Source{}, "b", ast::StorageClass::kStorageBuffer, &read);
|
||||
ast::Variable var_c(Source{}, "c", ast::StorageClass::kStorageBuffer, &rw);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&var_b)) << b.error();
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&var_c)) << b.error();
|
||||
|
@ -626,7 +629,8 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) {
|
|||
ast::type::ImageFormat::kR32Uint);
|
||||
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error();
|
||||
|
||||
ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type);
|
||||
ast::Variable var_a(Source{}, "a", ast::StorageClass::kUniformConstant,
|
||||
&type);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&var_a)) << b.error();
|
||||
|
||||
|
@ -646,7 +650,8 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
|
|||
ast::type::ImageFormat::kR32Uint);
|
||||
ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error();
|
||||
|
||||
ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type);
|
||||
ast::Variable var_a(Source{}, "a", ast::StorageClass::kUniformConstant,
|
||||
&type);
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&var_a)) << b.error();
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
v.set_is_const(true);
|
||||
|
||||
|
@ -77,7 +77,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
|||
|
||||
TEST_F(BuilderTest, IdentifierExpression_GlobalVar) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
||||
|
@ -112,7 +112,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
ast::Variable v("var", ast::StorageClass::kOutput, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32);
|
||||
v.set_constructor(init);
|
||||
v.set_is_const(true);
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
@ -134,7 +134,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
|||
|
||||
TEST_F(BuilderTest, IdentifierExpression_FunctionVar) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("var", ast::StorageClass::kNone, &f32);
|
||||
ast::Variable v(Source{}, "var", ast::StorageClass::kNone, &f32);
|
||||
|
||||
td.RegisterVariableForTesting(&v);
|
||||
|
||||
|
@ -160,7 +160,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) {
|
|||
TEST_F(BuilderTest, IdentifierExpression_Load) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
ast::Variable var("var", ast::StorageClass::kPrivate, &i32);
|
||||
ast::Variable var(Source{}, "var", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
td.RegisterVariableForTesting(&var);
|
||||
|
||||
|
@ -190,7 +190,7 @@ TEST_F(BuilderTest, IdentifierExpression_Load) {
|
|||
TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
ast::Variable var("var", ast::StorageClass::kNone, &i32);
|
||||
ast::Variable var(Source{}, "var", ast::StorageClass::kNone, &i32);
|
||||
var.set_constructor(create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)));
|
||||
var.set_is_const(true);
|
||||
|
|
|
@ -75,7 +75,8 @@ TEST_F(BuilderTest, If_WithStatements) {
|
|||
// if (true) {
|
||||
// v = 2;
|
||||
// }
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -122,7 +123,8 @@ TEST_F(BuilderTest, If_WithElse) {
|
|||
// } else {
|
||||
// v = 3;
|
||||
// }
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -181,7 +183,8 @@ TEST_F(BuilderTest, If_WithElseIf) {
|
|||
// } elseif (true) {
|
||||
// v = 3;
|
||||
// }
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -252,7 +255,8 @@ TEST_F(BuilderTest, If_WithMultiple) {
|
|||
// } else {
|
||||
// v = 5;
|
||||
// }
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -605,8 +609,8 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) {
|
|||
// }
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* var =
|
||||
create<ast::Variable>("a", ast::StorageClass::kFunction, &bool_type);
|
||||
auto* var = create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction,
|
||||
&bool_type);
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
||||
ast::IfStatement expr(Source{}, create<ast::IdentifierExpression>("a"),
|
||||
|
|
|
@ -65,7 +65,8 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) {
|
|||
// loop {
|
||||
// v = 2;
|
||||
// }
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
@ -111,7 +112,8 @@ TEST_F(BuilderTest, Loop_WithContinuing) {
|
|||
// }
|
||||
// }
|
||||
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(
|
||||
|
|
|
@ -81,7 +81,7 @@ TEST_F(BuilderTest, Return_WithValue) {
|
|||
TEST_F(BuilderTest, Return_WithValue_GeneratesLoad) {
|
||||
ast::type::F32 f32;
|
||||
|
||||
ast::Variable var("param", ast::StorageClass::kFunction, &f32);
|
||||
ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &f32);
|
||||
|
||||
ast::ReturnStatement ret(create<ast::IdentifierExpression>("param"));
|
||||
|
||||
|
|
|
@ -76,8 +76,10 @@ TEST_F(BuilderTest, Switch_WithCase) {
|
|||
// v = 2;
|
||||
// }
|
||||
|
||||
auto* v = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &i32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>();
|
||||
case_1_body->append(
|
||||
|
@ -155,8 +157,10 @@ TEST_F(BuilderTest, Switch_WithDefault) {
|
|||
// v = 1;
|
||||
// }
|
||||
|
||||
auto* v = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &i32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* default_body = create<ast::BlockStatement>();
|
||||
default_body->append(
|
||||
|
@ -219,8 +223,10 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) {
|
|||
// v = 3;
|
||||
// }
|
||||
|
||||
auto* v = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &i32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>();
|
||||
case_1_body->append(
|
||||
|
@ -313,8 +319,10 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) {
|
|||
// v = 3;
|
||||
// }
|
||||
|
||||
auto* v = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &i32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>();
|
||||
case_1_body->append(
|
||||
|
@ -403,8 +411,10 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) {
|
|||
// fallthrough;
|
||||
// }
|
||||
|
||||
auto* v = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &i32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>();
|
||||
case_1_body->append(
|
||||
|
@ -449,8 +459,10 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) {
|
|||
// v = 1;
|
||||
// }
|
||||
|
||||
auto* v = create<ast::Variable>("v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a = create<ast::Variable>("a", ast::StorageClass::kPrivate, &i32);
|
||||
auto* v =
|
||||
create<ast::Variable>(Source{}, "v", ast::StorageClass::kPrivate, &i32);
|
||||
auto* a =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &i32);
|
||||
|
||||
auto* if_body = create<ast::BlockStatement>();
|
||||
if_body->append(create<ast::BreakStatement>());
|
||||
|
|
|
@ -98,7 +98,7 @@ TEST_F(BuilderTest, UnaryOp_LoadRequired) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::Vector vec(&f32, 3);
|
||||
|
||||
ast::Variable var("param", ast::StorageClass::kFunction, &vec);
|
||||
ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &vec);
|
||||
|
||||
ast::UnaryOpExpression expr(ast::UnaryOp::kNegation,
|
||||
create<ast::IdentifierExpression>("param"));
|
||||
|
|
|
@ -68,8 +68,10 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) {
|
|||
ast::type::F32 f32;
|
||||
ast::type::I32 i32;
|
||||
ast::VariableList params;
|
||||
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &f32));
|
||||
params.push_back(create<ast::Variable>("b", ast::StorageClass::kNone, &i32));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32));
|
||||
params.push_back(
|
||||
create<ast::Variable>(Source{}, "b", ast::StorageClass::kNone, &i32));
|
||||
|
||||
ast::type::Void void_type;
|
||||
ast::Function func(Source{}, "my_func", params, &void_type, body,
|
||||
|
@ -189,8 +191,8 @@ TEST_F(WgslGeneratorImplTest,
|
|||
ast::type::Struct s("Data", str);
|
||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||
|
||||
auto* data_var = create<ast::DecoratedVariable>(
|
||||
create<ast::Variable>("data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
auto* data_var = create<ast::DecoratedVariable>(create<ast::Variable>(
|
||||
Source{}, "data", ast::StorageClass::kStorageBuffer, &ac));
|
||||
|
||||
ast::VariableDecorationList decos;
|
||||
decos.push_back(create<ast::BindingDecoration>(0, Source{}));
|
||||
|
@ -204,7 +206,8 @@ TEST_F(WgslGeneratorImplTest,
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
@ -225,7 +228,8 @@ TEST_F(WgslGeneratorImplTest,
|
|||
|
||||
{
|
||||
ast::VariableList params;
|
||||
auto* var = create<ast::Variable>("v", ast::StorageClass::kFunction, &f32);
|
||||
auto* var = create<ast::Variable>(Source{}, "v",
|
||||
ast::StorageClass::kFunction, &f32);
|
||||
var->set_constructor(create<ast::MemberAccessorExpression>(
|
||||
create<ast::IdentifierExpression>("data"),
|
||||
create<ast::IdentifierExpression>("d")));
|
||||
|
|
|
@ -32,7 +32,8 @@ using WgslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -47,7 +48,8 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) {
|
|||
// storage class. Rely on defaulting.
|
||||
// https://github.com/gpuweb/gpuweb/issues/654
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kFunction, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kFunction, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
@ -59,7 +61,8 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
|
||||
ast::type::F32 f32;
|
||||
auto* var = create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
|
||||
auto* var =
|
||||
create<ast::Variable>(Source{}, "a", ast::StorageClass::kPrivate, &f32);
|
||||
|
||||
ast::VariableDeclStatement stmt(var);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ using WgslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("a", ast::StorageClass::kNone, &f32);
|
||||
ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
|
||||
ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(var a : f32;
|
||||
|
@ -44,7 +44,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) {
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("a", ast::StorageClass::kInput, &f32);
|
||||
ast::Variable v(Source{}, "a", ast::StorageClass::kInput, &f32);
|
||||
|
||||
ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(var<in> a : f32;
|
||||
|
@ -94,7 +94,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
|
|||
auto* ident = create<ast::IdentifierExpression>("initializer");
|
||||
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("a", ast::StorageClass::kNone, &f32);
|
||||
ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
v.set_constructor(ident);
|
||||
|
||||
ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error();
|
||||
|
@ -106,7 +106,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Const) {
|
|||
auto* ident = create<ast::IdentifierExpression>("initializer");
|
||||
|
||||
ast::type::F32 f32;
|
||||
ast::Variable v("a", ast::StorageClass::kNone, &f32);
|
||||
ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32);
|
||||
v.set_constructor(ident);
|
||||
v.set_is_const(true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue