diff --git a/src/ast/builder.h b/src/ast/builder.h index bbb6ecf681..d77b0b9710 100644 --- a/src/ast/builder.h +++ b/src/ast/builder.h @@ -742,6 +742,15 @@ class Builder { /// @param loc the Source used for future create() calls void SetSource(const Source::Location& loc) { source_ = Source(loc); } + /// @returns true if all required fields in the AST are present. + bool IsValid() const { return mod->IsValid(); } + + /// @returns a reference to the program's AST root Module + ast::Module& AST() { return mod->AST(); } + + /// @returns a reference to the program's SymbolTable + SymbolTable& Symbols() { return mod->Symbols(); } + /// The builder program Program* const program; /// The builder types diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc index 636042a1d5..fac3dd1f79 100644 --- a/src/ast/function_test.cc +++ b/src/ast/function_test.cc @@ -36,7 +36,7 @@ TEST_F(FunctionTest, Creation) { auto* f = Func("func", params, ty.void_(), StatementList{}, FunctionDecorationList{}); - EXPECT_EQ(f->symbol(), mod->Symbols().Register("func")); + EXPECT_EQ(f->symbol(), Symbols().Register("func")); ASSERT_EQ(f->params().size(), 1u); EXPECT_EQ(f->return_type(), ty.void_()); EXPECT_EQ(f->params()[0], var); @@ -151,7 +151,7 @@ TEST_F(FunctionTest, AddDuplicateEntryPoints) { auto* f = Func("func", VariableList{}, ty.void_(), StatementList{}, FunctionDecorationList{}); - auto main_sym = mod->Symbols().Register("main"); + auto main_sym = Symbols().Register("main"); f->add_ancestor_entry_point(main_sym); ASSERT_EQ(1u, f->ancestor_entry_points().size()); EXPECT_EQ(main_sym, f->ancestor_entry_points()[0]); @@ -364,12 +364,12 @@ TEST_F(FunctionListTest, FindSymbol) { ast::FunctionDecorationList{}); FunctionList list; list.Add(func); - EXPECT_EQ(func, list.Find(mod->Symbols().Register("main"))); + EXPECT_EQ(func, list.Find(Symbols().Register("main"))); } TEST_F(FunctionListTest, FindSymbolMissing) { FunctionList list; - EXPECT_EQ(nullptr, list.Find(mod->Symbols().Register("Missing"))); + EXPECT_EQ(nullptr, list.Find(Symbols().Register("Missing"))); } TEST_F(FunctionListTest, FindSymbolStage) { @@ -384,10 +384,9 @@ TEST_F(FunctionListTest, FindSymbolStage) { FunctionList list; list.Add(fs); list.Add(vs); - EXPECT_EQ( - fs, list.Find(mod->Symbols().Register("main"), PipelineStage::kFragment)); - EXPECT_EQ(vs, - list.Find(mod->Symbols().Register("main"), PipelineStage::kVertex)); + EXPECT_EQ(fs, + list.Find(Symbols().Register("main"), PipelineStage::kFragment)); + EXPECT_EQ(vs, list.Find(Symbols().Register("main"), PipelineStage::kVertex)); } TEST_F(FunctionListTest, FindSymbolStageMissing) { @@ -397,7 +396,7 @@ TEST_F(FunctionListTest, FindSymbolStageMissing) { create(PipelineStage::kFragment), })); EXPECT_EQ(nullptr, - list.Find(mod->Symbols().Register("main"), PipelineStage::kVertex)); + list.Find(Symbols().Register("main"), PipelineStage::kVertex)); } TEST_F(FunctionListTest, HasStage) { diff --git a/src/ast/test_helper.h b/src/ast/test_helper.h index 9f39b02201..8ae08f574a 100644 --- a/src/ast/test_helper.h +++ b/src/ast/test_helper.h @@ -35,7 +35,7 @@ class TestHelperBase : public BASE, public BuilderWithProgram { /// @param s the string to demangle /// @returns the demangled string std::string demangle(const std::string& s) { - return demanger.Demangle(mod->Symbols(), s); + return demanger.Demangle(Symbols(), s); } /// A demangler diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index 3659928cf0..569086b310 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -114,11 +114,11 @@ class InspectorHelper : public ast::BuilderWithProgram { std::string in, out; std::tie(in, out) = inout; - mod->AST().AddGlobalVariable( + AST().AddGlobalVariable( Var(in, ast::StorageClass::kInput, ty.u32(), nullptr, ast::VariableDecorationList{ create(location++)})); - mod->AST().AddGlobalVariable( + AST().AddGlobalVariable( Var(out, ast::StorageClass::kOutput, ty.u32(), nullptr, ast::VariableDecorationList{ create(location++)})); @@ -187,7 +187,7 @@ class InspectorHelper : public ast::BuilderWithProgram { ast::VariableDecorationList{ create(id), }); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); } /// @param type AST type of the literal, must resolve to BoolLiteral @@ -334,7 +334,7 @@ class InspectorHelper : public ast::BuilderWithProgram { create(group), }); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); } /// Adds an uniform buffer variable to the program @@ -469,7 +469,7 @@ class InspectorHelper : public ast::BuilderWithProgram { } void AddGlobalVariable(const std::string& name, type::Type* type) { - mod->AST().AddGlobalVariable( + AST().AddGlobalVariable( Var(name, ast::StorageClass::kUniformConstant, type)); } @@ -477,7 +477,7 @@ class InspectorHelper : public ast::BuilderWithProgram { /// @param name the name of the variable /// @param type the type to use void AddDepthTexture(const std::string& name, type::Type* type) { - mod->AST().AddGlobalVariable( + AST().AddGlobalVariable( Var(name, ast::StorageClass::kUniformConstant, type)); } @@ -701,7 +701,7 @@ TEST_F(InspectorGetEntryPointTest, NoFunctions) { } TEST_F(InspectorGetEntryPointTest, NoEntryPoints) { - mod->AST().Functions().Add(MakeEmptyBodyFunction("foo", {})); + AST().Functions().Add(MakeEmptyBodyFunction("foo", {})); auto result = inspector()->GetEntryPoints(); ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); @@ -714,7 +714,7 @@ TEST_F(InspectorGetEntryPointTest, OneEntryPoint) { "foo", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); // TODO(dsinclair): Update to run the namer transform when available. @@ -732,13 +732,13 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) { "foo", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto* bar = MakeEmptyBodyFunction( "bar", ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(bar); + AST().Functions().Add(bar); // TODO(dsinclair): Update to run the namer transform when available. @@ -756,21 +756,21 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) { TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) { auto* func = MakeEmptyBodyFunction("func", {}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto* bar = MakeCallerBodyFunction( "bar", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(bar); + AST().Functions().Add(bar); // TODO(dsinclair): Update to run the namer transform when available. @@ -792,7 +792,7 @@ TEST_F(InspectorGetEntryPointTest, DefaultWorkgroupSize) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto result = inspector()->GetEntryPoints(); ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); @@ -811,7 +811,7 @@ TEST_F(InspectorGetEntryPointTest, NonDefaultWorkgroupSize) { create(ast::PipelineStage::kCompute), create(8u, 2u, 1u), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto result = inspector()->GetEntryPoints(); ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); @@ -826,14 +826,14 @@ TEST_F(InspectorGetEntryPointTest, NonDefaultWorkgroupSize) { TEST_F(InspectorGetEntryPointTest, NoInOutVariables) { auto* func = MakeEmptyBodyFunction("func", {}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto result = inspector()->GetEntryPoints(); ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); @@ -851,7 +851,7 @@ TEST_F(InspectorGetEntryPointTest, EntryPointInOutVariables) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -875,14 +875,14 @@ TEST_F(InspectorGetEntryPointTest, FunctionInOutVariables) { auto* func = MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -906,14 +906,14 @@ TEST_F(InspectorGetEntryPointTest, RepeatedInOutVariables) { auto* func = MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* foo = MakeInOutVariableCallerBodyFunction( "foo", "func", {{"in_var", "out_var"}}, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -940,7 +940,7 @@ TEST_F(InspectorGetEntryPointTest, EntryPointMultipleInOutVariables) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -970,14 +970,14 @@ TEST_F(InspectorGetEntryPointTest, FunctionMultipleInOutVariables) { auto* func = MakeInOutVariableBodyFunction( "func", {{"in_var", "out_var"}, {"in2_var", "out2_var"}}, {}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1011,14 +1011,14 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutVariables) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto* bar = MakeInOutVariableBodyFunction( "bar", {{"in2_var", "out_var"}}, ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(bar); + AST().Functions().Add(bar); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1057,21 +1057,21 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) { auto* func = MakeInOutVariableBodyFunction("func", {{"in2_var", "out2_var"}}, {}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* foo = MakeInOutVariableCallerBodyFunction( "foo", "func", {{"in_var", "out_var"}}, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto* bar = MakeCallerBodyFunction( "bar", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(bar); + AST().Functions().Add(bar); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1114,23 +1114,23 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) { } TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) { - mod->AST().AddGlobalVariable( + AST().AddGlobalVariable( Var("in_var", ast::StorageClass::kInput, ty.u32(), nullptr, ast::VariableDecorationList{ create(ast::Builtin::kPosition)})); - mod->AST().AddGlobalVariable( + AST().AddGlobalVariable( Var("out_var", ast::StorageClass::kOutput, ty.u32(), nullptr, ast::VariableDecorationList{create(0)})); auto* func = MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1162,7 +1162,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_NoFunctions) { // TODO(rharrison): Reenable once GetRemappedNameForEntryPoint isn't a pass // through TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_NoEntryPoints) { - mod->AST().Functions().Add(MakeEmptyBodyFunction("foo", {})); + AST().Functions().Add(MakeEmptyBodyFunction("foo", {})); auto result = inspector()->GetRemappedNameForEntryPoint("foo"); ASSERT_TRUE(inspector()->has_error()); @@ -1177,7 +1177,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_OneEntryPoint) { "foo", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); // TODO(dsinclair): Update to run the namer transform when available. @@ -1195,7 +1195,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, "foo", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); // TODO(dsinclair): Update to run the namer transform when available. @@ -1203,7 +1203,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, "bar", ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(bar); + AST().Functions().Add(bar); { auto result = inspector()->GetRemappedNameForEntryPoint("foo"); @@ -1321,14 +1321,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) { auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}}); - mod->AST().Functions().Add(ub_func); + AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1349,14 +1349,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}}); - mod->AST().Functions().Add(ub_func); + AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1374,14 +1374,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) { auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}}); - mod->AST().Functions().Add(ub_func); + AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1403,14 +1403,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) { auto* ub_func = MakeStructVariableReferenceBodyFunction( "ub_func", "foo_ub", {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}}); - mod->AST().Functions().Add(ub_func); + AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1436,7 +1436,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { const std::string& var_name) { auto* ub_func = MakeStructVariableReferenceBodyFunction( func_name, var_name, {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}}); - mod->AST().Functions().Add(ub_func); + AST().Functions().Add(ub_func); }; AddReferenceFunc("ub_foo_func", "ub_foo"); AddReferenceFunc("ub_bar_func", "ub_bar"); @@ -1454,7 +1454,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1484,14 +1484,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}}); - mod->AST().Functions().Add(ub_func); + AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1513,14 +1513,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) { auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1542,14 +1542,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { auto* sb_func = MakeStructVariableReferenceBodyFunction( "sb_func", "foo_sb", {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1575,7 +1575,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { const std::string& var_name) { auto* sb_func = MakeStructVariableReferenceBodyFunction( func_name, var_name, {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); }; AddReferenceFunc("sb_foo_func", "sb_foo"); AddReferenceFunc("sb_bar_func", "sb_bar"); @@ -1596,7 +1596,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1626,14 +1626,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1655,14 +1655,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1684,14 +1684,14 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1709,14 +1709,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1744,7 +1744,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, const std::string& var_name) { auto* sb_func = MakeStructVariableReferenceBodyFunction( func_name, var_name, {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); }; AddReferenceFunc("sb_foo_func", "sb_foo"); AddReferenceFunc("sb_bar_func", "sb_bar"); @@ -1765,7 +1765,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1796,14 +1796,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1827,14 +1827,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1857,14 +1857,14 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) { auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb", {{0, ty.i32()}}); - mod->AST().Functions().Add(sb_func); + AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1886,7 +1886,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1903,7 +1903,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) { "ep_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1922,14 +1922,14 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) { auto* foo_func = MakeSamplerReferenceBodyFunction( "foo_func", "foo_texture", "foo_sampler", "foo_coords", ty.f32(), {}); - mod->AST().Functions().Add(foo_func); + AST().Functions().Add(foo_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "foo_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1953,7 +1953,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1973,7 +1973,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1995,7 +1995,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2012,7 +2012,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) { "ep_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2032,14 +2032,14 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) { auto* foo_func = MakeComparisonSamplerReferenceBodyFunction( "foo_func", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32(), {}); - mod->AST().Functions().Add(foo_func); + AST().Functions().Add(foo_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "foo_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(ep_func); + AST().Functions().Add(ep_func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2063,7 +2063,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2083,7 +2083,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2098,7 +2098,7 @@ TEST_F(InspectorGetSampledTextureResourceBindingsTest, Empty) { "foo", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto result = inspector()->GetSampledTextureResourceBindings("foo"); ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); @@ -2121,7 +2121,7 @@ TEST_P(InspectorGetSampledTextureResourceBindingsTestWithParam, textureSample) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2212,7 +2212,7 @@ TEST_P(InspectorGetSampledArrayTextureResourceBindingsTestWithParam, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2283,7 +2283,7 @@ TEST_P(InspectorGetMultisampledTextureResourceBindingsTestWithParam, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2338,7 +2338,7 @@ TEST_F(InspectorGetMultisampledArrayTextureResourceBindingsTest, Empty) { "foo", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(foo); + AST().Functions().Add(foo); auto result = inspector()->GetSampledTextureResourceBindings("foo"); ASSERT_FALSE(inspector()->has_error()) << inspector()->error(); @@ -2363,7 +2363,7 @@ TEST_P(InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/program_test.cc b/src/program_test.cc index a7586632be..6659ae37e6 100644 --- a/src/program_test.cc +++ b/src/program_test.cc @@ -31,7 +31,7 @@ namespace { using ProgramTest = ast::TestHelper; TEST_F(ProgramTest, Creation) { - EXPECT_EQ(mod->AST().Functions().size(), 0u); + EXPECT_EQ(AST().Functions().size(), 0u); } TEST_F(ProgramTest, ToStrEmitsPreambleAndPostamble) { @@ -41,70 +41,70 @@ TEST_F(ProgramTest, ToStrEmitsPreambleAndPostamble) { } TEST_F(ProgramTest, IsValid_Empty) { - EXPECT_TRUE(mod->IsValid()); + EXPECT_TRUE(IsValid()); } TEST_F(ProgramTest, IsValid_GlobalVariable) { auto* var = Var("var", ast::StorageClass::kInput, ty.f32()); - mod->AST().AddGlobalVariable(var); - EXPECT_TRUE(mod->IsValid()); + AST().AddGlobalVariable(var); + EXPECT_TRUE(IsValid()); } TEST_F(ProgramTest, IsValid_Null_GlobalVariable) { - mod->AST().AddGlobalVariable(nullptr); - EXPECT_FALSE(mod->IsValid()); + AST().AddGlobalVariable(nullptr); + EXPECT_FALSE(IsValid()); } TEST_F(ProgramTest, IsValid_Invalid_GlobalVariable) { auto* var = Var("var", ast::StorageClass::kInput, nullptr); - mod->AST().AddGlobalVariable(var); - EXPECT_FALSE(mod->IsValid()); + AST().AddGlobalVariable(var); + EXPECT_FALSE(IsValid()); } TEST_F(ProgramTest, IsValid_Alias) { auto* alias = ty.alias("alias", ty.f32()); - mod->AST().AddConstructedType(alias); - EXPECT_TRUE(mod->IsValid()); + AST().AddConstructedType(alias); + EXPECT_TRUE(IsValid()); } TEST_F(ProgramTest, IsValid_Null_Alias) { - mod->AST().AddConstructedType(nullptr); - EXPECT_FALSE(mod->IsValid()); + AST().AddConstructedType(nullptr); + EXPECT_FALSE(IsValid()); } TEST_F(ProgramTest, IsValid_Struct) { auto* st = ty.struct_("name", {}); auto* alias = ty.alias("name", st); - mod->AST().AddConstructedType(alias); - EXPECT_TRUE(mod->IsValid()); + AST().AddConstructedType(alias); + EXPECT_TRUE(IsValid()); } TEST_F(ProgramTest, IsValid_Struct_EmptyName) { auto* st = ty.struct_("", {}); auto* alias = ty.alias("name", st); - mod->AST().AddConstructedType(alias); - EXPECT_FALSE(mod->IsValid()); + AST().AddConstructedType(alias); + EXPECT_FALSE(IsValid()); } TEST_F(ProgramTest, IsValid_Function) { auto* func = Func("main", ast::VariableList(), ty.f32(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); - EXPECT_TRUE(mod->IsValid()); + AST().Functions().Add(func); + EXPECT_TRUE(IsValid()); } TEST_F(ProgramTest, IsValid_Null_Function) { - mod->AST().Functions().Add(nullptr); - EXPECT_FALSE(mod->IsValid()); + AST().Functions().Add(nullptr); + EXPECT_FALSE(IsValid()); } TEST_F(ProgramTest, IsValid_Invalid_Function) { auto* func = Func("main", ast::VariableList{}, nullptr, ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); - EXPECT_FALSE(mod->IsValid()); + AST().Functions().Add(func); + EXPECT_FALSE(IsValid()); } } // namespace diff --git a/src/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc index 7b327da33a..7860926054 100644 --- a/src/type/storage_texture_type_test.cc +++ b/src/type/storage_texture_type_test.cc @@ -80,8 +80,8 @@ TEST_F(StorageTextureTest, TypeName) { } TEST_F(StorageTextureTest, F32) { - Type* s = mod->create(TextureDimension::k2dArray, - ImageFormat::kRgba32Float); + Type* s = create(TextureDimension::k2dArray, + ImageFormat::kRgba32Float); TypeDeterminer td(mod); ASSERT_TRUE(td.Determine()) << td.error(); @@ -91,8 +91,8 @@ TEST_F(StorageTextureTest, F32) { } TEST_F(StorageTextureTest, U32) { - Type* s = mod->create(TextureDimension::k2dArray, - ImageFormat::kRg32Uint); + Type* s = create(TextureDimension::k2dArray, + ImageFormat::kRg32Uint); TypeDeterminer td(mod); ASSERT_TRUE(td.Determine()) << td.error(); @@ -102,8 +102,8 @@ TEST_F(StorageTextureTest, U32) { } TEST_F(StorageTextureTest, I32) { - Type* s = mod->create(TextureDimension::k2dArray, - ImageFormat::kRgba32Sint); + Type* s = create(TextureDimension::k2dArray, + ImageFormat::kRgba32Sint); TypeDeterminer td(mod); ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/type/test_helper.h b/src/type/test_helper.h index ac0a328a6a..c1006bbf5e 100644 --- a/src/type/test_helper.h +++ b/src/type/test_helper.h @@ -35,7 +35,7 @@ class TestHelperBase : public BASE, public ast::BuilderWithProgram { /// @param s the string to demangle /// @returns the demangled string std::string demangle(const std::string& s) { - return demanger.Demangle(mod->Symbols(), s); + return demanger.Demangle(Symbols(), s); } /// A demangler diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 3e856e9f04..e2035c3d4a 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -292,7 +292,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call) { ast::VariableList params; auto* func = Func("my_func", params, ty.f32(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -319,14 +319,14 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) { create(), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func_main); + AST().Functions().Add(func_main); auto* func = Func("func", params0, ty.f32(), ast::StatementList{ create(), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_FALSE(td()->Determine()) << td()->error(); EXPECT_EQ(td()->error(), @@ -350,7 +350,7 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) { ast::VariableDecorationList{}); auto* init = var->constructor(); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); ASSERT_NE(init->result_type(), nullptr); @@ -367,7 +367,7 @@ TEST_F(TypeDeterminerTest, Expr_Error_Unknown) { TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { auto* idx = Expr(2); auto* var = Var("my_var", ast::StorageClass::kFunction, ty.array()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -383,8 +383,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { auto* aary = ty.alias("myarrty", ty.array()); - mod->AST().AddGlobalVariable( - Var("my_var", ast::StorageClass::kFunction, aary)); + AST().AddGlobalVariable(Var("my_var", ast::StorageClass::kFunction, aary)); EXPECT_TRUE(td()->Determine()); @@ -399,7 +398,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { auto* var = Const("my_var", ast::StorageClass::kFunction, ty.array()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -412,7 +411,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.mat2x3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -428,7 +427,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.mat2x3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -444,7 +443,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -472,7 +471,7 @@ TEST_F(TypeDeterminerTest, Expr_Call) { ast::VariableList params; auto* func = Func("my_func", params, ty.f32(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -487,7 +486,7 @@ TEST_F(TypeDeterminerTest, Expr_Call_WithParams) { ast::VariableList params; auto* func = Func("my_func", params, ty.f32(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -541,7 +540,7 @@ TEST_F(TypeDeterminerTest, Expr_Constructor_Type) { TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -554,8 +553,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) { } TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) { - mod->AST().AddGlobalVariable( - Const("my_var", ast::StorageClass::kNone, ty.f32())); + AST().AddGlobalVariable(Const("my_var", ast::StorageClass::kNone, ty.f32())); EXPECT_TRUE(td()->Determine()); @@ -626,7 +624,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { TEST_F(TypeDeterminerTest, Expr_Identifier_Function) { auto* func = Func("my_func", ast::VariableList{}, ty.f32(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -649,11 +647,11 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32()); auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32()); - mod->AST().AddGlobalVariable(in_var); - mod->AST().AddGlobalVariable(out_var); - mod->AST().AddGlobalVariable(sb_var); - mod->AST().AddGlobalVariable(wg_var); - mod->AST().AddGlobalVariable(priv_var); + AST().AddGlobalVariable(in_var); + AST().AddGlobalVariable(out_var); + AST().AddGlobalVariable(sb_var); + AST().AddGlobalVariable(wg_var); + AST().AddGlobalVariable(priv_var); auto* func = Func( "my_func", ast::VariableList{}, ty.f32(), @@ -665,7 +663,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -686,11 +684,11 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32()); auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32()); - mod->AST().AddGlobalVariable(in_var); - mod->AST().AddGlobalVariable(out_var); - mod->AST().AddGlobalVariable(sb_var); - mod->AST().AddGlobalVariable(wg_var); - mod->AST().AddGlobalVariable(priv_var); + AST().AddGlobalVariable(in_var); + AST().AddGlobalVariable(out_var); + AST().AddGlobalVariable(sb_var); + AST().AddGlobalVariable(wg_var); + AST().AddGlobalVariable(priv_var); auto* func = Func( "my_func", ast::VariableList{}, ty.f32(), @@ -702,7 +700,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* func2 = Func( "func", ast::VariableList{}, ty.f32(), @@ -711,7 +709,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func2); + AST().Functions().Add(func2); // Register the function EXPECT_TRUE(td()->Determine()); @@ -736,7 +734,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* v = Var("var", ast::StorageClass::kFunction, ty.f32()); td()->RegisterVariableForTesting(v); @@ -756,7 +754,7 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { auto* st = ty.struct_("S", strct); auto* var = Var("my_struct", ast::StorageClass::kNone, st); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -779,7 +777,7 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { auto* alias = ty.alias("alias", st); auto* var = Var("my_struct", ast::StorageClass::kNone, alias); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -794,7 +792,7 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) { auto* var = Var("my_vec", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -808,7 +806,7 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) { TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { auto* var = Var("my_vec", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -858,7 +856,7 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { auto* stA = ty.struct_("A", strctA); auto* var = Var("c", ast::StorageClass::kNone, stA); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); auto* mem = MemberAccessor( @@ -878,7 +876,7 @@ TEST_P(Expr_Binary_BitwiseTest, Scalar) { auto* var = Var("val", ast::StorageClass::kNone, ty.i32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -894,7 +892,7 @@ TEST_P(Expr_Binary_BitwiseTest, Vector) { auto* var = Var("val", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -924,7 +922,7 @@ TEST_P(Expr_Binary_LogicalTest, Scalar) { auto* var = Var("val", ast::StorageClass::kNone, ty.bool_()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -940,7 +938,7 @@ TEST_P(Expr_Binary_LogicalTest, Vector) { auto* var = Var("val", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -964,7 +962,7 @@ TEST_P(Expr_Binary_CompareTest, Scalar) { auto* var = Var("val", ast::StorageClass::kNone, ty.i32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -980,7 +978,7 @@ TEST_P(Expr_Binary_CompareTest, Vector) { auto* var = Var("val", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1005,7 +1003,7 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) { auto* var = Var("val", ast::StorageClass::kNone, ty.i32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1019,8 +1017,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) { auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32()); auto* vector = Var("vector", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(scalar); - mod->AST().AddGlobalVariable(vector); + AST().AddGlobalVariable(scalar); + AST().AddGlobalVariable(vector); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1036,8 +1034,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) { auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32()); auto* vector = Var("vector", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(scalar); - mod->AST().AddGlobalVariable(vector); + AST().AddGlobalVariable(scalar); + AST().AddGlobalVariable(vector); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1052,7 +1050,7 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) { auto* vector = Var("vector", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(vector); + AST().AddGlobalVariable(vector); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1068,8 +1066,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32()); auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3()); - mod->AST().AddGlobalVariable(scalar); - mod->AST().AddGlobalVariable(matrix); + AST().AddGlobalVariable(scalar); + AST().AddGlobalVariable(matrix); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1088,8 +1086,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) { auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32()); auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3()); - mod->AST().AddGlobalVariable(scalar); - mod->AST().AddGlobalVariable(matrix); + AST().AddGlobalVariable(scalar); + AST().AddGlobalVariable(matrix); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1108,8 +1106,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) { auto* vector = Var("vector", ast::StorageClass::kNone, ty.vec3()); auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3()); - mod->AST().AddGlobalVariable(vector); - mod->AST().AddGlobalVariable(matrix); + AST().AddGlobalVariable(vector); + AST().AddGlobalVariable(matrix); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1125,8 +1123,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) { auto* vector = Var("vector", ast::StorageClass::kNone, ty.vec3()); auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3()); - mod->AST().AddGlobalVariable(vector); - mod->AST().AddGlobalVariable(matrix); + AST().AddGlobalVariable(vector); + AST().AddGlobalVariable(matrix); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1142,8 +1140,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) { TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) { auto* matrix1 = Var("mat3x4", ast::StorageClass::kNone, ty.mat3x4()); auto* matrix2 = Var("mat4x3", ast::StorageClass::kNone, ty.mat4x3()); - mod->AST().AddGlobalVariable(matrix1); - mod->AST().AddGlobalVariable(matrix2); + AST().AddGlobalVariable(matrix1); + AST().AddGlobalVariable(matrix2); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1165,7 +1163,7 @@ TEST_P(IntrinsicDerivativeTest, Scalar) { auto* var = Var("ident", ast::StorageClass::kNone, ty.f32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -1181,7 +1179,7 @@ TEST_P(IntrinsicDerivativeTest, Vector) { auto* var = Var("ident", ast::StorageClass::kNone, ty.vec4()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -1209,8 +1207,8 @@ TEST_P(IntrinsicDerivativeTest, ToomManyParams) { auto* var1 = Var("ident1", ast::StorageClass::kNone, ty.vec4()); auto* var2 = Var("ident2", ast::StorageClass::kNone, ty.vec4()); - mod->AST().AddGlobalVariable(var1); - mod->AST().AddGlobalVariable(var2); + AST().AddGlobalVariable(var1); + AST().AddGlobalVariable(var2); EXPECT_TRUE(td()->Determine()); @@ -1236,7 +1234,7 @@ TEST_P(Intrinsic, Test) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call(name, "my_var"); @@ -1257,7 +1255,7 @@ TEST_P(Intrinsic_FloatMethod, Vector) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call(name, "my_var"); @@ -1277,7 +1275,7 @@ TEST_P(Intrinsic_FloatMethod, Scalar) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call(name, "my_var"); @@ -1293,7 +1291,7 @@ TEST_P(Intrinsic_FloatMethod, MissingParam) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call(name); @@ -1308,7 +1306,7 @@ TEST_P(Intrinsic_FloatMethod, TooManyParams) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call(name, "my_var", "my_var"); @@ -1370,7 +1368,7 @@ class Intrinsic_TextureOperation type::Type* type, ast::ExpressionList* call_params) { auto* var = Var(name, ast::StorageClass::kNone, type); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); call_params->push_back(Expr(name)); } @@ -1393,7 +1391,7 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) { auto* coords_type = get_coords_type(dim, ty.i32()); - type::Type* texture_type = mod->create(dim, format); + type::Type* texture_type = create(dim, format); ast::ExpressionList call_params; @@ -1502,7 +1500,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(TypeDeterminerTest, Intrinsic_Dot) { auto* var = Var("my_var", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call("dot", "my_var", "my_var"); @@ -1518,8 +1516,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select) { auto* bool_var = Var( // source "bool_var", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); - mod->AST().AddGlobalVariable(bool_var); + AST().AddGlobalVariable(var); + AST().AddGlobalVariable(bool_var); auto* expr = Call("select", "my_var", "my_var", "bool_var"); @@ -1535,7 +1533,7 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select) { TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) { auto* var = Var("v", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call("select", "v"); @@ -1549,7 +1547,7 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) { TEST_F(TypeDeterminerTest, Intrinsic_Select_TooManyParams) { auto* var = Var("v", ast::StorageClass::kNone, ty.vec3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call("select", "v", "v", "v", "v"); @@ -1566,7 +1564,7 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { auto* var = Var("ident", ast::StorageClass::kNone, ty.vec4()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); EXPECT_TRUE(td()->Determine()); @@ -1589,7 +1587,7 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) { auto* func = Func("func", ast::VariableList{}, ty.i32(), ast::StatementList{stmt}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_EQ(var->storage_class(), ast::StorageClass::kFunction); @@ -1601,7 +1599,7 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) { auto* func = Func("func", ast::VariableList{}, ty.i32(), ast::StatementList{stmt}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_EQ(var->storage_class(), ast::StorageClass::kNone); @@ -1614,7 +1612,7 @@ TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) { auto* func = Func("func", ast::VariableList{}, ty.i32(), ast::StatementList{stmt}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_FALSE(td()->Determine()); EXPECT_EQ(td()->error(), @@ -2652,7 +2650,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(TypeDeterminerTest, ImportData_GLSL_Determinant) { auto* var = Var("var", ast::StorageClass::kFunction, ty.mat3x3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2671,7 +2669,7 @@ TEST_P(ImportData_Matrix_OneParam_Test, Error_Float) { auto param = GetParam(); auto* var = Var("var", ast::StorageClass::kFunction, ty.f32()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2696,7 +2694,7 @@ TEST_P(ImportData_Matrix_OneParam_Test, TooManyParams) { auto param = GetParam(); auto* var = Var("var", ast::StorageClass::kFunction, ty.mat3x3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2760,39 +2758,34 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func_b); - mod->AST().Functions().Add(func_c); - mod->AST().Functions().Add(func_a); - mod->AST().Functions().Add(ep_1); - mod->AST().Functions().Add(ep_2); + AST().Functions().Add(func_b); + AST().Functions().Add(func_c); + AST().Functions().Add(func_a); + AST().Functions().Add(ep_1); + AST().Functions().Add(ep_2); - mod->AST().AddGlobalVariable( - Var("first", ast::StorageClass::kPrivate, ty.f32())); - mod->AST().AddGlobalVariable( - Var("second", ast::StorageClass::kPrivate, ty.f32())); - mod->AST().AddGlobalVariable( - Var("call_a", ast::StorageClass::kPrivate, ty.f32())); - mod->AST().AddGlobalVariable( - Var("call_b", ast::StorageClass::kPrivate, ty.f32())); - mod->AST().AddGlobalVariable( - Var("call_c", ast::StorageClass::kPrivate, ty.f32())); + AST().AddGlobalVariable(Var("first", ast::StorageClass::kPrivate, ty.f32())); + AST().AddGlobalVariable(Var("second", ast::StorageClass::kPrivate, ty.f32())); + AST().AddGlobalVariable(Var("call_a", ast::StorageClass::kPrivate, ty.f32())); + AST().AddGlobalVariable(Var("call_b", ast::StorageClass::kPrivate, ty.f32())); + AST().AddGlobalVariable(Var("call_c", ast::StorageClass::kPrivate, ty.f32())); // Register the functions and calculate the callers ASSERT_TRUE(td()->Determine()) << td()->error(); const auto& b_eps = func_b->ancestor_entry_points(); ASSERT_EQ(2u, b_eps.size()); - EXPECT_EQ(mod->Symbols().Register("ep_1"), b_eps[0]); - EXPECT_EQ(mod->Symbols().Register("ep_2"), b_eps[1]); + EXPECT_EQ(Symbols().Register("ep_1"), b_eps[0]); + EXPECT_EQ(Symbols().Register("ep_2"), b_eps[1]); const auto& a_eps = func_a->ancestor_entry_points(); ASSERT_EQ(1u, a_eps.size()); - EXPECT_EQ(mod->Symbols().Register("ep_1"), a_eps[0]); + EXPECT_EQ(Symbols().Register("ep_1"), a_eps[0]); const auto& c_eps = func_c->ancestor_entry_points(); ASSERT_EQ(2u, c_eps.size()); - EXPECT_EQ(mod->Symbols().Register("ep_1"), c_eps[0]); - EXPECT_EQ(mod->Symbols().Register("ep_2"), c_eps[1]); + EXPECT_EQ(Symbols().Register("ep_1"), c_eps[0]); + EXPECT_EQ(Symbols().Register("ep_2"), c_eps[1]); EXPECT_TRUE(ep_1->ancestor_entry_points().empty()); EXPECT_TRUE(ep_2->ancestor_entry_points().empty()); diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc index 12c7b1a609..22e2986830 100644 --- a/src/validator/validator_control_block_test.cc +++ b/src/validator/validator_control_block_test.cc @@ -375,7 +375,7 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) { create(var), create(Expr("a"), body), }); - mod->AST().AddConstructedType(my_int); + AST().AddConstructedType(my_int); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index f8240e1572..1526dcba47 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -49,7 +49,7 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -68,7 +68,7 @@ TEST_F(ValidateFunctionTest, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -89,7 +89,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { create(var), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -105,7 +105,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) { auto* func = Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.i32(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -127,14 +127,13 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); - EXPECT_TRUE(td()->DetermineFunctions(mod->AST().Functions())) - << td()->error(); + EXPECT_TRUE(td()->DetermineFunctions(AST().Functions())) << td()->error(); ValidatorImpl& v = Build(); - EXPECT_TRUE(v.ValidateFunctions(mod->AST().Functions())) << v.error(); + EXPECT_TRUE(v.ValidateFunctions(AST().Functions())) << v.error(); } TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { @@ -145,7 +144,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { Source{Source::Location{12, 34}}, Expr(2)), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -166,7 +165,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) { Source{Source::Location{12, 34}}, Expr(2)), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -195,8 +194,8 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); - mod->AST().Functions().Add(func_copy); + AST().Functions().Add(func); + AST().Functions().Add(func_copy); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -218,7 +217,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) { create(), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func0); + AST().Functions().Add(func0); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -242,7 +241,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { create(Expr(2)), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func0); + AST().Functions().Add(func0); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -265,7 +264,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) { create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -290,7 +289,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) { create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -315,7 +314,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) { create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -337,7 +336,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -353,7 +352,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) { create(), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index dba51971c4..2cd648f758 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -324,21 +324,20 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) { TEST_F(ValidatorTest, GlobalVariableWithStorageClass_Pass) { // var gloabl_var: f32; - mod->AST().AddGlobalVariable(Var( - Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kInput, - ty.f32(), nullptr, ast::VariableDecorationList{})); + AST().AddGlobalVariable(Var(Source{Source::Location{12, 34}}, "global_var", + ast::StorageClass::kInput, ty.f32(), nullptr, + ast::VariableDecorationList{})); ValidatorImpl& v = Build(); - EXPECT_TRUE(v.ValidateGlobalVariables(mod->AST().GlobalVariables())) - << v.error(); + EXPECT_TRUE(v.ValidateGlobalVariables(AST().GlobalVariables())) << v.error(); } TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) { // var gloabl_var: f32; - mod->AST().AddGlobalVariable(Var( - Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kNone, - ty.f32(), nullptr, ast::VariableDecorationList{})); + AST().AddGlobalVariable(Var(Source{Source::Location{12, 34}}, "global_var", + ast::StorageClass::kNone, ty.f32(), nullptr, + ast::VariableDecorationList{})); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -350,9 +349,9 @@ TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) { TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) { // const gloabl_var: f32; - mod->AST().AddGlobalVariable(Const( - Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kInput, - ty.f32(), nullptr, ast::VariableDecorationList{})); + AST().AddGlobalVariable(Const(Source{Source::Location{12, 34}}, "global_var", + ast::StorageClass::kInput, ty.f32(), nullptr, + ast::VariableDecorationList{})); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -365,9 +364,9 @@ TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) { TEST_F(ValidatorTest, GlobalConstNoStorageClass_Pass) { // const gloabl_var: f32; - mod->AST().AddGlobalVariable(Const( - Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kNone, - ty.f32(), nullptr, ast::VariableDecorationList{})); + AST().AddGlobalVariable(Const(Source{Source::Location{12, 34}}, "global_var", + ast::StorageClass::kNone, ty.f32(), nullptr, + ast::VariableDecorationList{})); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -380,9 +379,9 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { // fn my_func() -> f32 { // not_global_var = 3.14f; // } - mod->AST().AddGlobalVariable(Var("global_var", ast::StorageClass::kPrivate, - ty.f32(), Expr(2.1f), - ast::VariableDecorationList{})); + AST().AddGlobalVariable(Var("global_var", ast::StorageClass::kPrivate, + ty.f32(), Expr(2.1f), + ast::VariableDecorationList{})); SetSource(Source{Source::Location{12, 34}}); auto* lhs = Expr("not_global_var"); @@ -394,7 +393,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { Source{Source::Location{12, 34}}, lhs, rhs), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ValidatorImpl& v = Build(); @@ -409,9 +408,9 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { // return; // } - mod->AST().AddGlobalVariable(Var("global_var", ast::StorageClass::kPrivate, - ty.f32(), Expr(2.1f), - ast::VariableDecorationList{})); + AST().AddGlobalVariable(Var("global_var", ast::StorageClass::kPrivate, + ty.f32(), Expr(2.1f), + ast::VariableDecorationList{})); auto* func = Func( "my_func", ast::VariableList{}, ty.void_(), @@ -423,7 +422,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -502,17 +501,16 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) { // var global_var1 : i32 = 0; auto* var0 = Var("global_var0", ast::StorageClass::kPrivate, ty.f32(), Expr(0.1f), ast::VariableDecorationList{}); - mod->AST().AddGlobalVariable(var0); + AST().AddGlobalVariable(var0); auto* var1 = Var(Source{Source::Location{12, 34}}, "global_var1", ast::StorageClass::kPrivate, ty.f32(), Expr(0), ast::VariableDecorationList{}); - mod->AST().AddGlobalVariable(var1); + AST().AddGlobalVariable(var1); ValidatorImpl& v = Build(); - EXPECT_TRUE(v.ValidateGlobalVariables(mod->AST().GlobalVariables())) - << v.error(); + EXPECT_TRUE(v.ValidateGlobalVariables(AST().GlobalVariables())) << v.error(); } TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) { @@ -520,16 +518,16 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) { // var global_var : i32 = 0; auto* var0 = Var("global_var", ast::StorageClass::kPrivate, ty.f32(), Expr(0.1f), ast::VariableDecorationList{}); - mod->AST().AddGlobalVariable(var0); + AST().AddGlobalVariable(var0); auto* var1 = Var(Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kPrivate, ty.i32(), Expr(0), ast::VariableDecorationList{}); - mod->AST().AddGlobalVariable(var1); + AST().AddGlobalVariable(var1); ValidatorImpl& v = Build(); - EXPECT_FALSE(v.ValidateGlobalVariables(mod->AST().GlobalVariables())); + EXPECT_FALSE(v.ValidateGlobalVariables(AST().GlobalVariables())); EXPECT_EQ(v.error(), "12:34 v-0011: redeclared global identifier 'global_var'"); } @@ -570,7 +568,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { auto* global_var = Var("a", ast::StorageClass::kPrivate, ty.f32(), Expr(2.1f), ast::VariableDecorationList{}); - mod->AST().AddGlobalVariable(global_var); + AST().AddGlobalVariable(global_var); auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f), ast::VariableDecorationList{}); @@ -582,7 +580,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_TRUE(td()->DetermineFunction(func)) << td()->error(); @@ -612,7 +610,7 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_TRUE(td()->DetermineFunction(func)) << td()->error(); @@ -711,8 +709,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func0); - mod->AST().Functions().Add(func1); + AST().Functions().Add(func0); + AST().Functions().Add(func1); EXPECT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index b04aa9c319..b1b063bbbd 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -51,11 +51,11 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) { auto* struct_type = ty.struct_("Foo", st); - mod->AST().AddConstructedType(struct_type); + AST().AddConstructedType(struct_type); ValidatorImpl& v = Build(); - EXPECT_TRUE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes())); + EXPECT_TRUE(v.ValidateConstructedTypes(AST().ConstructedTypes())); } TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) { @@ -71,11 +71,11 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) { decos); auto* struct_type = ty.struct_("Foo", st); - mod->AST().AddConstructedType(struct_type); + AST().AddConstructedType(struct_type); ValidatorImpl& v = Build(); - EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes())); + EXPECT_FALSE(v.ValidateConstructedTypes(AST().ConstructedTypes())); EXPECT_EQ(v.error(), "v-0031: a struct containing a runtime-sized array must be " "in the 'storage' storage class: 'Foo'"); @@ -99,11 +99,11 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) { auto* struct_type = ty.struct_("Foo", st); - mod->AST().AddConstructedType(struct_type); + AST().AddConstructedType(struct_type); ValidatorImpl& v = Build(); - EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes())); + EXPECT_FALSE(v.ValidateConstructedTypes(AST().ConstructedTypes())); EXPECT_EQ(v.error(), "12:34 v-0015: runtime arrays may only appear as the last member " "of a struct"); @@ -125,11 +125,11 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) { ast::StructMemberList{Member("b", alias), Member("a", ty.u32())}, decos); auto* struct_type = ty.struct_("s", st); - mod->AST().AddConstructedType(struct_type); + AST().AddConstructedType(struct_type); ValidatorImpl& v = Build(); - EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes())); + EXPECT_FALSE(v.ValidateConstructedTypes(AST().ConstructedTypes())); EXPECT_EQ(v.error(), "v-0015: runtime arrays may only appear as the last member " "of a struct"); @@ -151,11 +151,11 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) { ast::StructMemberList{Member("a", ty.u32()), Member("b", alias)}, decos); auto* struct_type = ty.struct_("s", st); - mod->AST().AddConstructedType(struct_type); + AST().AddConstructedType(struct_type); ValidatorImpl& v = Build(); - EXPECT_TRUE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes())); + EXPECT_TRUE(v.ValidateConstructedTypes(AST().ConstructedTypes())); } TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) { @@ -172,7 +172,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -197,7 +197,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) { create(), }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* main = Func("main", ast::VariableList{}, ty.void_(), @@ -207,7 +207,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(main); + AST().Functions().Add(main); EXPECT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index acf05d9f50..0067d408b1 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -507,7 +507,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { auto* func = Func("foo", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ast::ExpressionList params; params.push_back(create(ast::BinaryOp::kLogicalAnd, diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc index efa34d3d41..5cb93dcda1 100644 --- a/src/writer/hlsl/generator_impl_call_test.cc +++ b/src/writer/hlsl/generator_impl_call_test.cc @@ -34,7 +34,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { auto* func = Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -47,7 +47,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { auto* func = Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -60,7 +60,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) { auto* func = Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); diff --git a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc index f5890fb130..800ce5bf55 100644 --- a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc +++ b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc @@ -57,8 +57,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("vtx_main", ast::VariableList{}, ty.f32(), @@ -70,7 +70,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); std::unordered_set globals; @@ -110,8 +110,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("vtx_main", ast::VariableList{}, ty.f32(), @@ -123,7 +123,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); std::unordered_set globals; @@ -163,8 +163,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("main", ast::VariableList{}, ty.f32(), @@ -176,7 +176,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); std::unordered_set globals; @@ -216,8 +216,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("main", ast::VariableList{}, ty.f32(), @@ -229,7 +229,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); std::unordered_set globals; @@ -266,8 +266,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("main", ast::VariableList{}, ty.f32(), @@ -279,7 +279,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); std::unordered_set globals; @@ -311,8 +311,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("main", ast::VariableList{}, ty.f32(), @@ -324,7 +324,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); std::unordered_set globals; @@ -364,8 +364,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, td.RegisterVariableForTesting(coord_var); td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(coord_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(depth_var); auto* func = Func("main", ast::VariableList{}, ty.void_(), @@ -377,7 +377,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); std::unordered_set globals; diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index 735367a415..ff489f8242 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -59,7 +59,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -80,7 +80,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -105,7 +105,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -128,7 +128,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -157,8 +157,8 @@ TEST_F(HlslGeneratorImplTest_Function, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("main", ast::VariableList{}, ty.void_(), @@ -169,7 +169,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -208,8 +208,8 @@ TEST_F(HlslGeneratorImplTest_Function, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("frag_main", ast::VariableList{}, ty.void_(), @@ -221,7 +221,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -262,8 +262,8 @@ TEST_F(HlslGeneratorImplTest_Function, td.RegisterVariableForTesting(coord_var); td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(coord_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(depth_var); auto* func = Func("frag_main", ast::VariableList{}, ty.void_(), @@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -310,7 +310,7 @@ TEST_F(HlslGeneratorImplTest_Function, }); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), MemberAccessor("coord", "x"), ast::VariableDecorationList{}); @@ -325,7 +325,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -358,10 +358,10 @@ TEST_F(HlslGeneratorImplTest_Function, create(1), }); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), create( @@ -378,7 +378,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -416,7 +416,7 @@ TEST_F(HlslGeneratorImplTest_Function, }); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), MemberAccessor("coord", "b"), ast::VariableDecorationList{}); @@ -431,7 +431,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -466,7 +466,7 @@ TEST_F(HlslGeneratorImplTest_Function, }); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), MemberAccessor("coord", "b"), ast::VariableDecorationList{}); @@ -481,7 +481,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -515,7 +515,7 @@ TEST_F(HlslGeneratorImplTest_Function, }); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* func = Func("frag_main", ast::VariableList{}, ty.void_(), @@ -528,7 +528,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -567,9 +567,9 @@ TEST_F( td.RegisterVariableForTesting(bar_var); td.RegisterVariableForTesting(val_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); - mod->AST().AddGlobalVariable(val_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(val_var); auto* sub_func = Func( "sub_func", @@ -582,7 +582,7 @@ TEST_F( }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); auto* func_1 = Func( "ep_1", ast::VariableList{}, ty.void_(), @@ -594,7 +594,7 @@ TEST_F( create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -635,7 +635,7 @@ TEST_F(HlslGeneratorImplTest_Function, td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(depth_var); auto* sub_func = Func( "sub_func", @@ -646,7 +646,7 @@ TEST_F(HlslGeneratorImplTest_Function, }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); auto* func_1 = Func("ep_1", ast::VariableList{}, ty.void_(), @@ -659,7 +659,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -701,8 +701,8 @@ TEST_F( td.RegisterVariableForTesting(coord_var); td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(coord_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(depth_var); auto* sub_func = Func( "sub_func", @@ -715,7 +715,7 @@ TEST_F( }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); auto* func_1 = Func("ep_1", ast::VariableList{}, ty.void_(), @@ -728,7 +728,7 @@ TEST_F( create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -768,7 +768,7 @@ TEST_F(HlslGeneratorImplTest_Function, td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* sub_func = Func( "sub_func", @@ -779,7 +779,7 @@ TEST_F(HlslGeneratorImplTest_Function, }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), Call("sub_func", 1.0f), ast::VariableDecorationList{}); @@ -794,7 +794,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -828,7 +828,7 @@ TEST_F(HlslGeneratorImplTest_Function, td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* sub_func = Func( "sub_func", @@ -839,7 +839,7 @@ TEST_F(HlslGeneratorImplTest_Function, }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), Call("sub_func", 1.0f), ast::VariableDecorationList{}); @@ -854,7 +854,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -883,7 +883,7 @@ TEST_F(HlslGeneratorImplTest_Function, }); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(bar_var); auto* list = create(ast::StatementList{ create(), @@ -902,7 +902,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -933,7 +933,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -956,7 +956,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -983,7 +983,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(2u, 4u, 6u), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -1008,7 +1008,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -1053,9 +1053,9 @@ TEST_F(HlslGeneratorImplTest_Function, create(0), }); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); td.RegisterVariableForTesting(data_var); - mod->AST().AddGlobalVariable(data_var); + AST().AddGlobalVariable(data_var); { auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), @@ -1071,7 +1071,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } { @@ -1088,7 +1088,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc index 5d075c1155..3ad837ba28 100644 --- a/src/writer/hlsl/generator_impl_import_test.cc +++ b/src/writer/hlsl/generator_impl_import_test.cc @@ -213,7 +213,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) { auto* expr = Call("determinant", "var"); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); // Register the global ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index c86bab893e..adeaee0f05 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { auto* s = ty.struct_("Str", strct); auto* str_var = Var("str", ast::StorageClass::kPrivate, s); - mod->AST().AddGlobalVariable(str_var); + AST().AddGlobalVariable(str_var); auto* expr = MemberAccessor("str", "mem"); @@ -79,7 +79,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = MemberAccessor("data", "b"); @@ -112,7 +112,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructDecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = MemberAccessor("data", "a"); @@ -149,9 +149,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* b_var = Var("b", ast::StorageClass::kPrivate, ty.mat2x3()); - mod->AST().AddGlobalVariable(b_var); + AST().AddGlobalVariable(b_var); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* lhs = MemberAccessor("data", "a"); auto* rhs = Expr("b"); @@ -197,7 +197,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* lhs = MemberAccessor("data", "a"); @@ -240,7 +240,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = MemberAccessor("data", "a"); @@ -282,7 +282,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = MemberAccessor("data", "a"); @@ -317,7 +317,7 @@ TEST_F( auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = MemberAccessor("data", "a"); @@ -353,7 +353,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = IndexAccessor( @@ -389,7 +389,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructDecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = IndexAccessor(MemberAccessor("data", "a"), Expr(2)); @@ -424,7 +424,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructDecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = IndexAccessor(MemberAccessor("data", "a"), @@ -459,7 +459,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* lhs = MemberAccessor("data", "b"); @@ -499,7 +499,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* lhs = IndexAccessor(MemberAccessor("data", "a"), Expr(2)); @@ -536,7 +536,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* lhs = MemberAccessor("data", "a"); @@ -573,7 +573,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = MemberAccessor("data", "b"); @@ -607,7 +607,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* s = ty.struct_("Data", str); auto* coord_var = Var("data", ast::StorageClass::kStorage, s); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* lhs = MemberAccessor("data", "b"); @@ -662,7 +662,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = @@ -711,7 +711,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); @@ -765,7 +765,7 @@ TEST_F( auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = MemberAccessor( @@ -817,7 +817,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* expr = IndexAccessor( @@ -869,7 +869,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* lhs = @@ -925,7 +925,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Var("data", ast::StorageClass::kStorage, pre_struct); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); td.RegisterVariableForTesting(coord_var); auto* lhs = MemberAccessor( diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index e183d100e0..da195eff95 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -30,7 +30,7 @@ using HlslGeneratorImplTest = TestHelper; TEST_F(HlslGeneratorImplTest, Generate) { auto* func = Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc index a8d08b8313..5c33043ce1 100644 --- a/src/writer/msl/generator_impl_call_test.cc +++ b/src/writer/msl/generator_impl_call_test.cc @@ -35,7 +35,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { auto* call = Call("my_func"); auto* func = Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -47,7 +47,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { auto* call = Call("my_func", "param1", "param2"); auto* func = Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -59,7 +59,7 @@ TEST_F(MslGeneratorImplTest, EmitStatement_Call) { auto* call = Call("my_func", "param1", "param2"); auto* func = Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); auto* expr = create(call); diff --git a/src/writer/msl/generator_impl_function_entry_point_data_test.cc b/src/writer/msl/generator_impl_function_entry_point_data_test.cc index 2cccf77c6f..e669d76c1f 100644 --- a/src/writer/msl/generator_impl_function_entry_point_data_test.cc +++ b/src/writer/msl/generator_impl_function_entry_point_data_test.cc @@ -58,8 +58,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -71,7 +71,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -106,8 +106,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -119,7 +119,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { create(ast::PipelineStage::kVertex), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -154,8 +154,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -167,7 +167,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -202,8 +202,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -215,7 +215,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -247,8 +247,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -260,7 +260,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -287,8 +287,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -300,7 +300,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -334,8 +334,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { td.RegisterVariableForTesting(coord_var); td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(coord_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(depth_var); auto body = ast::StatementList{create( Expr("depth"), MemberAccessor("coord", "x"))}; @@ -345,7 +345,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index a40cfb350d..025b00dcc1 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -62,7 +62,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -85,7 +85,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -112,7 +112,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -134,7 +134,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_NoReturn_Void) { ast::FunctionDecorationList{create( ast::PipelineStage::kFragment)}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -163,8 +163,8 @@ TEST_F(MslGeneratorImplTest, td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto* func = Func("main", ast::VariableList{}, ty.void_(), @@ -174,7 +174,7 @@ TEST_F(MslGeneratorImplTest, ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment)}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -212,8 +212,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { td.RegisterVariableForTesting(foo_var); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); auto body = ast::StatementList{ create(Expr("bar"), Expr("foo")), @@ -223,7 +223,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { ast::FunctionDecorationList{create( ast::PipelineStage::kFragment)}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -264,8 +264,8 @@ TEST_F(MslGeneratorImplTest, td.RegisterVariableForTesting(coord_var); td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(coord_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(depth_var); auto body = ast::StatementList{ create(Expr("depth"), @@ -278,7 +278,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -308,7 +308,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), MemberAccessor("coord", "x"), ast::VariableDecorationList{}); @@ -323,7 +323,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -350,7 +350,7 @@ TEST_F(MslGeneratorImplTest, auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadWrite, s); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr, @@ -359,7 +359,7 @@ TEST_F(MslGeneratorImplTest, td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), MemberAccessor("coord", "b"), ast::VariableDecorationList{}); @@ -374,7 +374,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -405,7 +405,7 @@ TEST_F(MslGeneratorImplTest, auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadOnly, s); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr, @@ -413,7 +413,7 @@ TEST_F(MslGeneratorImplTest, create(1)}); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), MemberAccessor("coord", "b"), ast::VariableDecorationList{}); @@ -428,7 +428,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -469,9 +469,9 @@ TEST_F( td.RegisterVariableForTesting(bar_var); td.RegisterVariableForTesting(val_var); - mod->AST().AddGlobalVariable(foo_var); - mod->AST().AddGlobalVariable(bar_var); - mod->AST().AddGlobalVariable(val_var); + AST().AddGlobalVariable(foo_var); + AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(val_var); ast::VariableList params; params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32())); @@ -483,7 +483,7 @@ TEST_F( auto* sub_func = Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); body = ast::StatementList{ create(Expr("bar"), Call("sub_func", 1.0f)), @@ -495,7 +495,7 @@ TEST_F( create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -536,7 +536,7 @@ TEST_F(MslGeneratorImplTest, create(ast::Builtin::kFragDepth)}); td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(depth_var); ast::VariableList params; params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32())); @@ -547,7 +547,7 @@ TEST_F(MslGeneratorImplTest, }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); auto body = ast::StatementList{ create(Expr("depth"), Call("sub_func", 1.0f)), @@ -560,7 +560,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -602,8 +602,8 @@ TEST_F( td.RegisterVariableForTesting(coord_var); td.RegisterVariableForTesting(depth_var); - mod->AST().AddGlobalVariable(coord_var); - mod->AST().AddGlobalVariable(depth_var); + AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(depth_var); ast::VariableList params; params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32())); @@ -616,7 +616,7 @@ TEST_F( auto* sub_func = Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); body = ast::StatementList{ create(Expr("depth"), Call("sub_func", 1.0f)), @@ -628,7 +628,7 @@ TEST_F( create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -663,7 +663,7 @@ TEST_F(MslGeneratorImplTest, create(1)}); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); ast::VariableList params; params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32())); @@ -674,7 +674,7 @@ TEST_F(MslGeneratorImplTest, auto* sub_func = Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); ast::ExpressionList expr; expr.push_back(Expr(1.0f)); @@ -692,7 +692,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -722,7 +722,7 @@ TEST_F(MslGeneratorImplTest, auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadWrite, s); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr, @@ -730,7 +730,7 @@ TEST_F(MslGeneratorImplTest, create(1)}); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); ast::VariableList params; params.push_back( @@ -741,7 +741,7 @@ TEST_F(MslGeneratorImplTest, auto* sub_func = Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), Call("sub_func", 1.0f), ast::VariableDecorationList{}); @@ -756,7 +756,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -791,7 +791,7 @@ TEST_F(MslGeneratorImplTest, auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadOnly, s); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); auto* coord_var = Var("coord", ast::StorageClass::kStorage, &ac, nullptr, @@ -799,7 +799,7 @@ TEST_F(MslGeneratorImplTest, create(1)}); td.RegisterVariableForTesting(coord_var); - mod->AST().AddGlobalVariable(coord_var); + AST().AddGlobalVariable(coord_var); ast::VariableList params; params.push_back( @@ -810,7 +810,7 @@ TEST_F(MslGeneratorImplTest, auto* sub_func = Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(sub_func); + AST().Functions().Add(sub_func); ast::ExpressionList expr; expr.push_back(Expr(1.0f)); @@ -828,7 +828,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -861,7 +861,7 @@ TEST_F(MslGeneratorImplTest, ast::VariableDecorationList{create(1)}); td.RegisterVariableForTesting(bar_var); - mod->AST().AddGlobalVariable(bar_var); + AST().AddGlobalVariable(bar_var); auto* list = create(ast::StatementList{ create(), @@ -881,7 +881,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(func_1); + AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -914,7 +914,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -938,7 +938,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { }, ast::FunctionDecorationList{}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -986,9 +986,9 @@ TEST_F(MslGeneratorImplTest, ast::VariableDecorationList{create(0), create(0)}); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); td.RegisterVariableForTesting(data_var); - mod->AST().AddGlobalVariable(data_var); + AST().AddGlobalVariable(data_var); { auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), @@ -1004,7 +1004,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } { @@ -1018,7 +1018,7 @@ TEST_F(MslGeneratorImplTest, ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute)}); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc index 7ef1375341..1da58536f1 100644 --- a/src/writer/msl/generator_impl_import_test.cc +++ b/src/writer/msl/generator_impl_import_test.cc @@ -198,7 +198,7 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { auto* var = Var("var", ast::StorageClass::kFunction, ty.mat3x3()); - mod->AST().AddGlobalVariable(var); + AST().AddGlobalVariable(var); auto* expr = Call("determinant", "var"); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index 909bafd6f6..f3f85f26f0 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, Generate) { ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); GeneratorImpl& gen = Build(); diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index d9b52f0dd4..d904ca718b 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -100,9 +100,9 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) { auto* v_out = Var("my_out", ast::StorageClass::kOutput, ty.f32()); auto* v_wg = Var("my_wg", ast::StorageClass::kWorkgroup, ty.f32()); - mod->AST().AddGlobalVariable(v_in); - mod->AST().AddGlobalVariable(v_out); - mod->AST().AddGlobalVariable(v_wg); + AST().AddGlobalVariable(v_in); + AST().AddGlobalVariable(v_out); + AST().AddGlobalVariable(v_wg); spirv::Builder& b = Build(); @@ -149,9 +149,9 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { auto* v_out = Var("my_out", ast::StorageClass::kOutput, ty.f32()); auto* v_wg = Var("my_wg", ast::StorageClass::kWorkgroup, ty.f32()); - mod->AST().AddGlobalVariable(v_in); - mod->AST().AddGlobalVariable(v_out); - mod->AST().AddGlobalVariable(v_wg); + AST().AddGlobalVariable(v_in); + AST().AddGlobalVariable(v_out); + AST().AddGlobalVariable(v_wg); td.RegisterVariableForTesting(v_in); td.RegisterVariableForTesting(v_out); @@ -276,7 +276,7 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_FragDepth) { ast::VariableDecorationList{ create(ast::Builtin::kFragDepth), }); - mod->AST().AddGlobalVariable(fragdepth); + AST().AddGlobalVariable(fragdepth); auto* func = Func("main", ast::VariableList{}, ty.void_(), diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index d096957927..e7a086a2bf 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -242,10 +242,10 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { create(0), }); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); td.RegisterVariableForTesting(data_var); - mod->AST().AddGlobalVariable(data_var); + AST().AddGlobalVariable(data_var); { auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(), @@ -261,7 +261,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } { @@ -278,7 +278,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/spirv/builder_intrinsic_texture_test.cc b/src/writer/spirv/builder_intrinsic_texture_test.cc index 34536c2bf4..4035d3fc8c 100644 --- a/src/writer/spirv/builder_intrinsic_texture_test.cc +++ b/src/writer/spirv/builder_intrinsic_texture_test.cc @@ -4150,8 +4150,8 @@ TEST_P(IntrinsicTextureTest, Call) { TEST_P(IntrinsicTextureTest, ValidateSPIRV) { auto param = GetParam(); - mod->AST().AddGlobalVariable(param.buildTextureVariable(this)); - mod->AST().AddGlobalVariable(param.buildSamplerVariable(this)); + AST().AddGlobalVariable(param.buildTextureVariable(this)); + AST().AddGlobalVariable(param.buildSamplerVariable(this)); auto* call = create(Expr(param.function), param.args(this)); @@ -4165,7 +4165,7 @@ TEST_P(IntrinsicTextureTest, ValidateSPIRV) { create(ast::PipelineStage::kFragment), }); - mod->AST().Functions().Add(main); + AST().Functions().Add(main); ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index 5fc6caab4c..7f53616eed 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -191,10 +191,10 @@ TEST_F(WgslGeneratorImplTest, create(0), }); - mod->AST().AddConstructedType(s); + AST().AddConstructedType(s); td.RegisterVariableForTesting(data_var); - mod->AST().AddGlobalVariable(data_var); + AST().AddGlobalVariable(data_var); { auto* var = @@ -212,7 +212,7 @@ TEST_F(WgslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } { @@ -231,7 +231,7 @@ TEST_F(WgslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->AST().Functions().Add(func); + AST().Functions().Add(func); } ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc index 24782e0889..0e6ca83625 100644 --- a/src/writer/wgsl/generator_impl_test.cc +++ b/src/writer/wgsl/generator_impl_test.cc @@ -30,9 +30,9 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Generate) { - mod->AST().Functions().Add(Func("my_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, - ast::FunctionDecorationList{})); + AST().Functions().Add(Func("my_func", ast::VariableList{}, ty.void_(), + ast::StatementList{}, + ast::FunctionDecorationList{})); GeneratorImpl& gen = Build();