From 83158f214f9ea6d3aff14b0f1aae19f3785cdb27 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 26 Jan 2021 16:57:10 +0000 Subject: [PATCH] Program: Remove deprecated function methods Fixup all usages Bug: tint:390 Change-Id: I949235908e50702d6c8b2e7e2299594879653e01 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38547 Reviewed-by: dan sinclair --- src/inspector/inspector.cc | 4 +- src/inspector/inspector_test.cc | 164 +++++++++--------- src/program.h | 8 - src/program_test.cc | 8 +- src/reader/spirv/function.cc | 2 +- src/reader/wgsl/parser_impl.cc | 2 +- .../wgsl/parser_impl_global_decl_test.cc | 8 +- src/reader/wgsl/parser_impl_test.cc | 2 +- src/reader/wgsl/parser_test.cc | 2 +- src/transform/emit_vertex_point_size.cc | 2 +- src/transform/vertex_pulling.cc | 4 +- src/type_determiner.cc | 6 +- src/type_determiner_test.cc | 36 ++-- src/validator/validator_function_test.cc | 37 ++-- src/validator/validator_impl.cc | 4 +- src/validator/validator_test.cc | 12 +- src/validator/validator_type_test.cc | 6 +- src/writer/hlsl/generator_impl.cc | 8 +- src/writer/hlsl/generator_impl_binary_test.cc | 2 +- src/writer/hlsl/generator_impl_call_test.cc | 6 +- ...tor_impl_function_entry_point_data_test.cc | 14 +- .../hlsl/generator_impl_function_test.cc | 58 +++---- src/writer/hlsl/generator_impl_test.cc | 2 +- src/writer/msl/generator_impl.cc | 8 +- src/writer/msl/generator_impl_call_test.cc | 6 +- ...tor_impl_function_entry_point_data_test.cc | 14 +- .../msl/generator_impl_function_test.cc | 54 +++--- src/writer/msl/generator_impl_test.cc | 2 +- src/writer/spirv/builder.cc | 2 +- src/writer/spirv/builder_function_test.cc | 4 +- .../spirv/builder_intrinsic_texture_test.cc | 2 +- src/writer/wgsl/generator_impl.cc | 7 +- .../wgsl/generator_impl_function_test.cc | 4 +- src/writer/wgsl/generator_impl_test.cc | 6 +- 34 files changed, 250 insertions(+), 256 deletions(-) diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 09bd59067e..bdd89a8cd5 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -50,7 +50,7 @@ Inspector::~Inspector() = default; std::vector Inspector::GetEntryPoints() { std::vector result; - for (auto* func : program_.Functions()) { + for (auto* func : program_.AST().Functions()) { if (!func->IsEntryPoint()) { continue; } @@ -283,7 +283,7 @@ std::vector Inspector::GetMultisampledTextureResourceBindings( } ast::Function* Inspector::FindEntryPointByName(const std::string& name) { - auto* func = program_.Functions().Find(program_.GetSymbol(name)); + auto* func = program_.AST().Functions().Find(program_.GetSymbol(name)); if (!func) { error_ += name + " was not found!"; return nullptr; diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index a98ce395be..61722539f7 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -701,7 +701,7 @@ TEST_F(InspectorGetEntryPointTest, NoFunctions) { } TEST_F(InspectorGetEntryPointTest, NoEntryPoints) { - mod->Functions().Add(MakeEmptyBodyFunction("foo", {})); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(foo); + mod->AST().Functions().Add(foo); auto* bar = MakeEmptyBodyFunction( "bar", ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(bar); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(foo); + mod->AST().Functions().Add(foo); auto* bar = MakeCallerBodyFunction( "bar", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(bar); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(foo); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(foo); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); auto* foo = MakeInOutVariableCallerBodyFunction( "foo", "func", {{"in_var", "out_var"}}, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(foo); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(foo); + mod->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->Functions().Add(foo); + mod->AST().Functions().Add(foo); auto* bar = MakeInOutVariableBodyFunction( "bar", {{"in2_var", "out_var"}}, ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(bar); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); auto* foo = MakeInOutVariableCallerBodyFunction( "foo", "func", {{"in_var", "out_var"}}, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(foo); + mod->AST().Functions().Add(foo); auto* bar = MakeCallerBodyFunction( "bar", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(bar); + mod->AST().Functions().Add(bar); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -1123,14 +1123,14 @@ TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) { ast::VariableDecorationList{create(0)})); auto* func = MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); auto* foo = MakeCallerBodyFunction( "foo", "func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(foo); + mod->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->Functions().Add(MakeEmptyBodyFunction("foo", {})); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(bar); + mod->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->Functions().Add(ub_func); + mod->AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(ub_func); + mod->AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(ub_func); + mod->AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(ub_func); + mod->AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(ub_func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(ub_func); + mod->AST().Functions().Add(ub_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "ub_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(sb_func); + mod->AST().Functions().Add(sb_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "sb_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(foo_func); + mod->AST().Functions().Add(foo_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "foo_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(foo_func); + mod->AST().Functions().Add(foo_func); auto* ep_func = MakeCallerBodyFunction( "ep_func", "foo_func", ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(ep_func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2212,7 +2212,7 @@ TEST_P(InspectorGetSampledArrayTextureResourceBindingsTestWithParam, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); @@ -2283,7 +2283,7 @@ TEST_P(InspectorGetMultisampledTextureResourceBindingsTestWithParam, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->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->Functions().Add(foo); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/program.h b/src/program.h index a77de887a6..aa0e63c686 100644 --- a/src/program.h +++ b/src/program.h @@ -118,14 +118,6 @@ class Program { return types_.Get(std::forward(args)...); } - /// @returns the functions declared in the translation unit - /// [DEPRECATED]: Use AST().Functions() - const ast::FunctionList& Functions() const { return AST().Functions(); } - - /// @returns the functions declared in the translation unit - /// [DEPRECATED]: Use AST().Functions() - ast::FunctionList& Functions() { return AST().Functions(); } - /// Returns all the declared types in the program /// [DEPRECATED]: Use AST().Types().types() /// @returns the mapping from name string to type. diff --git a/src/program_test.cc b/src/program_test.cc index dd97ca944e..947a953024 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->Functions().size(), 0u); + EXPECT_EQ(mod->AST().Functions().size(), 0u); } TEST_F(ProgramTest, ToStrEmitsPreambleAndPostamble) { @@ -90,12 +90,12 @@ TEST_F(ProgramTest, IsValid_Function) { auto* func = Func("main", ast::VariableList(), ty.f32, ast::StatementList{}, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(mod->IsValid()); } TEST_F(ProgramTest, IsValid_Null_Function) { - mod->Functions().Add(nullptr); + mod->AST().Functions().Add(nullptr); EXPECT_FALSE(mod->IsValid()); } @@ -103,7 +103,7 @@ TEST_F(ProgramTest, IsValid_Invalid_Function) { auto* func = Func("main", ast::VariableList{}, nullptr, ast::StatementList{}, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_FALSE(mod->IsValid()); } diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index 251a9ec605..b88f9822d2 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -859,7 +859,7 @@ bool FunctionEmitter::Emit() { auto& statements = statements_stack_[0].GetStatements(); auto* body = create(Source{}, statements); - program_.Functions().Add(create( + program_.AST().Functions().Add(create( decl.source, program_.RegisterSymbol(decl.name), std::move(decl.params), decl.return_type, body, std::move(decl.decorations))); diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 27c496d563..dc15e047b9 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -378,7 +378,7 @@ Expect ParserImpl::expect_global_decl() { if (func.errored) errored = true; if (func.matched) { - program_.Functions().Add(func.value); + program_.AST().Functions().Add(func.value); return true; } diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc index c9ab075d52..022b34d547 100644 --- a/src/reader/wgsl/parser_impl_global_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_decl_test.cc @@ -135,8 +135,8 @@ TEST_F(ParserImplTest, GlobalDecl_Function) { ASSERT_FALSE(p->has_error()) << p->error(); auto& m = p->get_program(); - ASSERT_EQ(m.Functions().size(), 1u); - EXPECT_EQ(m.SymbolToName(m.Functions()[0]->symbol()), "main"); + ASSERT_EQ(m.AST().Functions().size(), 1u); + EXPECT_EQ(m.SymbolToName(m.AST().Functions()[0]->symbol()), "main"); } TEST_F(ParserImplTest, GlobalDecl_Function_WithDecoration) { @@ -145,8 +145,8 @@ TEST_F(ParserImplTest, GlobalDecl_Function_WithDecoration) { ASSERT_FALSE(p->has_error()) << p->error(); auto& m = p->get_program(); - ASSERT_EQ(m.Functions().size(), 1u); - EXPECT_EQ(m.SymbolToName(m.Functions()[0]->symbol()), "main"); + ASSERT_EQ(m.AST().Functions().size(), 1u); + EXPECT_EQ(m.SymbolToName(m.AST().Functions()[0]->symbol()), "main"); } TEST_F(ParserImplTest, GlobalDecl_Function_Invalid) { diff --git a/src/reader/wgsl/parser_impl_test.cc b/src/reader/wgsl/parser_impl_test.cc index 654b6db880..4fc43fcc8c 100644 --- a/src/reader/wgsl/parser_impl_test.cc +++ b/src/reader/wgsl/parser_impl_test.cc @@ -40,7 +40,7 @@ fn main() -> void { ASSERT_TRUE(p->Parse()) << p->error(); auto& m = p->get_program(); - ASSERT_EQ(1u, m.Functions().size()); + ASSERT_EQ(1u, m.AST().Functions().size()); ASSERT_EQ(1u, m.AST().GlobalVariables().size()); } diff --git a/src/reader/wgsl/parser_test.cc b/src/reader/wgsl/parser_test.cc index 57f9672e24..c31ac863bb 100644 --- a/src/reader/wgsl/parser_test.cc +++ b/src/reader/wgsl/parser_test.cc @@ -42,7 +42,7 @@ fn main() -> void { ASSERT_TRUE(p.Parse()) << p.error(); auto m = p.program(); - ASSERT_EQ(1u, m.Functions().size()); + ASSERT_EQ(1u, m.AST().Functions().size()); ASSERT_EQ(1u, m.AST().GlobalVariables().size()); } diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc index 51b7623066..d77f3441d7 100644 --- a/src/transform/emit_vertex_point_size.cc +++ b/src/transform/emit_vertex_point_size.cc @@ -41,7 +41,7 @@ EmitVertexPointSize::~EmitVertexPointSize() = default; Transform::Output EmitVertexPointSize::Run(const Program* in) { Output out; - if (!in->Functions().HasStage(ast::PipelineStage::kVertex)) { + if (!in->AST().Functions().HasStage(ast::PipelineStage::kVertex)) { // If the module doesn't have any vertex stages, then there's nothing to do. out.program = in->Clone(); return out; diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 32c7575b4a..152d33deb9 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -85,8 +85,8 @@ Transform::Output VertexPulling::Run(const Program* in) { } // Find entry point - auto* func = in->Functions().Find(in->GetSymbol(cfg.entry_point_name), - ast::PipelineStage::kVertex); + auto* func = in->AST().Functions().Find(in->GetSymbol(cfg.entry_point_name), + ast::PipelineStage::kVertex); if (func == nullptr) { diag::Diagnostic err; err.severity = diag::Severity::Error; diff --git a/src/type_determiner.cc b/src/type_determiner.cc index aae1da6c61..22ca44b84e 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -126,13 +126,13 @@ bool TypeDeterminer::Determine() { } } - if (!DetermineFunctions(program_->Functions())) { + if (!DetermineFunctions(program_->AST().Functions())) { return false; } // Walk over the caller to callee information and update functions with which // entry points call those functions. - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!func->IsEntryPoint()) { continue; } @@ -404,7 +404,7 @@ bool TypeDeterminer::DetermineCall(ast::CallExpression* expr) { caller_to_callee_[current_function_->symbol()].push_back( ident->symbol()); - auto* callee_func = program_->Functions().Find(ident->symbol()); + auto* callee_func = program_->AST().Functions().Find(ident->symbol()); if (callee_func == nullptr) { set_error(expr->source(), "unable to find called function: " + diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index d0cd87b420..e6b57057a7 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->Functions().Add(func); + mod->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->Functions().Add(func_main); + mod->AST().Functions().Add(func_main); auto* func = Func("func", params0, ty.f32, ast::StatementList{ create(), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_FALSE(td()->Determine()) << td()->error(); EXPECT_EQ(td()->error(), @@ -472,7 +472,7 @@ TEST_F(TypeDeterminerTest, Expr_Call) { ast::VariableList params; auto* func = Func("my_func", params, ty.f32, ast::StatementList{}, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -487,7 +487,7 @@ TEST_F(TypeDeterminerTest, Expr_Call_WithParams) { ast::VariableList params; auto* func = Func("my_func", params, ty.f32, ast::StatementList{}, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -626,7 +626,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->Functions().Add(func); + mod->AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -665,7 +665,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); // Register the function EXPECT_TRUE(td()->Determine()); @@ -702,7 +702,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); auto* func2 = Func( "func", ast::VariableList{}, ty.f32, @@ -711,7 +711,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func2); + mod->AST().Functions().Add(func2); // Register the function EXPECT_TRUE(td()->Determine()); @@ -736,7 +736,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); auto* v = Var("var", ast::StorageClass::kFunction, ty.f32); td()->RegisterVariableForTesting(v); @@ -1589,7 +1589,7 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) { auto* func = Func("func", ast::VariableList{}, ty.i32, ast::StatementList{stmt}, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_EQ(var->storage_class(), ast::StorageClass::kFunction); @@ -1601,7 +1601,7 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) { auto* func = Func("func", ast::VariableList{}, ty.i32, ast::StatementList{stmt}, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_EQ(var->storage_class(), ast::StorageClass::kNone); @@ -1614,7 +1614,7 @@ TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) { auto* func = Func("func", ast::VariableList{}, ty.i32, ast::StatementList{stmt}, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_FALSE(td()->Determine()); EXPECT_EQ(td()->error(), @@ -2760,11 +2760,11 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func_b); - mod->Functions().Add(func_c); - mod->Functions().Add(func_a); - mod->Functions().Add(ep_1); - mod->Functions().Add(ep_2); + 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); mod->AST().AddGlobalVariable( Var("first", ast::StorageClass::kPrivate, ty.f32)); diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index 73c3ce2535..bdc936658c 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->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -68,7 +68,7 @@ TEST_F(ValidateFunctionTest, ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -89,7 +89,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { create(var), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -127,13 +127,14 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); - EXPECT_TRUE(td()->DetermineFunctions(mod->Functions())) << td()->error(); + EXPECT_TRUE(td()->DetermineFunctions(mod->AST().Functions())) + << td()->error(); ValidatorImpl& v = Build(); - EXPECT_TRUE(v.ValidateFunctions(mod->Functions())) << v.error(); + EXPECT_TRUE(v.ValidateFunctions(mod->AST().Functions())) << v.error(); } TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { @@ -144,7 +145,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { Source{Source::Location{12, 34}}, Expr(2)), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -165,7 +166,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) { Source{Source::Location{12, 34}}, Expr(2)), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -194,8 +195,8 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); - mod->Functions().Add(func_copy); + mod->AST().Functions().Add(func); + mod->AST().Functions().Add(func_copy); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -217,7 +218,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) { create(), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func0); + mod->AST().Functions().Add(func0); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -241,7 +242,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { create(Expr(2)), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func0); + mod->AST().Functions().Add(func0); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -263,7 +264,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) { create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -288,7 +289,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) { create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -313,7 +314,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) { create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); ValidatorImpl& v = Build(); @@ -335,7 +336,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -351,7 +352,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) { create(), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc index 83b444c5e0..1df8e8a8a1 100644 --- a/src/validator/validator_impl.cc +++ b/src/validator/validator_impl.cc @@ -71,10 +71,10 @@ bool ValidatorImpl::Validate() { if (!ValidateConstructedTypes(program_->AST().ConstructedTypes())) { return false; } - if (!ValidateFunctions(program_->Functions())) { + if (!ValidateFunctions(program_->AST().Functions())) { return false; } - if (!ValidateEntryPoint(program_->Functions())) { + if (!ValidateEntryPoint(program_->AST().Functions())) { return false; } function_stack_.pop_scope(); diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index 081366deb9..b07d321ee1 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -394,7 +394,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { Source{Source::Location{12, 34}}, lhs, rhs), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ValidatorImpl& v = Build(); @@ -423,7 +423,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -582,7 +582,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_TRUE(td()->DetermineFunction(func)) << td()->error(); @@ -612,7 +612,7 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); EXPECT_TRUE(td()->DetermineFunction(func)) << td()->error(); @@ -711,8 +711,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func0); - mod->Functions().Add(func1); + mod->AST().Functions().Add(func0); + mod->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 191c008a70..f9e47f76cc 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -172,7 +172,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) { ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); EXPECT_TRUE(td()->Determine()) << td()->error(); @@ -197,7 +197,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) { create(), }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->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->Functions().Add(main); + mod->AST().Functions().Add(main); EXPECT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 533b95d970..9fdbc89524 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -160,7 +160,7 @@ bool GeneratorImpl::Generate(std::ostream& out) { std::unordered_set emitted_globals; // Make sure all entry point data is emitted before the entry point functions - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!func->IsEntryPoint()) { continue; } @@ -170,13 +170,13 @@ bool GeneratorImpl::Generate(std::ostream& out) { } } - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!EmitFunction(out, func)) { return false; } } - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!func->IsEntryPoint()) { continue; } @@ -631,7 +631,7 @@ bool GeneratorImpl::EmitCall(std::ostream& pre, name = it->second; } - auto* func = program_->Functions().Find(ident->symbol()); + auto* func = program_->AST().Functions().Find(ident->symbol()); if (func == nullptr) { error_ = "Unable to find function: " + program_->SymbolToName(ident->symbol()); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index c0a0e03a60..4e03a34ba0 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->Functions().Add(func); + mod->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 c03e631825..c3ac3763a5 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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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 cf45b92b1a..3639139291 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 @@ -70,7 +70,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); std::unordered_set globals; @@ -123,7 +123,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); std::unordered_set globals; @@ -176,7 +176,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); std::unordered_set globals; @@ -229,7 +229,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); std::unordered_set globals; @@ -279,7 +279,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); std::unordered_set globals; @@ -324,7 +324,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); std::unordered_set globals; @@ -377,7 +377,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->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 b2fa845379..899d52bb22 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->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -80,7 +80,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -105,7 +105,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -128,7 +128,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -169,7 +169,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -221,7 +221,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -325,7 +325,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -378,7 +378,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -431,7 +431,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -481,7 +481,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -528,7 +528,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -582,7 +582,7 @@ TEST_F( }, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -646,7 +646,7 @@ TEST_F(HlslGeneratorImplTest_Function, }, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -715,7 +715,7 @@ TEST_F( }, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -779,7 +779,7 @@ TEST_F(HlslGeneratorImplTest_Function, }, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -839,7 +839,7 @@ TEST_F(HlslGeneratorImplTest_Function, }, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -902,7 +902,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -933,7 +933,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -956,7 +956,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -983,7 +983,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(2u, 4u, 6u), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -1008,7 +1008,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -1071,7 +1071,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); } { @@ -1088,7 +1088,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); } ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index d3e36abe89..898f8b96d9 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->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index b83519c109..f730784b46 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -138,7 +138,7 @@ bool GeneratorImpl::Generate() { } // Make sure all entry point data is emitted before the entry point functions - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!func->IsEntryPoint()) { continue; } @@ -148,13 +148,13 @@ bool GeneratorImpl::Generate() { } } - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!EmitFunction(func)) { return false; } } - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!func->IsEntryPoint()) { continue; } @@ -525,7 +525,7 @@ bool GeneratorImpl::EmitCall(ast::CallExpression* expr) { name = it->second; } - auto* func = program_->Functions().Find(ident->symbol()); + auto* func = program_->AST().Functions().Find(ident->symbol()); if (func == nullptr) { error_ = "Unable to find function: " + program_->SymbolToName(ident->symbol()); diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc index f2164d6897..6a00000fb7 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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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->Functions().Add(func); + mod->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 bdbd3fd0cf..5a223b5b0d 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 @@ -71,7 +71,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -119,7 +119,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { create(ast::PipelineStage::kVertex), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -167,7 +167,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -215,7 +215,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -260,7 +260,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -300,7 +300,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -345,7 +345,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->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 1b99314655..66662b2174 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->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -85,7 +85,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -112,7 +112,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -174,7 +174,7 @@ TEST_F(MslGeneratorImplTest, ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment)}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -223,7 +223,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { ast::FunctionDecorationList{create( ast::PipelineStage::kFragment)}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -278,7 +278,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -323,7 +323,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -374,7 +374,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -428,7 +428,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -483,7 +483,7 @@ TEST_F( auto* sub_func = Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -547,7 +547,7 @@ TEST_F(MslGeneratorImplTest, }, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -616,7 +616,7 @@ TEST_F( auto* sub_func = Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -674,7 +674,7 @@ TEST_F(MslGeneratorImplTest, auto* sub_func = Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -741,7 +741,7 @@ TEST_F(MslGeneratorImplTest, auto* sub_func = Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -810,7 +810,7 @@ TEST_F(MslGeneratorImplTest, auto* sub_func = Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{}); - mod->Functions().Add(sub_func); + mod->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->Functions().Add(func); + mod->AST().Functions().Add(func); ASSERT_TRUE(td.Determine()) << td.error(); @@ -881,7 +881,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(func_1); + mod->AST().Functions().Add(func_1); ASSERT_TRUE(td.Determine()) << td.error(); @@ -914,7 +914,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -938,7 +938,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { }, ast::FunctionDecorationList{}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); @@ -1004,7 +1004,7 @@ TEST_F(MslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); } { @@ -1018,7 +1018,7 @@ TEST_F(MslGeneratorImplTest, ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute)}); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); } ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index 765205edc9..1a1a965490 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->Functions().Add(func); + mod->AST().Functions().Add(func); GeneratorImpl& gen = Build(); diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 0bb8144ada..ef481abc9a 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -303,7 +303,7 @@ bool Builder::Build() { } } - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!GenerateFunction(func)) { return false; } diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 066684892f..5ce14b323c 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -261,7 +261,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); } { @@ -278,7 +278,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->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 c4b51304b4..01240dcb82 100644 --- a/src/writer/spirv/builder_intrinsic_texture_test.cc +++ b/src/writer/spirv/builder_intrinsic_texture_test.cc @@ -4165,7 +4165,7 @@ TEST_P(IntrinsicTextureTest, ValidateSPIRV) { create(ast::PipelineStage::kFragment), }); - mod->Functions().Add(main); + mod->AST().Functions().Add(main); ASSERT_TRUE(td.Determine()) << td.error(); diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 0e23380c5a..dd14fe3a99 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -101,7 +101,7 @@ bool GeneratorImpl::Generate() { out_ << std::endl; } - for (auto* func : program_->Functions()) { + for (auto* func : program_->AST().Functions()) { if (!EmitFunction(func)) { return false; } @@ -113,7 +113,8 @@ bool GeneratorImpl::Generate() { bool GeneratorImpl::GenerateEntryPoint(ast::PipelineStage stage, const std::string& name) { - auto* func = program_->Functions().Find(program_->GetSymbol(name), stage); + auto* func = + program_->AST().Functions().Find(program_->GetSymbol(name), stage); if (func == nullptr) { error_ = "Unable to find requested entry point: " + name; return false; @@ -152,7 +153,7 @@ bool GeneratorImpl::GenerateEntryPoint(ast::PipelineStage stage, out_ << std::endl; } - for (auto* f : program_->Functions()) { + for (auto* f : program_->AST().Functions()) { if (!f->HasAncestorEntryPoint(program_->GetSymbol(name))) { continue; } diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index f82c2b1c22..4c11185ef1 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -212,7 +212,7 @@ TEST_F(WgslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->AST().Functions().Add(func); } { @@ -231,7 +231,7 @@ TEST_F(WgslGeneratorImplTest, create(ast::PipelineStage::kCompute), }); - mod->Functions().Add(func); + mod->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 449e795cbf..d39f14cbac 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->Functions().Add(Func("my_func", ast::VariableList{}, ty.void_, - ast::StatementList{}, - ast::FunctionDecorationList{})); + mod->AST().Functions().Add(Func("my_func", ast::VariableList{}, ty.void_, + ast::StatementList{}, + ast::FunctionDecorationList{})); GeneratorImpl& gen = Build();