From d026e13f48d34d327fbe073d57f86438d32a90fe Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 18 Apr 2023 19:38:25 +0000 Subject: [PATCH] Remove `SymbolTable::NameFor` This CL removes the `NameFor` method from SymbolTable and accesses the symbols name directly. Change-Id: Ic4ad6eecfa78efb946d97aeaecf2d784af2e6f16 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127301 Reviewed-by: Ben Clayton Kokoro: Kokoro Commit-Queue: Dan Sinclair --- src/tint/ast/alias_test.cc | 4 +- src/tint/ast/bitcast_expression_test.cc | 2 +- src/tint/ast/builtin_attribute_test.cc | 2 +- src/tint/ast/diagnostic_directive_test.cc | 2 +- src/tint/ast/function_test.cc | 2 +- src/tint/ast/interpolate_attribute_test.cc | 4 +- src/tint/ast/module_test.cc | 9 +- src/tint/ast/struct_member_test.cc | 8 +- src/tint/ast/test_helper.h | 30 ++---- src/tint/ast/test_helper_test.cc | 8 +- src/tint/ast/variable_test.cc | 18 ++-- src/tint/ast/workgroup_attribute_test.cc | 2 +- src/tint/clone_context.cc | 2 +- src/tint/clone_context_test.cc | 62 ++++++------ src/tint/cmd/info.cc | 7 +- src/tint/inspector/inspector.cc | 24 ++--- src/tint/inspector/test_inspector_builder.cc | 2 +- src/tint/ir/binary.cc | 8 +- src/tint/ir/binary.h | 3 +- src/tint/ir/binary_test.cc | 36 +++---- src/tint/ir/bitcast.cc | 6 +- src/tint/ir/bitcast.h | 3 +- src/tint/ir/bitcast_test.cc | 2 +- src/tint/ir/builder_impl.cc | 2 +- src/tint/ir/builtin.cc | 6 +- src/tint/ir/builtin.h | 3 +- src/tint/ir/call.cc | 4 +- src/tint/ir/call.h | 3 +- src/tint/ir/constant.cc | 6 +- src/tint/ir/constant.h | 3 +- src/tint/ir/constant_test.cc | 12 +-- src/tint/ir/construct.cc | 8 +- src/tint/ir/construct.h | 3 +- src/tint/ir/convert.cc | 8 +- src/tint/ir/convert.h | 3 +- src/tint/ir/debug.cc | 2 +- src/tint/ir/disassembler.cc | 13 ++- src/tint/ir/instruction.h | 4 +- src/tint/ir/temp.cc | 4 +- src/tint/ir/temp.h | 3 +- src/tint/ir/temp_test.cc | 2 +- src/tint/ir/user_call.cc | 8 +- src/tint/ir/user_call.h | 3 +- src/tint/ir/value.h | 4 +- src/tint/program.cc | 4 +- src/tint/program_builder.cc | 4 +- .../reader/spirv/parser_impl_test_helper.cc | 2 +- .../reader/wgsl/parser_impl_call_stmt_test.cc | 6 +- .../parser_impl_diagnostic_attribute_test.cc | 2 +- .../parser_impl_diagnostic_control_test.cc | 4 +- .../parser_impl_diagnostic_directive_test.cc | 2 +- .../parser_impl_function_attribute_test.cc | 2 +- .../wgsl/parser_impl_function_decl_test.cc | 2 +- .../wgsl/parser_impl_function_header_test.cc | 4 +- .../parser_impl_global_constant_decl_test.cc | 8 +- .../wgsl/parser_impl_global_decl_test.cc | 11 +-- .../parser_impl_global_variable_decl_test.cc | 24 ++--- .../wgsl/parser_impl_param_list_test.cc | 15 ++- .../parser_impl_primary_expression_test.cc | 10 +- .../parser_impl_singular_expression_test.cc | 4 +- .../wgsl/parser_impl_struct_body_decl_test.cc | 4 +- .../wgsl/parser_impl_struct_member_test.cc | 16 ++-- .../wgsl/parser_impl_type_alias_test.cc | 10 +- .../reader/wgsl/parser_impl_type_decl_test.cc | 55 +++++------ ...arser_impl_variable_attribute_list_test.cc | 3 +- .../parser_impl_variable_attribute_test.cc | 24 ++--- .../wgsl/parser_impl_variable_decl_test.cc | 12 +-- .../parser_impl_variable_ident_decl_test.cc | 4 +- .../parser_impl_variable_qualifier_test.cc | 5 +- .../wgsl/parser_impl_variable_stmt_test.cc | 12 +-- src/tint/resolver/bitcast_validation_test.cc | 10 +- src/tint/resolver/builtin_test.cc | 2 +- src/tint/resolver/dependency_graph.cc | 45 ++++----- src/tint/resolver/dependency_graph.h | 10 +- src/tint/resolver/dependency_graph_test.cc | 26 +++-- src/tint/resolver/intrinsic_table.cc | 29 +++--- src/tint/resolver/resolver.cc | 77 +++++++-------- src/tint/resolver/resolver_test_helper.h | 4 +- src/tint/resolver/sem_helper.cc | 35 +++---- src/tint/resolver/uniformity.cc | 12 +-- src/tint/resolver/validator.cc | 94 +++++++++---------- src/tint/sem/array_count.cc | 6 +- src/tint/sem/array_count.h | 6 +- src/tint/sem/struct_test.cc | 2 +- src/tint/symbol_table.cc | 5 - src/tint/symbol_table.h | 5 - src/tint/symbol_table_test.cc | 13 --- src/tint/transform/add_block_attribute.cc | 2 +- .../transform/canonicalize_entry_point_io.cc | 10 +- src/tint/transform/clamp_frag_depth.cc | 2 +- src/tint/transform/combine_samplers.cc | 6 +- src/tint/transform/decompose_memory_access.cc | 6 +- src/tint/transform/direct_variable_access.cc | 8 +- src/tint/transform/packed_vec3.cc | 7 +- src/tint/transform/pad_structs.cc | 2 +- src/tint/transform/preserve_padding.cc | 2 +- src/tint/transform/renamer.cc | 4 +- src/tint/transform/robustness.cc | 3 +- src/tint/transform/simplify_pointers.cc | 3 +- src/tint/transform/single_entry_point.cc | 2 +- src/tint/transform/spirv_atomic.cc | 8 +- src/tint/transform/std140.cc | 28 +++--- src/tint/transform/transform_test.cc | 19 ++-- src/tint/transform/unshadow.cc | 2 +- src/tint/transform/vertex_pulling.cc | 2 +- .../transform/zero_init_workgroup_memory.cc | 2 +- src/tint/type/abstract_float.cc | 2 +- src/tint/type/abstract_float.h | 3 +- src/tint/type/abstract_int.cc | 2 +- src/tint/type/abstract_int.h | 3 +- src/tint/type/array.cc | 6 +- src/tint/type/array.h | 3 +- src/tint/type/array_count.cc | 4 +- src/tint/type/array_count.h | 9 +- src/tint/type/array_test.cc | 8 +- src/tint/type/atomic.cc | 4 +- src/tint/type/atomic.h | 3 +- src/tint/type/atomic_test.cc | 2 +- src/tint/type/bool.cc | 2 +- src/tint/type/bool.h | 3 +- src/tint/type/bool_test.cc | 2 +- src/tint/type/depth_multisampled_texture.cc | 2 +- src/tint/type/depth_multisampled_texture.h | 3 +- .../type/depth_multisampled_texture_test.cc | 2 +- src/tint/type/depth_texture.cc | 2 +- src/tint/type/depth_texture.h | 3 +- src/tint/type/depth_texture_test.cc | 2 +- src/tint/type/external_texture.cc | 2 +- src/tint/type/external_texture.h | 3 +- src/tint/type/external_texture_test.cc | 2 +- src/tint/type/f16.cc | 2 +- src/tint/type/f16.h | 3 +- src/tint/type/f16_test.cc | 2 +- src/tint/type/f32.cc | 2 +- src/tint/type/f32.h | 3 +- src/tint/type/f32_test.cc | 2 +- src/tint/type/i32.cc | 2 +- src/tint/type/i32.h | 3 +- src/tint/type/i32_test.cc | 2 +- src/tint/type/matrix.cc | 4 +- src/tint/type/matrix.h | 3 +- src/tint/type/matrix_test.cc | 2 +- src/tint/type/multisampled_texture.cc | 4 +- src/tint/type/multisampled_texture.h | 3 +- src/tint/type/multisampled_texture_test.cc | 2 +- src/tint/type/pointer.cc | 4 +- src/tint/type/pointer.h | 3 +- src/tint/type/pointer_test.cc | 4 +- src/tint/type/reference.cc | 4 +- src/tint/type/reference.h | 3 +- src/tint/type/reference_test.cc | 4 +- src/tint/type/sampled_texture.cc | 4 +- src/tint/type/sampled_texture.h | 3 +- src/tint/type/sampled_texture_test.cc | 2 +- src/tint/type/sampler.cc | 2 +- src/tint/type/sampler.h | 3 +- src/tint/type/sampler_test.cc | 4 +- src/tint/type/storage_texture.cc | 2 +- src/tint/type/storage_texture.h | 3 +- src/tint/type/storage_texture_test.cc | 2 +- src/tint/type/struct.cc | 16 ++-- src/tint/type/struct.h | 6 +- src/tint/type/struct_test.cc | 12 +-- src/tint/type/type.h | 3 +- src/tint/type/u32.cc | 2 +- src/tint/type/u32.h | 3 +- src/tint/type/u32_test.cc | 2 +- src/tint/type/vector.cc | 4 +- src/tint/type/vector.h | 3 +- src/tint/type/vector_test.cc | 4 +- src/tint/type/void.cc | 2 +- src/tint/type/void.h | 3 +- src/tint/writer/append_vector_test.cc | 10 +- src/tint/writer/glsl/generator.cc | 2 +- src/tint/writer/glsl/generator_bench.cc | 2 +- src/tint/writer/glsl/generator_impl.cc | 47 +++++----- src/tint/writer/hlsl/generator.cc | 2 +- src/tint/writer/hlsl/generator_impl.cc | 53 +++++------ src/tint/writer/msl/generator_impl.cc | 46 +++++---- src/tint/writer/spirv/builder.cc | 45 ++++----- src/tint/writer/syntax_tree/generator_impl.cc | 20 ++-- src/tint/writer/text_generator.cc | 4 +- src/tint/writer/wgsl/generator_impl.cc | 22 ++--- 183 files changed, 700 insertions(+), 874 deletions(-) diff --git a/src/tint/ast/alias_test.cc b/src/tint/ast/alias_test.cc index d99fb21748..8131f65f5d 100644 --- a/src/tint/ast/alias_test.cc +++ b/src/tint/ast/alias_test.cc @@ -24,8 +24,8 @@ using AstAliasTest = TestHelper; TEST_F(AstAliasTest, Create) { auto u32 = ty.u32(); auto* a = Alias("a_type", u32); - CheckIdentifier(Symbols(), a->name, "a_type"); - CheckIdentifier(Symbols(), a->type, "u32"); + CheckIdentifier(a->name, "a_type"); + CheckIdentifier(a->type, "u32"); } } // namespace diff --git a/src/tint/ast/bitcast_expression_test.cc b/src/tint/ast/bitcast_expression_test.cc index d288a77490..ce4ab1d048 100644 --- a/src/tint/ast/bitcast_expression_test.cc +++ b/src/tint/ast/bitcast_expression_test.cc @@ -25,7 +25,7 @@ using BitcastExpressionTest = TestHelper; TEST_F(BitcastExpressionTest, Create) { auto* expr = Expr("expr"); auto* exp = Bitcast(ty.f32(), expr); - CheckIdentifier(Symbols(), exp->type, "f32"); + CheckIdentifier(exp->type, "f32"); ASSERT_EQ(exp->expr, expr); } diff --git a/src/tint/ast/builtin_attribute_test.cc b/src/tint/ast/builtin_attribute_test.cc index 00192b8e3b..9c4f871444 100644 --- a/src/tint/ast/builtin_attribute_test.cc +++ b/src/tint/ast/builtin_attribute_test.cc @@ -24,7 +24,7 @@ using BuiltinAttributeTest = TestHelper; TEST_F(BuiltinAttributeTest, Creation) { auto* d = Builtin(builtin::BuiltinValue::kFragDepth); - CheckIdentifier(Symbols(), d->builtin, "frag_depth"); + CheckIdentifier(d->builtin, "frag_depth"); } TEST_F(BuiltinAttributeTest, Assert_Null_Builtin) { diff --git a/src/tint/ast/diagnostic_directive_test.cc b/src/tint/ast/diagnostic_directive_test.cc index 3e23d6a183..721a545238 100644 --- a/src/tint/ast/diagnostic_directive_test.cc +++ b/src/tint/ast/diagnostic_directive_test.cc @@ -29,7 +29,7 @@ TEST_F(DiagnosticDirectiveTest, Creation) { EXPECT_EQ(diag->source.range.end.line, 10u); EXPECT_EQ(diag->source.range.end.column, 15u); EXPECT_EQ(diag->control.severity, builtin::DiagnosticSeverity::kWarning); - CheckIdentifier(Symbols(), diag->control.rule_name, "foo"); + CheckIdentifier(diag->control.rule_name, "foo"); } } // namespace diff --git a/src/tint/ast/function_test.cc b/src/tint/ast/function_test.cc index 1af27a692c..36a96e3370 100644 --- a/src/tint/ast/function_test.cc +++ b/src/tint/ast/function_test.cc @@ -33,7 +33,7 @@ TEST_F(FunctionTest, Creation_i32ReturnType) { auto* f = Func("func", params, i32, utils::Empty); EXPECT_EQ(f->name->symbol, Symbols().Get("func")); ASSERT_EQ(f->params.Length(), 1u); - CheckIdentifier(Symbols(), f->return_type, "i32"); + CheckIdentifier(f->return_type, "i32"); EXPECT_EQ(f->params[0], var); } diff --git a/src/tint/ast/interpolate_attribute_test.cc b/src/tint/ast/interpolate_attribute_test.cc index ecb2facac6..462449d60f 100644 --- a/src/tint/ast/interpolate_attribute_test.cc +++ b/src/tint/ast/interpolate_attribute_test.cc @@ -27,8 +27,8 @@ using InterpolateAttributeTest = TestHelper; TEST_F(InterpolateAttributeTest, Creation) { auto* d = Interpolate(builtin::InterpolationType::kLinear, builtin::InterpolationSampling::kCenter); - CheckIdentifier(Symbols(), d->type, "linear"); - CheckIdentifier(Symbols(), d->sampling, "center"); + CheckIdentifier(d->type, "linear"); + CheckIdentifier(d->sampling, "center"); } } // namespace diff --git a/src/tint/ast/module_test.cc b/src/tint/ast/module_test.cc index c0255ffdee..878df56732 100644 --- a/src/tint/ast/module_test.cc +++ b/src/tint/ast/module_test.cc @@ -125,12 +125,9 @@ TEST_F(ModuleTest, CloneOrder) { ASSERT_TRUE(decls[2]->Is()); ASSERT_TRUE(decls[4]->Is()); - ASSERT_EQ(cloned.Symbols().NameFor(decls[0]->As()->name->symbol), - "inserted_before_F"); - ASSERT_EQ(cloned.Symbols().NameFor(decls[2]->As()->name->symbol), - "inserted_before_A"); - ASSERT_EQ(cloned.Symbols().NameFor(decls[4]->As()->name->symbol), - "inserted_before_V"); + ASSERT_EQ(decls[0]->As()->name->symbol.Name(), "inserted_before_F"); + ASSERT_EQ(decls[2]->As()->name->symbol.Name(), "inserted_before_A"); + ASSERT_EQ(decls[4]->As()->name->symbol.Name(), "inserted_before_V"); } TEST_F(ModuleTest, Directives) { diff --git a/src/tint/ast/struct_member_test.cc b/src/tint/ast/struct_member_test.cc index 59eb30f4ec..22f40df2cf 100644 --- a/src/tint/ast/struct_member_test.cc +++ b/src/tint/ast/struct_member_test.cc @@ -23,8 +23,8 @@ using StructMemberTest = TestHelper; TEST_F(StructMemberTest, Creation) { auto* st = Member("a", ty.i32(), utils::Vector{MemberSize(4_a)}); - CheckIdentifier(Symbols(), st->name, "a"); - CheckIdentifier(Symbols(), st->type, "i32"); + CheckIdentifier(st->name, "a"); + CheckIdentifier(st->type, "i32"); EXPECT_EQ(st->attributes.Length(), 1u); EXPECT_TRUE(st->attributes[0]->Is()); EXPECT_EQ(st->source.range.begin.line, 0u); @@ -36,8 +36,8 @@ TEST_F(StructMemberTest, Creation) { TEST_F(StructMemberTest, CreationWithSource) { auto* st = Member(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}}, "a", ty.i32()); - CheckIdentifier(Symbols(), st->name, "a"); - CheckIdentifier(Symbols(), st->type, "i32"); + CheckIdentifier(st->name, "a"); + CheckIdentifier(st->type, "i32"); EXPECT_EQ(st->attributes.Length(), 0u); EXPECT_EQ(st->source.range.begin.line, 27u); EXPECT_EQ(st->source.range.begin.column, 4u); diff --git a/src/tint/ast/test_helper.h b/src/tint/ast/test_helper.h index 9d7b68901b..e26c10a76a 100644 --- a/src/tint/ast/test_helper.h +++ b/src/tint/ast/test_helper.h @@ -72,25 +72,21 @@ struct IsTemplatedIdentifierMatcher> { }; /// A testing utility for checking that an Identifier matches the expected values. -/// @param symbols the symbol table /// @param got the identifier /// @param expected the expected identifier name template -void CheckIdentifier(const SymbolTable& symbols, const Identifier* got, std::string_view expected) { +void CheckIdentifier(const Identifier* got, std::string_view expected) { EXPECT_FALSE(got->Is()); - EXPECT_EQ(symbols.NameFor(got->symbol), expected); + EXPECT_EQ(got->symbol.Name(), expected); } /// A testing utility for checking that an Identifier matches the expected name and template /// arguments. -/// @param symbols the symbol table /// @param ident the identifier /// @param expected the expected identifier name and arguments template -void CheckIdentifier(const SymbolTable& symbols, - const Identifier* ident, - const TemplatedIdentifierMatcher& expected) { - EXPECT_EQ(symbols.NameFor(ident->symbol), expected.name); +void CheckIdentifier(const Identifier* ident, const TemplatedIdentifierMatcher& expected) { + EXPECT_EQ(ident->symbol.Name(), expected.name); ASSERT_TRUE(ident->Is()); auto* got = ident->As(); ASSERT_EQ(got->arguments.Length(), std::tuple_size_v); @@ -102,12 +98,12 @@ void CheckIdentifier(const SymbolTable& symbols, using T = std::decay_t; if constexpr (traits::IsStringLike) { ASSERT_TRUE(got_arg->Is()); - CheckIdentifier(symbols, got_arg->As()->identifier, expected_arg); + CheckIdentifier(got_arg->As()->identifier, expected_arg); } else if constexpr (IsTemplatedIdentifierMatcher::value) { ASSERT_TRUE(got_arg->Is()); auto* got_ident = got_arg->As()->identifier; ASSERT_TRUE(got_ident->Is()); - CheckIdentifier(symbols, got_ident->As(), expected_arg); + CheckIdentifier(got_ident->As(), expected_arg); } else if constexpr (std::is_same_v) { ASSERT_TRUE(got_arg->Is()); EXPECT_EQ(got_arg->As()->value, expected_arg); @@ -149,30 +145,24 @@ void CheckIdentifier(const SymbolTable& symbols, } /// A testing utility for checking that an IdentifierExpression matches the expected values. -/// @param symbols the symbol table /// @param expr the IdentifierExpression /// @param expected the expected identifier name template -void CheckIdentifier(const SymbolTable& symbols, - const Expression* expr, - std::string_view expected) { +void CheckIdentifier(const Expression* expr, std::string_view expected) { auto* expr_ident = expr->As(); ASSERT_NE(expr_ident, nullptr) << "expression is not a IdentifierExpression"; - CheckIdentifier(symbols, expr_ident->identifier, expected); + CheckIdentifier(expr_ident->identifier, expected); } /// A testing utility for checking that an IdentifierExpression matches the expected name and /// template arguments. -/// @param symbols the symbol table /// @param expr the IdentifierExpression /// @param expected the expected identifier name and arguments template -void CheckIdentifier(const SymbolTable& symbols, - const Expression* expr, - const TemplatedIdentifierMatcher& expected) { +void CheckIdentifier(const Expression* expr, const TemplatedIdentifierMatcher& expected) { auto* expr_ident = expr->As(); ASSERT_NE(expr_ident, nullptr) << "expression is not a IdentifierExpression"; - CheckIdentifier(symbols, expr_ident->identifier, expected); + CheckIdentifier(expr_ident->identifier, expected); } } // namespace tint::ast diff --git a/src/tint/ast/test_helper_test.cc b/src/tint/ast/test_helper_test.cc index fcf339c6ef..74d529f6a7 100644 --- a/src/tint/ast/test_helper_test.cc +++ b/src/tint/ast/test_helper_test.cc @@ -21,21 +21,21 @@ using namespace tint::number_suffixes; // NOLINT using AstCheckIdentifierTest = TestHelper; TEST_F(AstCheckIdentifierTest, NonTemplated) { - CheckIdentifier(Symbols(), Ident("abc"), "abc"); + CheckIdentifier(Ident("abc"), "abc"); } TEST_F(AstCheckIdentifierTest, TemplatedScalars) { - CheckIdentifier(Symbols(), Ident("abc", 1_i, 2_u, 3_f, 4_h, 5_a, 6._a, true), // + CheckIdentifier(Ident("abc", 1_i, 2_u, 3_f, 4_h, 5_a, 6._a, true), // Template("abc", 1_i, 2_u, 3_f, 4_h, 5_a, 6._a, true)); } TEST_F(AstCheckIdentifierTest, TemplatedIdentifiers) { - CheckIdentifier(Symbols(), Ident("abc", "one", "two", "three"), // + CheckIdentifier(Ident("abc", "one", "two", "three"), // Template("abc", "one", "two", "three")); } TEST_F(AstCheckIdentifierTest, NestedTemplate) { - CheckIdentifier(Symbols(), Ident("abc", "pre", Ident("nested", 42_a), "post"), // + CheckIdentifier(Ident("abc", "pre", Ident("nested", 42_a), "post"), // Template("abc", "pre", Template("nested", 42_a), "post")); } diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc index 6fbc42005a..bc8f2743ac 100644 --- a/src/tint/ast/variable_test.cc +++ b/src/tint/ast/variable_test.cc @@ -28,10 +28,10 @@ using VariableTest = TestHelper; TEST_F(VariableTest, Creation) { auto* v = Var("my_var", ty.i32(), builtin::AddressSpace::kFunction); - CheckIdentifier(Symbols(), v->name, "my_var"); - CheckIdentifier(Symbols(), v->declared_address_space, "function"); + CheckIdentifier(v->name, "my_var"); + CheckIdentifier(v->declared_address_space, "function"); EXPECT_EQ(v->declared_access, nullptr); - CheckIdentifier(Symbols(), v->type, "i32"); + CheckIdentifier(v->type, "i32"); EXPECT_EQ(v->source.range.begin.line, 0u); EXPECT_EQ(v->source.range.begin.column, 0u); EXPECT_EQ(v->source.range.end.line, 0u); @@ -42,9 +42,9 @@ TEST_F(VariableTest, CreationWithSource) { auto* v = Var(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}}, "i", ty.f32(), builtin::AddressSpace::kPrivate, utils::Empty); - CheckIdentifier(Symbols(), v->name, "i"); - CheckIdentifier(Symbols(), v->declared_address_space, "private"); - CheckIdentifier(Symbols(), v->type, "f32"); + CheckIdentifier(v->name, "i"); + CheckIdentifier(v->declared_address_space, "private"); + CheckIdentifier(v->type, "f32"); EXPECT_EQ(v->source.range.begin.line, 27u); EXPECT_EQ(v->source.range.begin.column, 4u); EXPECT_EQ(v->source.range.end.line, 27u); @@ -55,9 +55,9 @@ TEST_F(VariableTest, CreationEmpty) { auto* v = Var(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 7}}}, "a_var", ty.i32(), builtin::AddressSpace::kWorkgroup, utils::Empty); - CheckIdentifier(Symbols(), v->name, "a_var"); - CheckIdentifier(Symbols(), v->declared_address_space, "workgroup"); - CheckIdentifier(Symbols(), v->type, "i32"); + CheckIdentifier(v->name, "a_var"); + CheckIdentifier(v->declared_address_space, "workgroup"); + CheckIdentifier(v->type, "i32"); EXPECT_EQ(v->source.range.begin.line, 27u); EXPECT_EQ(v->source.range.begin.column, 4u); EXPECT_EQ(v->source.range.end.line, 27u); diff --git a/src/tint/ast/workgroup_attribute_test.cc b/src/tint/ast/workgroup_attribute_test.cc index 3363e52eb0..be833b61b0 100644 --- a/src/tint/ast/workgroup_attribute_test.cc +++ b/src/tint/ast/workgroup_attribute_test.cc @@ -73,7 +73,7 @@ TEST_F(WorkgroupAttributeTest, Creation_WithIdentifier) { auto* z_ident = As(values[2]); ASSERT_TRUE(z_ident); - EXPECT_EQ(Symbols().NameFor(z_ident->identifier->symbol), "depth"); + EXPECT_EQ(z_ident->identifier->symbol.Name(), "depth"); } } // namespace diff --git a/src/tint/clone_context.cc b/src/tint/clone_context.cc index 359030133b..a6f147846f 100644 --- a/src/tint/clone_context.cc +++ b/src/tint/clone_context.cc @@ -49,7 +49,7 @@ Symbol CloneContext::Clone(Symbol s) { if (symbol_transform_) { return symbol_transform_(s); } - return dst->Symbols().New(src->Symbols().NameFor(s)); + return dst->Symbols().New(s.Name()); }); } diff --git a/src/tint/clone_context_test.cc b/src/tint/clone_context_test.cc index 59c47c0cb4..ec17e0de4b 100644 --- a/src/tint/clone_context_test.cc +++ b/src/tint/clone_context_test.cc @@ -183,10 +183,8 @@ TEST_F(CloneContextNodeTest, CloneWithReplaceAll_Cloneable) { CloneContext ctx(&cloned, &original); ctx.ReplaceAll([&](const Replaceable* in) { - auto out_name = - cloned.Symbols().Register("replacement:" + original.Symbols().NameFor(in->name)); - auto b_name = - cloned.Symbols().Register("replacement-child:" + original.Symbols().NameFor(in->name)); + auto out_name = cloned.Symbols().Register("replacement:" + in->name.Name()); + auto b_name = cloned.Symbols().Register("replacement-child:" + in->name.Name()); auto* out = alloc.Create(out_name); out->b = alloc.Create(b_name); out->c = ctx.Clone(in->a); @@ -276,7 +274,7 @@ TEST_F(CloneContextNodeTest, CloneWithReplaceAll_Symbols) { ProgramBuilder cloned; auto* cloned_root = CloneContext(&cloned, &original, false) .ReplaceAll([&](Symbol sym) { - auto in = original.Symbols().NameFor(sym); + auto in = sym.Name(); auto out = "transformed<" + in + ">"; return cloned.Symbols().New(out); }) @@ -1173,9 +1171,9 @@ TEST_F(CloneContextTest, CloneNewUnnamedSymbols) { Symbol old_a = builder.Symbols().New(); Symbol old_b = builder.Symbols().New(); Symbol old_c = builder.Symbols().New(); - EXPECT_EQ(builder.Symbols().NameFor(old_a), "tint_symbol"); - EXPECT_EQ(builder.Symbols().NameFor(old_b), "tint_symbol_1"); - EXPECT_EQ(builder.Symbols().NameFor(old_c), "tint_symbol_2"); + EXPECT_EQ(old_a.Name(), "tint_symbol"); + EXPECT_EQ(old_b.Name(), "tint_symbol_1"); + EXPECT_EQ(old_c.Name(), "tint_symbol_2"); Program original(std::move(builder)); @@ -1188,12 +1186,12 @@ TEST_F(CloneContextTest, CloneNewUnnamedSymbols) { Symbol new_z = cloned.Symbols().New(); Symbol new_c = ctx.Clone(old_c); - EXPECT_EQ(cloned.Symbols().NameFor(new_x), "tint_symbol"); - EXPECT_EQ(cloned.Symbols().NameFor(new_a), "tint_symbol_1"); - EXPECT_EQ(cloned.Symbols().NameFor(new_y), "tint_symbol_2"); - EXPECT_EQ(cloned.Symbols().NameFor(new_b), "tint_symbol_1_1"); - EXPECT_EQ(cloned.Symbols().NameFor(new_z), "tint_symbol_3"); - EXPECT_EQ(cloned.Symbols().NameFor(new_c), "tint_symbol_2_1"); + EXPECT_EQ(new_x.Name(), "tint_symbol"); + EXPECT_EQ(new_a.Name(), "tint_symbol_1"); + EXPECT_EQ(new_y.Name(), "tint_symbol_2"); + EXPECT_EQ(new_b.Name(), "tint_symbol_1_1"); + EXPECT_EQ(new_z.Name(), "tint_symbol_3"); + EXPECT_EQ(new_c.Name(), "tint_symbol_2_1"); } TEST_F(CloneContextTest, CloneNewSymbols) { @@ -1201,9 +1199,9 @@ TEST_F(CloneContextTest, CloneNewSymbols) { Symbol old_a = builder.Symbols().New("a"); Symbol old_b = builder.Symbols().New("b"); Symbol old_c = builder.Symbols().New("c"); - EXPECT_EQ(builder.Symbols().NameFor(old_a), "a"); - EXPECT_EQ(builder.Symbols().NameFor(old_b), "b"); - EXPECT_EQ(builder.Symbols().NameFor(old_c), "c"); + EXPECT_EQ(old_a.Name(), "a"); + EXPECT_EQ(old_b.Name(), "b"); + EXPECT_EQ(old_c.Name(), "c"); Program original(std::move(builder)); @@ -1216,12 +1214,12 @@ TEST_F(CloneContextTest, CloneNewSymbols) { Symbol new_z = cloned.Symbols().New("c"); Symbol new_c = ctx.Clone(old_c); - EXPECT_EQ(cloned.Symbols().NameFor(new_x), "a"); - EXPECT_EQ(cloned.Symbols().NameFor(new_a), "a_1"); - EXPECT_EQ(cloned.Symbols().NameFor(new_y), "b"); - EXPECT_EQ(cloned.Symbols().NameFor(new_b), "b_1"); - EXPECT_EQ(cloned.Symbols().NameFor(new_z), "c"); - EXPECT_EQ(cloned.Symbols().NameFor(new_c), "c_1"); + EXPECT_EQ(new_x.Name(), "a"); + EXPECT_EQ(new_a.Name(), "a_1"); + EXPECT_EQ(new_y.Name(), "b"); + EXPECT_EQ(new_b.Name(), "b_1"); + EXPECT_EQ(new_z.Name(), "c"); + EXPECT_EQ(new_c.Name(), "c_1"); } TEST_F(CloneContextTest, CloneNewSymbols_AfterCloneSymbols) { @@ -1229,9 +1227,9 @@ TEST_F(CloneContextTest, CloneNewSymbols_AfterCloneSymbols) { Symbol old_a = builder.Symbols().New("a"); Symbol old_b = builder.Symbols().New("b"); Symbol old_c = builder.Symbols().New("c"); - EXPECT_EQ(builder.Symbols().NameFor(old_a), "a"); - EXPECT_EQ(builder.Symbols().NameFor(old_b), "b"); - EXPECT_EQ(builder.Symbols().NameFor(old_c), "c"); + EXPECT_EQ(old_a.Name(), "a"); + EXPECT_EQ(old_b.Name(), "b"); + EXPECT_EQ(old_c.Name(), "c"); Program original(std::move(builder)); @@ -1244,12 +1242,12 @@ TEST_F(CloneContextTest, CloneNewSymbols_AfterCloneSymbols) { Symbol new_z = cloned.Symbols().New("c"); Symbol new_c = ctx.Clone(old_c); - EXPECT_EQ(cloned.Symbols().NameFor(new_x), "a_1"); - EXPECT_EQ(cloned.Symbols().NameFor(new_a), "a"); - EXPECT_EQ(cloned.Symbols().NameFor(new_y), "b_1"); - EXPECT_EQ(cloned.Symbols().NameFor(new_b), "b"); - EXPECT_EQ(cloned.Symbols().NameFor(new_z), "c_1"); - EXPECT_EQ(cloned.Symbols().NameFor(new_c), "c"); + EXPECT_EQ(new_x.Name(), "a_1"); + EXPECT_EQ(new_a.Name(), "a"); + EXPECT_EQ(new_y.Name(), "b_1"); + EXPECT_EQ(new_b.Name(), "b"); + EXPECT_EQ(new_z.Name(), "c_1"); + EXPECT_EQ(new_c.Name(), "c"); } TEST_F(CloneContextTest, ProgramIDs) { diff --git a/src/tint/cmd/info.cc b/src/tint/cmd/info.cc index c31095c127..bc1a260904 100644 --- a/src/tint/cmd/info.cc +++ b/src/tint/cmd/info.cc @@ -237,7 +237,7 @@ void EmitJson(const tint::Program* program) { std::cout << std::endl; std::cout << "{" << std::endl; - std::cout << "\"name\": \"" << s->FriendlyName(program->Symbols()) << "\"," << std::endl; + std::cout << "\"name\": \"" << s->FriendlyName() << "\"," << std::endl; std::cout << "\"align\": " << s->Align() << "," << std::endl; std::cout << "\"size\": " << s->Size() << "," << std::endl; std::cout << "\"members\": ["; @@ -265,8 +265,7 @@ void EmitJson(const tint::Program* program) { } std::cout << "{" << std::endl; - std::cout << "\"name\": \"" << program->Symbols().NameFor(m->Name()) << "\"," - << std::endl; + std::cout << "\"name\": \"" << m->Name().Name() << "\"," << std::endl; std::cout << "\"offset\": " << m->Offset() << "," << std::endl; std::cout << "\"align\": " << m->Align() << "," << std::endl; std::cout << "\"size\": " << m->Size() << std::endl; @@ -307,7 +306,7 @@ void EmitText(const tint::Program* program) { continue; } const auto* s = ty->As(); - std::cout << s->Layout(program->Symbols()) << std::endl << std::endl; + std::cout << s->Layout() << std::endl << std::endl; } } } diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index 0b8b22c648..d2330e9043 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -133,8 +133,8 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) { auto* sem = program_->Sem().Get(func); - entry_point.name = program_->Symbols().NameFor(func->name->symbol); - entry_point.remapped_name = program_->Symbols().NameFor(func->name->symbol); + entry_point.name = func->name->symbol.Name(); + entry_point.remapped_name = func->name->symbol.Name(); switch (func->PipelineStage()) { case ast::PipelineStage::kCompute: { @@ -163,9 +163,9 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) { } for (auto* param : sem->Parameters()) { - AddEntryPointInOutVariables(program_->Symbols().NameFor(param->Declaration()->name->symbol), - param->Type(), param->Declaration()->attributes, - param->Location(), entry_point.input_variables); + AddEntryPointInOutVariables(param->Declaration()->name->symbol.Name(), param->Type(), + param->Declaration()->attributes, param->Location(), + entry_point.input_variables); entry_point.input_position_used |= ContainsBuiltin( builtin::BuiltinValue::kPosition, param->Type(), param->Declaration()->attributes); @@ -192,7 +192,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) { for (auto* var : sem->TransitivelyReferencedGlobals()) { auto* decl = var->Declaration(); - auto name = program_->Symbols().NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); auto* global = var->As(); if (global && global->Declaration()->Is()) { @@ -295,7 +295,7 @@ std::map Inspector::GetNamedOverrideIds() { for (auto* var : program_->AST().GlobalVariables()) { auto* global = program_->Sem().Get(var); if (global && global->Declaration()->Is()) { - auto name = program_->Symbols().NameFor(var->name->symbol); + auto name = var->name->symbol.Name(); result[name] = global->OverrideId(); } } @@ -619,9 +619,9 @@ void Inspector::AddEntryPointInOutVariables(std::string name, if (auto* struct_ty = unwrapped_type->As()) { // Recurse into members. for (auto* member : struct_ty->Members()) { - AddEntryPointInOutVariables(name + "." + program_->Symbols().NameFor(member->Name()), - member->Type(), member->Declaration()->attributes, - member->Location(), variables); + AddEntryPointInOutVariables(name + "." + member->Name().Name(), member->Type(), + member->Declaration()->attributes, member->Location(), + variables); } return; } @@ -838,8 +838,8 @@ void Inspector::GenerateSamplerTargets() { auto sampler_binding_point = globals[1]->BindingPoint(); for (auto* entry_point : entry_points) { - const auto& ep_name = program_->Symbols().NameFor( - entry_point->Declaration()->name->symbol); + const auto& ep_name = + entry_point->Declaration()->name->symbol.Name(); (*sampler_targets_)[ep_name].Add( {sampler_binding_point, texture_binding_point}); } diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index 9f92d6ded6..c351ec34bc 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -83,7 +83,7 @@ bool InspectorBuilder::ContainsName(utils::VectorRef vec, const s } std::string InspectorBuilder::StructMemberName(size_t idx, ast::Type type) { - return std::to_string(idx) + Symbols().NameFor(type->identifier->symbol); + return std::to_string(idx) + type->identifier->symbol.Name(); } const ast::Struct* InspectorBuilder::MakeStructType(const std::string& name, diff --git a/src/tint/ir/binary.cc b/src/tint/ir/binary.cc index cdec94d4e8..6cbf742731 100644 --- a/src/tint/ir/binary.cc +++ b/src/tint/ir/binary.cc @@ -29,9 +29,9 @@ Binary::Binary(Kind kind, Value* result, Value* lhs, Value* rhs) Binary::~Binary() = default; -utils::StringStream& Binary::ToString(utils::StringStream& out, const SymbolTable& st) const { - Result()->ToString(out, st) << " = "; - lhs_->ToString(out, st) << " "; +utils::StringStream& Binary::ToString(utils::StringStream& out) const { + Result()->ToString(out) << " = "; + lhs_->ToString(out) << " "; switch (GetKind()) { case Binary::Kind::kAdd: @@ -90,7 +90,7 @@ utils::StringStream& Binary::ToString(utils::StringStream& out, const SymbolTabl break; } out << " "; - rhs_->ToString(out, st); + rhs_->ToString(out); return out; } diff --git a/src/tint/ir/binary.h b/src/tint/ir/binary.h index 063bc935b6..bb74ea81cf 100644 --- a/src/tint/ir/binary.h +++ b/src/tint/ir/binary.h @@ -76,9 +76,8 @@ class Binary : public Castable { /// Write the instruction to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; private: Kind kind_; diff --git a/src/tint/ir/binary_test.cc b/src/tint/ir/binary_test.cc index 9f4ba19622..31972cea98 100644 --- a/src/tint/ir/binary_test.cc +++ b/src/tint/ir/binary_test.cc @@ -47,7 +47,7 @@ TEST_F(IR_InstructionTest, CreateAnd) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 & 2"); } @@ -74,7 +74,7 @@ TEST_F(IR_InstructionTest, CreateOr) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 | 2"); } @@ -101,7 +101,7 @@ TEST_F(IR_InstructionTest, CreateXor) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 ^ 2"); } @@ -128,7 +128,7 @@ TEST_F(IR_InstructionTest, CreateLogicalAnd) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 && 2"); } @@ -155,7 +155,7 @@ TEST_F(IR_InstructionTest, CreateLogicalOr) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 || 2"); } @@ -182,7 +182,7 @@ TEST_F(IR_InstructionTest, CreateEqual) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 == 2"); } @@ -209,7 +209,7 @@ TEST_F(IR_InstructionTest, CreateNotEqual) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 != 2"); } @@ -236,7 +236,7 @@ TEST_F(IR_InstructionTest, CreateLessThan) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 < 2"); } @@ -263,7 +263,7 @@ TEST_F(IR_InstructionTest, CreateGreaterThan) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 > 2"); } @@ -290,7 +290,7 @@ TEST_F(IR_InstructionTest, CreateLessThanEqual) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 <= 2"); } @@ -317,7 +317,7 @@ TEST_F(IR_InstructionTest, CreateGreaterThanEqual) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (bool) = 4 >= 2"); } @@ -344,7 +344,7 @@ TEST_F(IR_InstructionTest, CreateShiftLeft) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 << 2"); } @@ -371,7 +371,7 @@ TEST_F(IR_InstructionTest, CreateShiftRight) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 >> 2"); } @@ -398,7 +398,7 @@ TEST_F(IR_InstructionTest, CreateAdd) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 + 2"); } @@ -425,7 +425,7 @@ TEST_F(IR_InstructionTest, CreateSubtract) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 - 2"); } @@ -452,7 +452,7 @@ TEST_F(IR_InstructionTest, CreateMultiply) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 * 2"); } @@ -479,7 +479,7 @@ TEST_F(IR_InstructionTest, CreateDivide) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 / 2"); } @@ -506,7 +506,7 @@ TEST_F(IR_InstructionTest, CreateModulo) { EXPECT_EQ(2_i, rhs->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = 4 % 2"); } diff --git a/src/tint/ir/bitcast.cc b/src/tint/ir/bitcast.cc index 3cf0c97db1..749702eab6 100644 --- a/src/tint/ir/bitcast.cc +++ b/src/tint/ir/bitcast.cc @@ -26,10 +26,10 @@ Bitcast::Bitcast(Value* result, Value* val) : Base(result), val_(val) { Bitcast::~Bitcast() = default; -utils::StringStream& Bitcast::ToString(utils::StringStream& out, const SymbolTable& st) const { - Result()->ToString(out, st); +utils::StringStream& Bitcast::ToString(utils::StringStream& out) const { + Result()->ToString(out); out << " = bitcast("; - val_->ToString(out, st); + val_->ToString(out); out << ")"; return out; } diff --git a/src/tint/ir/bitcast.h b/src/tint/ir/bitcast.h index 0178066cb4..7e9f7dbcb1 100644 --- a/src/tint/ir/bitcast.h +++ b/src/tint/ir/bitcast.h @@ -42,9 +42,8 @@ class Bitcast : public Castable { /// Write the instruction to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; private: Value* val_ = nullptr; diff --git a/src/tint/ir/bitcast_test.cc b/src/tint/ir/bitcast_test.cc index 38ae9b2750..b46c334805 100644 --- a/src/tint/ir/bitcast_test.cc +++ b/src/tint/ir/bitcast_test.cc @@ -40,7 +40,7 @@ TEST_F(IR_InstructionTest, Bitcast) { EXPECT_EQ(4_i, val->As>()->ValueAs()); utils::StringStream str; - instr->ToString(str, b.builder.ir.symbols); + instr->ToString(str); EXPECT_EQ(str.str(), "%42 (i32) = bitcast(4)"); } diff --git a/src/tint/ir/builder_impl.cc b/src/tint/ir/builder_impl.cc index ba63be6adb..c6c6ed0422 100644 --- a/src/tint/ir/builder_impl.cc +++ b/src/tint/ir/builder_impl.cc @@ -146,7 +146,7 @@ FlowNode* BuilderImpl::FindEnclosingControl(ControlFlags flags) { } Symbol BuilderImpl::CloneSymbol(Symbol sym) const { - return clone_ctx_.type_ctx.dst.st->Register(clone_ctx_.type_ctx.src.st->NameFor(sym)); + return clone_ctx_.type_ctx.dst.st->Register(sym.Name()); } ResultType BuilderImpl::Build() { diff --git a/src/tint/ir/builtin.cc b/src/tint/ir/builtin.cc index e9acf66394..423779789a 100644 --- a/src/tint/ir/builtin.cc +++ b/src/tint/ir/builtin.cc @@ -25,10 +25,10 @@ Builtin::Builtin(Value* result, builtin::Function func, utils::VectorRef Builtin::~Builtin() = default; -utils::StringStream& Builtin::ToString(utils::StringStream& out, const SymbolTable& st) const { - Result()->ToString(out, st); +utils::StringStream& Builtin::ToString(utils::StringStream& out) const { + Result()->ToString(out); out << " = " << builtin::str(func_) << "("; - EmitArgs(out, st); + EmitArgs(out); out << ")"; return out; } diff --git a/src/tint/ir/builtin.h b/src/tint/ir/builtin.h index 0385c6cb7f..4fc8a76e03 100644 --- a/src/tint/ir/builtin.h +++ b/src/tint/ir/builtin.h @@ -44,9 +44,8 @@ class Builtin : public Castable { /// Write the instruction to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; private: const builtin::Function func_; diff --git a/src/tint/ir/call.cc b/src/tint/ir/call.cc index 9dda1f9fb1..b8012603f0 100644 --- a/src/tint/ir/call.cc +++ b/src/tint/ir/call.cc @@ -26,14 +26,14 @@ Call::Call(Value* result, utils::VectorRef args) : Base(result), args_(a Call::~Call() = default; -void Call::EmitArgs(utils::StringStream& out, const SymbolTable& st) const { +void Call::EmitArgs(utils::StringStream& out) const { bool first = true; for (const auto* arg : args_) { if (!first) { out << ", "; } first = false; - arg->ToString(out, st); + arg->ToString(out); } } diff --git a/src/tint/ir/call.h b/src/tint/ir/call.h index d6ced3f069..e1f9d481c5 100644 --- a/src/tint/ir/call.h +++ b/src/tint/ir/call.h @@ -42,8 +42,7 @@ class Call : public Castable { /// Writes the call arguments to the given stream. /// @param out the output stream - /// @param st the symbol table - void EmitArgs(utils::StringStream& out, const SymbolTable& st) const; + void EmitArgs(utils::StringStream& out) const; private: utils::Vector args_; diff --git a/src/tint/ir/constant.cc b/src/tint/ir/constant.cc index 61610b0995..403661652e 100644 --- a/src/tint/ir/constant.cc +++ b/src/tint/ir/constant.cc @@ -29,7 +29,7 @@ Constant::Constant(const constant::Value* val) : value(val) {} Constant::~Constant() = default; -utils::StringStream& Constant::ToString(utils::StringStream& out, const SymbolTable& st) const { +utils::StringStream& Constant::ToString(utils::StringStream& out) const { std::function emit = [&](const constant::Value* c) { Switch( c, @@ -43,12 +43,12 @@ utils::StringStream& Constant::ToString(utils::StringStream& out, const SymbolTa out << (scalar->ValueAs() ? "true" : "false"); }, [&](const constant::Splat* splat) { - out << splat->Type()->FriendlyName(st) << "("; + out << splat->Type()->FriendlyName() << "("; emit(splat->Index(0)); out << ")"; }, [&](const constant::Composite* composite) { - out << composite->Type()->FriendlyName(st) << "("; + out << composite->Type()->FriendlyName() << "("; for (const auto* elem : composite->elements) { if (elem != composite->elements[0]) { out << ", "; diff --git a/src/tint/ir/constant.h b/src/tint/ir/constant.h index 1c4088f947..7be3688d51 100644 --- a/src/tint/ir/constant.h +++ b/src/tint/ir/constant.h @@ -35,9 +35,8 @@ class Constant : public Castable { /// Write the constant to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; /// The constants value const constant::Value* const value; diff --git a/src/tint/ir/constant_test.cc b/src/tint/ir/constant_test.cc index f3a1dc0c68..f407cdb561 100644 --- a/src/tint/ir/constant_test.cc +++ b/src/tint/ir/constant_test.cc @@ -31,7 +31,7 @@ TEST_F(IR_ConstantTest, f32) { auto* c = b.builder.Constant(1.2_f); EXPECT_EQ(1.2_f, c->value->As>()->ValueAs()); - c->ToString(str, b.builder.ir.symbols); + c->ToString(str); EXPECT_EQ("1.20000004768371582031", str.str()); EXPECT_TRUE(c->value->Is>()); @@ -49,7 +49,7 @@ TEST_F(IR_ConstantTest, f16) { auto* c = b.builder.Constant(1.1_h); EXPECT_EQ(1.1_h, c->value->As>()->ValueAs()); - c->ToString(str, b.builder.ir.symbols); + c->ToString(str); EXPECT_EQ("1.099609375", str.str()); EXPECT_FALSE(c->value->Is>()); @@ -67,7 +67,7 @@ TEST_F(IR_ConstantTest, i32) { auto* c = b.builder.Constant(1_i); EXPECT_EQ(1_i, c->value->As>()->ValueAs()); - c->ToString(str, b.builder.ir.symbols); + c->ToString(str); EXPECT_EQ("1", str.str()); EXPECT_FALSE(c->value->Is>()); @@ -85,7 +85,7 @@ TEST_F(IR_ConstantTest, u32) { auto* c = b.builder.Constant(2_u); EXPECT_EQ(2_u, c->value->As>()->ValueAs()); - c->ToString(str, b.builder.ir.symbols); + c->ToString(str); EXPECT_EQ("2", str.str()); EXPECT_FALSE(c->value->Is>()); @@ -104,7 +104,7 @@ TEST_F(IR_ConstantTest, bool) { auto* c = b.builder.Constant(false); EXPECT_FALSE(c->value->As>()->ValueAs()); - c->ToString(str, b.builder.ir.symbols); + c->ToString(str); EXPECT_EQ("false", str.str()); } @@ -113,7 +113,7 @@ TEST_F(IR_ConstantTest, bool) { auto c = b.builder.Constant(true); EXPECT_TRUE(c->value->As>()->ValueAs()); - c->ToString(str, b.builder.ir.symbols); + c->ToString(str); EXPECT_EQ("true", str.str()); EXPECT_FALSE(c->value->Is>()); diff --git a/src/tint/ir/construct.cc b/src/tint/ir/construct.cc index 27bb084d19..595075ba0f 100644 --- a/src/tint/ir/construct.cc +++ b/src/tint/ir/construct.cc @@ -23,12 +23,12 @@ Construct::Construct(Value* result, utils::VectorRef args) : Base(result Construct::~Construct() = default; -utils::StringStream& Construct::ToString(utils::StringStream& out, const SymbolTable& st) const { - Result()->ToString(out, st); - out << " = construct(" << Result()->Type()->FriendlyName(st); +utils::StringStream& Construct::ToString(utils::StringStream& out) const { + Result()->ToString(out); + out << " = construct(" << Result()->Type()->FriendlyName(); if (!Args().IsEmpty()) { out << ", "; - EmitArgs(out, st); + EmitArgs(out); } out << ")"; return out; diff --git a/src/tint/ir/construct.h b/src/tint/ir/construct.h index 6f620d3e6a..24449b689d 100644 --- a/src/tint/ir/construct.h +++ b/src/tint/ir/construct.h @@ -39,9 +39,8 @@ class Construct : public Castable { /// Write the instruction to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; }; } // namespace tint::ir diff --git a/src/tint/ir/convert.cc b/src/tint/ir/convert.cc index e845adb6e1..ed312504c3 100644 --- a/src/tint/ir/convert.cc +++ b/src/tint/ir/convert.cc @@ -24,11 +24,11 @@ Convert::Convert(Value* result, const type::Type* from, utils::VectorRef Convert::~Convert() = default; -utils::StringStream& Convert::ToString(utils::StringStream& out, const SymbolTable& st) const { - Result()->ToString(out, st); - out << " = convert(" << Result()->Type()->FriendlyName(st) << ", " << from_->FriendlyName(st) +utils::StringStream& Convert::ToString(utils::StringStream& out) const { + Result()->ToString(out); + out << " = convert(" << Result()->Type()->FriendlyName() << ", " << from_->FriendlyName() << ", "; - EmitArgs(out, st); + EmitArgs(out); out << ")"; return out; } diff --git a/src/tint/ir/convert.h b/src/tint/ir/convert.h index 5132248ba6..3b8878bbf4 100644 --- a/src/tint/ir/convert.h +++ b/src/tint/ir/convert.h @@ -45,9 +45,8 @@ class Convert : public Castable { /// Write the instruction to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; private: const type::Type* from_ = nullptr; diff --git a/src/tint/ir/debug.cc b/src/tint/ir/debug.cc index eb7d40f845..f69805e5de 100644 --- a/src/tint/ir/debug.cc +++ b/src/tint/ir/debug.cc @@ -145,7 +145,7 @@ std::string Debug::AsDotGraph(const Module* mod) { for (const auto* func : mod->functions) { // Cluster each function to label and draw a box around it. out << "subgraph cluster_" << name_for(func) << " {" << std::endl; - out << R"(label=")" << mod->symbols.NameFor(func->name) << R"(")" << std::endl; + out << R"(label=")" << func->name.Name() << R"(")" << std::endl; out << name_for(func->start_target) << R"( [label="start"])" << std::endl; out << name_for(func->end_target) << R"( [label="end"])" << std::endl; Graph(func->start_target); diff --git a/src/tint/ir/disassembler.cc b/src/tint/ir/disassembler.cc index 041495d03f..c3bb0061e1 100644 --- a/src/tint/ir/disassembler.cc +++ b/src/tint/ir/disassembler.cc @@ -64,7 +64,7 @@ utils::StringStream& Disassembler::Indent() { void Disassembler::EmitBlockInstructions(const Block* b) { for (const auto* instr : b->instructions) { Indent(); - instr->ToString(out_, mod_.symbols) << std::endl; + instr->ToString(out_) << std::endl; } } @@ -89,8 +89,7 @@ void Disassembler::Walk(const FlowNode* node) { tint::Switch( node, [&](const ir::Function* f) { - Indent() << "%bb" << GetIdForNode(f) << " = Function " << mod_.symbols.NameFor(f->name) - << std::endl; + Indent() << "%bb" << GetIdForNode(f) << " = Function " << f->name.Name() << std::endl; { ScopedIndent func_indent(&indent_size_); @@ -120,7 +119,7 @@ void Disassembler::Walk(const FlowNode* node) { if (v != b->branch.args.Front()) { out_ << ", "; } - v->ToString(out_, mod_.symbols); + v->ToString(out_); } out_ << ")" << std::endl; @@ -132,7 +131,7 @@ void Disassembler::Walk(const FlowNode* node) { }, [&](const ir::Switch* s) { Indent() << "%bb" << GetIdForNode(s) << " = Switch ("; - s->condition->ToString(out_, mod_.symbols); + s->condition->ToString(out_); out_ << ")" << std::endl; { @@ -148,7 +147,7 @@ void Disassembler::Walk(const FlowNode* node) { if (selector.IsDefault()) { out_ << "default"; } else { - selector.val->ToString(out_, mod_.symbols); + selector.val->ToString(out_); } } out_ << std::endl; @@ -161,7 +160,7 @@ void Disassembler::Walk(const FlowNode* node) { }, [&](const ir::If* i) { Indent() << "%bb" << GetIdForNode(i) << " = if ("; - i->condition->ToString(out_, mod_.symbols); + i->condition->ToString(out_); out_ << ")" << std::endl; { diff --git a/src/tint/ir/instruction.h b/src/tint/ir/instruction.h index 9d09fcb6d9..8ae2de43bd 100644 --- a/src/tint/ir/instruction.h +++ b/src/tint/ir/instruction.h @@ -38,10 +38,8 @@ class Instruction : public Castable { /// Write the instruction to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - virtual utils::StringStream& ToString(utils::StringStream& out, - const SymbolTable& st) const = 0; + virtual utils::StringStream& ToString(utils::StringStream& out) const = 0; protected: /// Constructor diff --git a/src/tint/ir/temp.cc b/src/tint/ir/temp.cc index 3efae03db1..b6c9a8e3b8 100644 --- a/src/tint/ir/temp.cc +++ b/src/tint/ir/temp.cc @@ -24,8 +24,8 @@ Temp::Temp(const type::Type* type, Id id) : type_(type), id_(id) {} Temp::~Temp() = default; -utils::StringStream& Temp::ToString(utils::StringStream& out, const SymbolTable& st) const { - out << "%" << std::to_string(AsId()) << " (" << type_->FriendlyName(st) << ")"; +utils::StringStream& Temp::ToString(utils::StringStream& out) const { + out << "%" << std::to_string(AsId()) << " (" << type_->FriendlyName() << ")"; return out; } diff --git a/src/tint/ir/temp.h b/src/tint/ir/temp.h index 8532a450e2..94330999e4 100644 --- a/src/tint/ir/temp.h +++ b/src/tint/ir/temp.h @@ -49,9 +49,8 @@ class Temp : public Castable { /// Write the temp to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; private: const type::Type* type_ = nullptr; diff --git a/src/tint/ir/temp_test.cc b/src/tint/ir/temp_test.cc index e73dd34223..edd002bae5 100644 --- a/src/tint/ir/temp_test.cc +++ b/src/tint/ir/temp_test.cc @@ -32,7 +32,7 @@ TEST_F(IR_TempTest, id) { auto* val = b.builder.Temp(b.builder.ir.types.Get()); EXPECT_EQ(4u, val->AsId()); - val->ToString(str, b.builder.ir.symbols); + val->ToString(str); EXPECT_EQ("%4 (i32)", str.str()); } diff --git a/src/tint/ir/user_call.cc b/src/tint/ir/user_call.cc index cf672cf8d8..9a1f7eb63d 100644 --- a/src/tint/ir/user_call.cc +++ b/src/tint/ir/user_call.cc @@ -24,11 +24,11 @@ UserCall::UserCall(Value* result, Symbol name, utils::VectorRef args) UserCall::~UserCall() = default; -utils::StringStream& UserCall::ToString(utils::StringStream& out, const SymbolTable& st) const { - Result()->ToString(out, st); +utils::StringStream& UserCall::ToString(utils::StringStream& out) const { + Result()->ToString(out); out << " = call("; - out << st.NameFor(name_) << ", "; - EmitArgs(out, st); + out << name_.Name() << ", "; + EmitArgs(out); out << ")"; return out; } diff --git a/src/tint/ir/user_call.h b/src/tint/ir/user_call.h index 2edeecb6d5..34215ed931 100644 --- a/src/tint/ir/user_call.h +++ b/src/tint/ir/user_call.h @@ -43,9 +43,8 @@ class UserCall : public Castable { /// Write the instruction to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - utils::StringStream& ToString(utils::StringStream& out, const SymbolTable& st) const override; + utils::StringStream& ToString(utils::StringStream& out) const override; private: Symbol name_{}; diff --git a/src/tint/ir/value.h b/src/tint/ir/value.h index b3ec7ef50e..2d4fcb0b4f 100644 --- a/src/tint/ir/value.h +++ b/src/tint/ir/value.h @@ -53,10 +53,8 @@ class Value : public Castable { /// Write the value to the given stream /// @param out the stream to write to - /// @param st the symbol table /// @returns the stream - virtual utils::StringStream& ToString(utils::StringStream& out, - const SymbolTable& st) const = 0; + virtual utils::StringStream& ToString(utils::StringStream& out) const = 0; protected: /// Constructor diff --git a/src/tint/program.cc b/src/tint/program.cc index 643999d3d3..c8466f520f 100644 --- a/src/tint/program.cc +++ b/src/tint/program.cc @@ -136,11 +136,11 @@ const type::Type* Program::TypeOf(const ast::TypeDecl* type_decl) const { std::string Program::FriendlyName(ast::Type type) const { TINT_ASSERT_PROGRAM_IDS_EQUAL(Program, type, ID()); - return type ? Symbols().NameFor(type->identifier->symbol) : ""; + return type ? type->identifier->symbol.Name() : ""; } std::string Program::FriendlyName(const type::Type* type) const { - return type ? type->FriendlyName(Symbols()) : ""; + return type ? type->FriendlyName() : ""; } std::string Program::FriendlyName(std::nullptr_t) const { diff --git a/src/tint/program_builder.cc b/src/tint/program_builder.cc index bfb7edbc81..4181f96744 100644 --- a/src/tint/program_builder.cc +++ b/src/tint/program_builder.cc @@ -115,11 +115,11 @@ const type::Type* ProgramBuilder::TypeOf(const ast::TypeDecl* type_decl) const { std::string ProgramBuilder::FriendlyName(ast::Type type) const { TINT_ASSERT_PROGRAM_IDS_EQUAL(ProgramBuilder, type, ID()); - return type.expr ? Symbols().NameFor(type->identifier->symbol) : ""; + return type.expr ? type->identifier->symbol.Name() : ""; } std::string ProgramBuilder::FriendlyName(const type::Type* type) const { - return type ? type->FriendlyName(Symbols()) : ""; + return type ? type->FriendlyName() : ""; } std::string ProgramBuilder::FriendlyName(std::nullptr_t) const { diff --git a/src/tint/reader/spirv/parser_impl_test_helper.cc b/src/tint/reader/spirv/parser_impl_test_helper.cc index 4a57379e14..697a51be91 100644 --- a/src/tint/reader/spirv/parser_impl_test_helper.cc +++ b/src/tint/reader/spirv/parser_impl_test_helper.cc @@ -75,7 +75,7 @@ std::string ToString(const Program& program, const ast::Node* node) { } return writer.result(); }, - [&](const ast::Identifier* ident) { return program.Symbols().NameFor(ident->symbol); }, + [&](const ast::Identifier* ident) { return ident->symbol.Name(); }, [&](Default) { return "TypeInfo().name) + ">"; }); diff --git a/src/tint/reader/wgsl/parser_impl_call_stmt_test.cc b/src/tint/reader/wgsl/parser_impl_call_stmt_test.cc index 63f957413d..5fd1b59757 100644 --- a/src/tint/reader/wgsl/parser_impl_call_stmt_test.cc +++ b/src/tint/reader/wgsl/parser_impl_call_stmt_test.cc @@ -35,7 +35,7 @@ TEST_F(ParserImplTest, Statement_Call) { ASSERT_TRUE(e->Is()); auto* c = e->As()->expr; - ast::CheckIdentifier(p->builder().Symbols(), c->target, "a"); + ast::CheckIdentifier(c->target, "a"); EXPECT_EQ(c->args.Length(), 0u); } @@ -51,7 +51,7 @@ TEST_F(ParserImplTest, Statement_Call_WithParams) { ASSERT_TRUE(e->Is()); auto* c = e->As()->expr; - ast::CheckIdentifier(p->builder().Symbols(), c->target, "a"); + ast::CheckIdentifier(c->target, "a"); EXPECT_EQ(c->args.Length(), 3u); EXPECT_TRUE(c->args[0]->Is()); @@ -70,7 +70,7 @@ TEST_F(ParserImplTest, Statement_Call_WithParams_TrailingComma) { ASSERT_TRUE(e->Is()); auto* c = e->As()->expr; - ast::CheckIdentifier(p->builder().Symbols(), c->target, "a"); + ast::CheckIdentifier(c->target, "a"); EXPECT_EQ(c->args.Length(), 2u); EXPECT_TRUE(c->args[0]->Is()); diff --git a/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc index 5c54e93c83..991d5b656d 100644 --- a/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc @@ -30,7 +30,7 @@ TEST_F(ParserImplTest, DiagnosticAttribute_Valid) { EXPECT_EQ(d->control.severity, builtin::DiagnosticSeverity::kOff); auto* r = d->control.rule_name; ASSERT_NE(r, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), r, "foo"); + ast::CheckIdentifier(r, "foo"); } } // namespace diff --git a/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc b/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc index 81ce1781b3..e45d1e701a 100644 --- a/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc +++ b/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc @@ -33,7 +33,7 @@ TEST_P(DiagnosticControlParserTest, DiagnosticControl_Valid) { auto* r = e->rule_name; ASSERT_NE(r, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), r, "foo"); + ast::CheckIdentifier(r, "foo"); } INSTANTIATE_TEST_SUITE_P(DiagnosticControlParserTest, DiagnosticControlParserTest, @@ -52,7 +52,7 @@ TEST_F(ParserImplTest, DiagnosticControl_Valid_TrailingComma) { auto* r = e->rule_name; ASSERT_NE(r, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), r, "foo"); + ast::CheckIdentifier(r, "foo"); } TEST_F(ParserImplTest, DiagnosticControl_MissingOpenParen) { diff --git a/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc b/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc index b2f987ce1d..12b69f1071 100644 --- a/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc +++ b/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc @@ -33,7 +33,7 @@ TEST_F(ParserImplTest, DiagnosticDirective_Valid) { auto* r = directive->control.rule_name; ASSERT_NE(r, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), r, "foo"); + ast::CheckIdentifier(r, "foo"); } TEST_F(ParserImplTest, DiagnosticDirective_MissingSemicolon) { diff --git a/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc index 5e96d8eacc..8f0512b5c9 100644 --- a/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc @@ -311,7 +311,7 @@ TEST_F(ParserImplTest, Attribute_Workgroup_WithIdent) { ast::IntLiteralExpression::Suffix::kNone); ASSERT_NE(values[1], nullptr); - ast::CheckIdentifier(p->builder().Symbols(), values[1], "height"); + ast::CheckIdentifier(values[1], "height"); ASSERT_EQ(values[2], nullptr); } diff --git a/src/tint/reader/wgsl/parser_impl_function_decl_test.cc b/src/tint/reader/wgsl/parser_impl_function_decl_test.cc index 3888326f02..052f786a9b 100644 --- a/src/tint/reader/wgsl/parser_impl_function_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_function_decl_test.cc @@ -241,7 +241,7 @@ TEST_F(ParserImplTest, FunctionDecl_ReturnTypeAttributeList) { EXPECT_EQ(f->name->symbol, p->builder().Symbols().Get("main")); ASSERT_NE(f->return_type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), f->return_type, "f32"); + ast::CheckIdentifier(f->return_type, "f32"); ASSERT_EQ(f->params.Length(), 0u); diff --git a/src/tint/reader/wgsl/parser_impl_function_header_test.cc b/src/tint/reader/wgsl/parser_impl_function_header_test.cc index f68ea69cb2..d92fef099a 100644 --- a/src/tint/reader/wgsl/parser_impl_function_header_test.cc +++ b/src/tint/reader/wgsl/parser_impl_function_header_test.cc @@ -53,7 +53,7 @@ TEST_F(ParserImplTest, FunctionHeader_AttributeReturnType) { EXPECT_EQ(f->name, "main"); EXPECT_EQ(f->params.Length(), 0u); - ast::CheckIdentifier(p->builder().Symbols(), f->return_type, "f32"); + ast::CheckIdentifier(f->return_type, "f32"); ASSERT_EQ(f->return_type_attributes.Length(), 1u); auto* loc = f->return_type_attributes[0]->As(); @@ -72,7 +72,7 @@ TEST_F(ParserImplTest, FunctionHeader_InvariantReturnType) { EXPECT_EQ(f->name, "main"); EXPECT_EQ(f->params.Length(), 0u); - ast::CheckIdentifier(p->builder().Symbols(), f->return_type, "f32"); + ast::CheckIdentifier(f->return_type, "f32"); ASSERT_EQ(f->return_type_attributes.Length(), 1u); EXPECT_TRUE(f->return_type_attributes[0]->Is()); } diff --git a/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc b/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc index 98f3de1106..ecfdfbc14c 100644 --- a/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc @@ -45,7 +45,7 @@ TEST_F(ParserImplTest, GlobalConstDecl) { EXPECT_EQ(c->name->symbol, p->builder().Symbols().Get("a")); ASSERT_NE(c->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), c->type, "f32"); + ast::CheckIdentifier(c->type, "f32"); EXPECT_EQ(c->source.range.begin.line, 1u); EXPECT_EQ(c->source.range.begin.column, 7u); @@ -121,7 +121,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId) { EXPECT_EQ(override->name->symbol, p->builder().Symbols().Get("a")); ASSERT_NE(override->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), override->type, "f32"); + ast::CheckIdentifier(override->type, "f32"); EXPECT_EQ(override->source.range.begin.line, 1u); EXPECT_EQ(override->source.range.begin.column, 17u); @@ -151,7 +151,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId_TrailingComma) { EXPECT_EQ(override->name->symbol, p->builder().Symbols().Get("a")); ASSERT_NE(override->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), override->type, "f32"); + ast::CheckIdentifier(override->type, "f32"); EXPECT_EQ(override->source.range.begin.line, 1u); EXPECT_EQ(override->source.range.begin.column, 18u); @@ -181,7 +181,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithoutId) { EXPECT_EQ(override->name->symbol, p->builder().Symbols().Get("a")); ASSERT_NE(override->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), override->type, "f32"); + ast::CheckIdentifier(override->type, "f32"); EXPECT_EQ(override->source.range.begin.line, 1u); EXPECT_EQ(override->source.range.begin.column, 10u); diff --git a/src/tint/reader/wgsl/parser_impl_global_decl_test.cc b/src/tint/reader/wgsl/parser_impl_global_decl_test.cc index 697475ead9..d2a6a74aca 100644 --- a/src/tint/reader/wgsl/parser_impl_global_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_global_decl_test.cc @@ -34,7 +34,7 @@ TEST_F(ParserImplTest, GlobalDecl_GlobalVariable) { auto* v = program.AST().GlobalVariables()[0]; EXPECT_EQ(v->name->symbol, program.Symbols().Get("a")); - ast::CheckIdentifier(program.Symbols(), v->type, ast::Template("vec2", "i32")); + ast::CheckIdentifier(v->type, ast::Template("vec2", "i32")); } TEST_F(ParserImplTest, GlobalDecl_GlobalVariable_Inferred) { @@ -107,8 +107,7 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) { auto program = p->program(); ASSERT_EQ(program.AST().TypeDecls().Length(), 1u); ASSERT_TRUE(program.AST().TypeDecls()[0]->Is()); - ast::CheckIdentifier(program.Symbols(), program.AST().TypeDecls()[0]->As()->name, - "A"); + ast::CheckIdentifier(program.AST().TypeDecls()[0]->As()->name, "A"); } TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) { @@ -129,7 +128,7 @@ alias B = A;)"); ASSERT_TRUE(program.AST().TypeDecls()[1]->Is()); auto* alias = program.AST().TypeDecls()[1]->As(); EXPECT_EQ(alias->name->symbol, program.Symbols().Get("B")); - ast::CheckIdentifier(program.Symbols(), alias->type, "A"); + ast::CheckIdentifier(alias->type, "A"); } TEST_F(ParserImplTest, GlobalDecl_TypeAlias_MissingSemicolon) { @@ -146,7 +145,7 @@ TEST_F(ParserImplTest, GlobalDecl_Function) { auto program = p->program(); ASSERT_EQ(program.AST().Functions().Length(), 1u); - ast::CheckIdentifier(program.Symbols(), program.AST().Functions()[0]->name, "main"); + ast::CheckIdentifier(program.AST().Functions()[0]->name, "main"); } TEST_F(ParserImplTest, GlobalDecl_Function_WithAttribute) { @@ -156,7 +155,7 @@ TEST_F(ParserImplTest, GlobalDecl_Function_WithAttribute) { auto program = p->program(); ASSERT_EQ(program.AST().Functions().Length(), 1u); - ast::CheckIdentifier(program.Symbols(), program.AST().Functions()[0]->name, "main"); + ast::CheckIdentifier(program.AST().Functions()[0]->name, "main"); } TEST_F(ParserImplTest, GlobalDecl_Function_Invalid) { diff --git a/src/tint/reader/wgsl/parser_impl_global_variable_decl_test.cc b/src/tint/reader/wgsl/parser_impl_global_variable_decl_test.cc index a5de0a90ba..f83438d9d0 100644 --- a/src/tint/reader/wgsl/parser_impl_global_variable_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_global_variable_decl_test.cc @@ -30,9 +30,9 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutInitializer) { auto* var = e.value->As(); ASSERT_NE(var, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), var->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), var->type, "f32"); - ast::CheckIdentifier(p->builder().Symbols(), var->declared_address_space, "private"); + ast::CheckIdentifier(var->name, "a"); + ast::CheckIdentifier(var->type, "f32"); + ast::CheckIdentifier(var->declared_address_space, "private"); EXPECT_EQ(var->source.range.begin.line, 1u); EXPECT_EQ(var->source.range.begin.column, 14u); @@ -54,9 +54,9 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithInitializer) { auto* var = e.value->As(); ASSERT_NE(var, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), var->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), var->type, "f32"); - ast::CheckIdentifier(p->builder().Symbols(), var->declared_address_space, "private"); + ast::CheckIdentifier(var->name, "a"); + ast::CheckIdentifier(var->type, "f32"); + ast::CheckIdentifier(var->declared_address_space, "private"); EXPECT_EQ(var->source.range.begin.line, 1u); EXPECT_EQ(var->source.range.begin.column, 14u); @@ -79,9 +79,9 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithAttribute) { auto* var = e.value->As(); ASSERT_NE(var, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), var->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), var->type, "f32"); - ast::CheckIdentifier(p->builder().Symbols(), var->declared_address_space, "uniform"); + ast::CheckIdentifier(var->name, "a"); + ast::CheckIdentifier(var->type, "f32"); + ast::CheckIdentifier(var->declared_address_space, "uniform"); EXPECT_EQ(var->source.range.begin.line, 1u); EXPECT_EQ(var->source.range.begin.column, 36u); @@ -109,9 +109,9 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithAttribute_MulitpleGroups) { auto* var = e.value->As(); ASSERT_NE(var, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), var->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), var->type, "f32"); - ast::CheckIdentifier(p->builder().Symbols(), var->declared_address_space, "uniform"); + ast::CheckIdentifier(var->name, "a"); + ast::CheckIdentifier(var->type, "f32"); + ast::CheckIdentifier(var->declared_address_space, "uniform"); EXPECT_EQ(var->source.range.begin.line, 1u); EXPECT_EQ(var->source.range.begin.column, 36u); diff --git a/src/tint/reader/wgsl/parser_impl_param_list_test.cc b/src/tint/reader/wgsl/parser_impl_param_list_test.cc index eb4db4570e..1ebd651c79 100644 --- a/src/tint/reader/wgsl/parser_impl_param_list_test.cc +++ b/src/tint/reader/wgsl/parser_impl_param_list_test.cc @@ -27,7 +27,7 @@ TEST_F(ParserImplTest, ParamList_Single) { EXPECT_EQ(e.value.Length(), 1u); EXPECT_EQ(e.value[0]->name->symbol, p->builder().Symbols().Get("a")); - ast::CheckIdentifier(p->builder().Symbols(), e.value[0]->type, "i32"); + ast::CheckIdentifier(e.value[0]->type, "i32"); EXPECT_TRUE(e.value[0]->Is()); ASSERT_EQ(e.value[0]->source.range.begin.line, 1u); @@ -45,7 +45,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) { EXPECT_EQ(e.value.Length(), 3u); EXPECT_EQ(e.value[0]->name->symbol, p->builder().Symbols().Get("a")); - ast::CheckIdentifier(p->builder().Symbols(), e.value[0]->type, "i32"); + ast::CheckIdentifier(e.value[0]->type, "i32"); EXPECT_TRUE(e.value[0]->Is()); ASSERT_EQ(e.value[0]->source.range.begin.line, 1u); @@ -54,7 +54,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) { ASSERT_EQ(e.value[0]->source.range.end.column, 2u); EXPECT_EQ(e.value[1]->name->symbol, p->builder().Symbols().Get("b")); - ast::CheckIdentifier(p->builder().Symbols(), e.value[1]->type, "f32"); + ast::CheckIdentifier(e.value[1]->type, "f32"); EXPECT_TRUE(e.value[1]->Is()); ASSERT_EQ(e.value[1]->source.range.begin.line, 1u); @@ -63,7 +63,7 @@ TEST_F(ParserImplTest, ParamList_Multiple) { ASSERT_EQ(e.value[1]->source.range.end.column, 11u); EXPECT_EQ(e.value[2]->name->symbol, p->builder().Symbols().Get("c")); - ast::CheckIdentifier(p->builder().Symbols(), e.value[2]->type, ast::Template("vec2", "f32")); + ast::CheckIdentifier(e.value[2]->type, ast::Template("vec2", "f32")); EXPECT_TRUE(e.value[2]->Is()); ASSERT_EQ(e.value[2]->source.range.begin.line, 1u); @@ -97,13 +97,12 @@ TEST_F(ParserImplTest, ParamList_Attributes) { ASSERT_EQ(e.value.Length(), 2u); EXPECT_EQ(e.value[0]->name->symbol, p->builder().Symbols().Get("coord")); - ast::CheckIdentifier(p->builder().Symbols(), e.value[0]->type, ast::Template("vec4", "f32")); + ast::CheckIdentifier(e.value[0]->type, ast::Template("vec4", "f32")); EXPECT_TRUE(e.value[0]->Is()); auto attrs_0 = e.value[0]->attributes; ASSERT_EQ(attrs_0.Length(), 1u); EXPECT_TRUE(attrs_0[0]->Is()); - ast::CheckIdentifier(p->builder().Symbols(), attrs_0[0]->As()->builtin, - "position"); + ast::CheckIdentifier(attrs_0[0]->As()->builtin, "position"); ASSERT_EQ(e.value[0]->source.range.begin.line, 1u); ASSERT_EQ(e.value[0]->source.range.begin.column, 20u); @@ -111,7 +110,7 @@ TEST_F(ParserImplTest, ParamList_Attributes) { ASSERT_EQ(e.value[0]->source.range.end.column, 25u); EXPECT_EQ(e.value[1]->name->symbol, p->builder().Symbols().Get("loc1")); - ast::CheckIdentifier(p->builder().Symbols(), e.value[1]->type, "f32"); + ast::CheckIdentifier(e.value[1]->type, "f32"); EXPECT_TRUE(e.value[1]->Is()); auto attrs_1 = e.value[1]->attributes; ASSERT_EQ(attrs_1.Length(), 1u); diff --git a/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc b/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc index 5dab39fad2..904e8815b5 100644 --- a/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc @@ -27,7 +27,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Ident) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); ASSERT_TRUE(e->Is()); - ast::CheckIdentifier(p->builder().Symbols(), e.value, "a"); + ast::CheckIdentifier(e.value, "a"); } TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) { @@ -116,7 +116,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_StructInitializer_Empty) { auto* call = e->As(); ASSERT_NE(call->target, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), call->target, "S"); + ast::CheckIdentifier(call->target, "S"); ASSERT_EQ(call->args.Length(), 0u); } @@ -140,7 +140,7 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_StructInitializer_NotEmpty) { auto* call = e->As(); ASSERT_NE(call->target, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), call->target, "S"); + ast::CheckIdentifier(call->target, "S"); ASSERT_EQ(call->args.Length(), 2u); @@ -215,7 +215,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) { ASSERT_TRUE(e->Is()); auto* call = e->As(); - ast::CheckIdentifier(p->builder().Symbols(), call->target, "f32"); + ast::CheckIdentifier(call->target, "f32"); ASSERT_EQ(call->args.Length(), 1u); ASSERT_TRUE(call->args[0]->Is()); @@ -233,7 +233,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast) { auto* c = e->As(); - ast::CheckIdentifier(p->builder().Symbols(), c->type, "f32"); + ast::CheckIdentifier(c->type, "f32"); ASSERT_TRUE(c->expr->Is()); } diff --git a/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc b/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc index dfde6fa184..8809ba5652 100644 --- a/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc @@ -98,7 +98,7 @@ TEST_F(ParserImplTest, SingularExpression_Call_Empty) { ASSERT_TRUE(e->Is()); auto* c = e->As(); - ast::CheckIdentifier(p->builder().Symbols(), c->target, "a"); + ast::CheckIdentifier(c->target, "a"); EXPECT_EQ(c->args.Length(), 0u); } @@ -114,7 +114,7 @@ TEST_F(ParserImplTest, SingularExpression_Call_WithArgs) { ASSERT_TRUE(e->Is()); auto* c = e->As(); - ast::CheckIdentifier(p->builder().Symbols(), c->target, "test"); + ast::CheckIdentifier(c->target, "test"); EXPECT_EQ(c->args.Length(), 3u); EXPECT_TRUE(c->args[0]->Is()); diff --git a/src/tint/reader/wgsl/parser_impl_struct_body_decl_test.cc b/src/tint/reader/wgsl/parser_impl_struct_body_decl_test.cc index a4fbe2c6e6..5efa18db5a 100644 --- a/src/tint/reader/wgsl/parser_impl_struct_body_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_struct_body_decl_test.cc @@ -30,7 +30,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) { const auto* mem = m.value[0]; EXPECT_EQ(mem->name->symbol, builder.Symbols().Get("a")); - ast::CheckIdentifier(p->builder().Symbols(), mem->type, "i32"); + ast::CheckIdentifier(mem->type, "i32"); EXPECT_EQ(mem->attributes.Length(), 0u); } @@ -46,7 +46,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses_TrailingComma) { const auto* mem = m.value[0]; EXPECT_EQ(mem->name->symbol, builder.Symbols().Get("a")); - ast::CheckIdentifier(p->builder().Symbols(), mem->type, "i32"); + ast::CheckIdentifier(mem->type, "i32"); EXPECT_EQ(mem->attributes.Length(), 0u); } diff --git a/src/tint/reader/wgsl/parser_impl_struct_member_test.cc b/src/tint/reader/wgsl/parser_impl_struct_member_test.cc index 0af0ba2097..9dc90a5273 100644 --- a/src/tint/reader/wgsl/parser_impl_struct_member_test.cc +++ b/src/tint/reader/wgsl/parser_impl_struct_member_test.cc @@ -26,8 +26,8 @@ TEST_F(ParserImplTest, StructMember_Parses) { ASSERT_FALSE(m.errored); ASSERT_NE(m.value, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), m->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), m->type, "i32"); + ast::CheckIdentifier(m->name, "a"); + ast::CheckIdentifier(m->type, "i32"); EXPECT_EQ(m->attributes.Length(), 0u); EXPECT_EQ(m->source.range, (Source::Range{{1u, 1u}, {1u, 2u}})); @@ -42,8 +42,8 @@ TEST_F(ParserImplTest, StructMember_ParsesWithAlignAttribute) { ASSERT_FALSE(m.errored); ASSERT_NE(m.value, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), m->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), m->type, "i32"); + ast::CheckIdentifier(m->name, "a"); + ast::CheckIdentifier(m->type, "i32"); EXPECT_EQ(m->attributes.Length(), 1u); EXPECT_TRUE(m->attributes[0]->Is()); @@ -65,8 +65,8 @@ TEST_F(ParserImplTest, StructMember_ParsesWithSizeAttribute) { ASSERT_FALSE(m.errored); ASSERT_NE(m.value, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), m->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), m->type, "i32"); + ast::CheckIdentifier(m->name, "a"); + ast::CheckIdentifier(m->type, "i32"); EXPECT_EQ(m->attributes.Length(), 1u); ASSERT_TRUE(m->attributes[0]->Is()); auto* s = m->attributes[0]->As(); @@ -87,8 +87,8 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleattributes) { ASSERT_FALSE(m.errored); ASSERT_NE(m.value, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), m->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), m->type, "i32"); + ast::CheckIdentifier(m->name, "a"); + ast::CheckIdentifier(m->type, "i32"); EXPECT_EQ(m->attributes.Length(), 2u); ASSERT_TRUE(m->attributes[0]->Is()); auto* size_attr = m->attributes[0]->As(); diff --git a/src/tint/reader/wgsl/parser_impl_type_alias_test.cc b/src/tint/reader/wgsl/parser_impl_type_alias_test.cc index 1aa8bf9500..08a0464d8a 100644 --- a/src/tint/reader/wgsl/parser_impl_type_alias_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_alias_test.cc @@ -28,7 +28,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) { ASSERT_NE(t.value, nullptr); ASSERT_TRUE(t->Is()); auto* alias = t->As(); - ast::CheckIdentifier(p->builder().Symbols(), alias->type, "i32"); + ast::CheckIdentifier(alias->type, "i32"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 14u}})); } @@ -42,8 +42,8 @@ TEST_F(ParserImplTest, TypeDecl_Parses_Ident) { ASSERT_NE(t.value, nullptr); ASSERT_TRUE(t.value->Is()); auto* alias = t.value->As(); - ast::CheckIdentifier(p->builder().Symbols(), alias->name, "a"); - ast::CheckIdentifier(p->builder().Symbols(), alias->type, "B"); + ast::CheckIdentifier(alias->name, "a"); + ast::CheckIdentifier(alias->type, "B"); EXPECT_EQ(alias->source.range, (Source::Range{{1u, 1u}, {1u, 12u}})); } @@ -61,8 +61,8 @@ TEST_F(ParserImplTest, TypeDecl_Unicode_Parses_Ident) { ASSERT_NE(t.value, nullptr); ASSERT_TRUE(t.value->Is()); auto* alias = t.value->As(); - ast::CheckIdentifier(p->builder().Symbols(), alias->name, ident); - ast::CheckIdentifier(p->builder().Symbols(), alias->type, "i32"); + ast::CheckIdentifier(alias->name, ident); + ast::CheckIdentifier(alias->type, "i32"); EXPECT_EQ(alias->source.range, (Source::Range{{1u, 1u}, {1u, 38u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc index 25e60e0368..dd0afedb8c 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc @@ -38,7 +38,7 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ast::CheckIdentifier(p->builder().Symbols(), t.value, "A"); + ast::CheckIdentifier(t.value, "A"); EXPECT_EQ(t->expr->source.range, (Source::Range{{1u, 1u}, {1u, 2u}})); } @@ -49,7 +49,7 @@ TEST_F(ParserImplTest, TypeDecl_Bool) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ast::CheckIdentifier(p->builder().Symbols(), t.value, "bool"); + ast::CheckIdentifier(t.value, "bool"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 5u}})); } @@ -60,7 +60,7 @@ TEST_F(ParserImplTest, TypeDecl_F16) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ast::CheckIdentifier(p->builder().Symbols(), t.value, "f16"); + ast::CheckIdentifier(t.value, "f16"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 4u}})); } @@ -71,7 +71,7 @@ TEST_F(ParserImplTest, TypeDecl_F32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ast::CheckIdentifier(p->builder().Symbols(), t.value, "f32"); + ast::CheckIdentifier(t.value, "f32"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 4u}})); } @@ -82,7 +82,7 @@ TEST_F(ParserImplTest, TypeDecl_I32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ast::CheckIdentifier(p->builder().Symbols(), t.value, "i32"); + ast::CheckIdentifier(t.value, "i32"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 4u}})); } @@ -93,7 +93,7 @@ TEST_F(ParserImplTest, TypeDecl_U32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ast::CheckIdentifier(p->builder().Symbols(), t.value, "u32"); + ast::CheckIdentifier(t.value, "u32"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 4u}})); } @@ -117,8 +117,7 @@ TEST_P(VecTest, Parse) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, - ast::Template("vec" + std::to_string(params.count), "f32")); + ast::CheckIdentifier(t.value, ast::Template("vec" + std::to_string(params.count), "f32")); EXPECT_EQ(t.value->source.range, params.range); } INSTANTIATE_TEST_SUITE_P(ParserImplTest, @@ -153,7 +152,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("ptr", "function", "f32")); + ast::CheckIdentifier(t.value, ast::Template("ptr", "function", "f32")); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 19u}})); } @@ -165,8 +164,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_WithAccess) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, - ast::Template("ptr", "function", "f32", "read")); + ast::CheckIdentifier(t.value, ast::Template("ptr", "function", "f32", "read")); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25u}})); } @@ -178,8 +176,7 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, - ast::Template("ptr", "function", ast::Template("vec2", "f32"))); + ast::CheckIdentifier(t.value, ast::Template("ptr", "function", ast::Template("vec2", "f32"))); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 25}})); } @@ -232,7 +229,7 @@ TEST_F(ParserImplTest, TypeDecl_Atomic) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("atomic", "f32")); + ast::CheckIdentifier(t.value, ast::Template("atomic", "f32")); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 12u}})); } @@ -244,8 +241,7 @@ TEST_F(ParserImplTest, TypeDecl_Atomic_ToVec) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, - ast::Template("atomic", ast::Template("vec2", "f32"))); + ast::CheckIdentifier(t.value, ast::Template("atomic", ast::Template("vec2", "f32"))); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 18u}})); } @@ -267,7 +263,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_AbstractIntLiteralSize) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("array", "f32", 5_a)); + ast::CheckIdentifier(t.value, ast::Template("array", "f32", 5_a)); } TEST_F(ParserImplTest, TypeDecl_Array_SintLiteralSize) { @@ -278,7 +274,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_SintLiteralSize) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("array", "f32", 5_i)); + ast::CheckIdentifier(t.value, ast::Template("array", "f32", 5_i)); } TEST_F(ParserImplTest, TypeDecl_Array_UintLiteralSize) { @@ -289,7 +285,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_UintLiteralSize) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("array", "f32", 5_u)); + ast::CheckIdentifier(t.value, ast::Template("array", "f32", 5_u)); } TEST_F(ParserImplTest, TypeDecl_Array_ConstantSize) { @@ -300,7 +296,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_ConstantSize) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("array", "f32", "size")); + ast::CheckIdentifier(t.value, ast::Template("array", "f32", "size")); } TEST_F(ParserImplTest, TypeDecl_Array_ExpressionSize) { @@ -311,17 +307,15 @@ TEST_F(ParserImplTest, TypeDecl_Array_ExpressionSize) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - auto name_for = [&](const Symbol& sym) { return p->builder().Symbols().NameFor(sym); }; - auto* arr = t->expr->identifier->As(); - EXPECT_EQ(name_for(arr->symbol), "array"); + EXPECT_EQ(arr->symbol.Name(), "array"); EXPECT_TRUE(arr->attributes.IsEmpty()); ASSERT_EQ(arr->arguments.Length(), 2u); auto* ty = As(arr->arguments[0]); ASSERT_NE(ty, nullptr); - EXPECT_EQ(name_for(ty->identifier->symbol), "f32"); + EXPECT_EQ(ty->identifier->symbol.Name(), "f32"); auto* count = As(arr->arguments[1]); ASSERT_NE(count, nullptr); @@ -329,7 +323,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_ExpressionSize) { auto* count_lhs = As(count->lhs); ASSERT_NE(count_lhs, nullptr); - EXPECT_EQ(name_for(count_lhs->identifier->symbol), "size"); + EXPECT_EQ(count_lhs->identifier->symbol.Name(), "size"); auto* count_rhs = As(count->rhs); ASSERT_NE(count_rhs, nullptr); @@ -344,7 +338,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("array", "u32")); + ast::CheckIdentifier(t.value, ast::Template("array", "u32")); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 11u}})); } @@ -356,8 +350,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Vec) { ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ast::CheckIdentifier(p->builder().Symbols(), t.value, - ast::Template("array", ast::Template("vec4", "u32"))); + ast::CheckIdentifier(t.value, ast::Template("array", ast::Template("vec4", "u32"))); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 17u}})); } @@ -406,7 +399,7 @@ TEST_P(MatrixTest, Parse) { std::string expected_name = "mat" + std::to_string(GetParam().columns) + "x" + std::to_string(GetParam().rows); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template(expected_name, "f32")); + ast::CheckIdentifier(t.value, ast::Template(expected_name, "f32")); EXPECT_EQ(t.value->source.range, params.range); } INSTANTIATE_TEST_SUITE_P(ParserImplTest, @@ -453,7 +446,7 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); - ast::CheckIdentifier(p->builder().Symbols(), t.value, "sampler"); + ast::CheckIdentifier(t.value, "sampler"); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 8u}})); } @@ -465,7 +458,7 @@ TEST_F(ParserImplTest, TypeDecl_Texture) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), t.value, ast::Template("texture_cube", "f32")); + ast::CheckIdentifier(t.value, ast::Template("texture_cube", "f32")); EXPECT_EQ(t.value->source.range, (Source::Range{{1u, 1u}, {1u, 18u}})); } diff --git a/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc b/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc index 07775c5b70..1751e98816 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc @@ -39,8 +39,7 @@ TEST_F(ParserImplTest, AttributeList_Parses) { EXPECT_EQ(exp->value, 4u); ASSERT_TRUE(attr_1->Is()); - ast::CheckIdentifier(p->builder().Symbols(), attr_1->As()->builtin, - "position"); + ast::CheckIdentifier(attr_1->As()->builtin, "position"); } TEST_F(ParserImplTest, AttributeList_Invalid) { diff --git a/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc index 2ca7da474f..e67a18aa16 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc @@ -233,7 +233,7 @@ TEST_P(BuiltinTest, Attribute_Builtin) { ASSERT_TRUE(var_attr->Is()); auto* builtin = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), builtin->builtin, str); + ast::CheckIdentifier(builtin->builtin, str); } TEST_P(BuiltinTest, Attribute_Builtin_TrailingComma) { auto str = utils::ToString(GetParam()); @@ -249,7 +249,7 @@ TEST_P(BuiltinTest, Attribute_Builtin_TrailingComma) { ASSERT_TRUE(var_attr->Is()); auto* builtin = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), builtin->builtin, str); + ast::CheckIdentifier(builtin->builtin, str); } INSTANTIATE_TEST_SUITE_P(ParserImplTest, BuiltinTest, @@ -308,7 +308,7 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Flat) { ASSERT_TRUE(var_attr->Is()); auto* interp = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), interp->type, "flat"); + ast::CheckIdentifier(interp->type, "flat"); EXPECT_EQ(interp->sampling, nullptr); } @@ -324,7 +324,7 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Single_TrailingComma) { ASSERT_TRUE(var_attr->Is()); auto* interp = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), interp->type, "flat"); + ast::CheckIdentifier(interp->type, "flat"); EXPECT_EQ(interp->sampling, nullptr); } @@ -350,8 +350,8 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Perspective_Center) { ASSERT_TRUE(var_attr->Is()); auto* interp = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), interp->type, "perspective"); - ast::CheckIdentifier(p->builder().Symbols(), interp->sampling, "center"); + ast::CheckIdentifier(interp->type, "perspective"); + ast::CheckIdentifier(interp->sampling, "center"); } TEST_F(ParserImplTest, Attribute_Interpolate_Double_TrailingComma) { @@ -366,8 +366,8 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Double_TrailingComma) { ASSERT_TRUE(var_attr->Is()); auto* interp = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), interp->type, "perspective"); - ast::CheckIdentifier(p->builder().Symbols(), interp->sampling, "center"); + ast::CheckIdentifier(interp->type, "perspective"); + ast::CheckIdentifier(interp->sampling, "center"); } TEST_F(ParserImplTest, Attribute_Interpolate_Perspective_Centroid) { @@ -382,8 +382,8 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Perspective_Centroid) { ASSERT_TRUE(var_attr->Is()); auto* interp = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), interp->type, "perspective"); - ast::CheckIdentifier(p->builder().Symbols(), interp->sampling, "centroid"); + ast::CheckIdentifier(interp->type, "perspective"); + ast::CheckIdentifier(interp->sampling, "centroid"); } TEST_F(ParserImplTest, Attribute_Interpolate_Linear_Sample) { @@ -398,8 +398,8 @@ TEST_F(ParserImplTest, Attribute_Interpolate_Linear_Sample) { ASSERT_TRUE(var_attr->Is()); auto* interp = var_attr->As(); - ast::CheckIdentifier(p->builder().Symbols(), interp->type, "linear"); - ast::CheckIdentifier(p->builder().Symbols(), interp->sampling, "sample"); + ast::CheckIdentifier(interp->type, "linear"); + ast::CheckIdentifier(interp->sampling, "sample"); } TEST_F(ParserImplTest, Attribute_Interpolate_MissingLeftParen) { diff --git a/src/tint/reader/wgsl/parser_impl_variable_decl_test.cc b/src/tint/reader/wgsl/parser_impl_variable_decl_test.cc index 993ecb0ad9..c8fb651ad6 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_decl_test.cc @@ -26,7 +26,7 @@ TEST_F(ParserImplTest, VariableDecl_Parses) { EXPECT_EQ(v->name, "my_var"); EXPECT_NE(v->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), v->type, "f32"); + ast::CheckIdentifier(v->type, "f32"); EXPECT_EQ(v->source.range, (Source::Range{{1u, 5u}, {1u, 11u}})); EXPECT_EQ(v->type->source.range, (Source::Range{{1u, 14u}, {1u, 17u}})); @@ -46,7 +46,7 @@ TEST_F(ParserImplTest, VariableDecl_Unicode_Parses) { EXPECT_EQ(v->name, ident); EXPECT_NE(v->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), v->type, "f32"); + ast::CheckIdentifier(v->type, "f32"); EXPECT_EQ(v->source.range, (Source::Range{{1u, 5u}, {1u, 48u}})); EXPECT_EQ(v->type->source.range, (Source::Range{{1u, 51u}, {1u, 54u}})); @@ -83,8 +83,8 @@ TEST_F(ParserImplTest, VariableDecl_WithAddressSpace) { EXPECT_FALSE(p->has_error()); EXPECT_EQ(v->name, "my_var"); - ast::CheckIdentifier(p->builder().Symbols(), v->type, "f32"); - ast::CheckIdentifier(p->builder().Symbols(), v->address_space, "private"); + ast::CheckIdentifier(v->type, "f32"); + ast::CheckIdentifier(v->address_space, "private"); EXPECT_EQ(v->source.range.begin.line, 1u); EXPECT_EQ(v->source.range.begin.column, 14u); @@ -100,8 +100,8 @@ TEST_F(ParserImplTest, VariableDecl_WithPushConstant) { EXPECT_FALSE(p->has_error()); EXPECT_EQ(v->name, "my_var"); - ast::CheckIdentifier(p->builder().Symbols(), v->type, "f32"); - ast::CheckIdentifier(p->builder().Symbols(), v->address_space, "push_constant"); + ast::CheckIdentifier(v->type, "f32"); + ast::CheckIdentifier(v->address_space, "push_constant"); } } // namespace diff --git a/src/tint/reader/wgsl/parser_impl_variable_ident_decl_test.cc b/src/tint/reader/wgsl/parser_impl_variable_ident_decl_test.cc index 467fa8098e..8de0a52e23 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_ident_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_ident_decl_test.cc @@ -25,7 +25,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), decl->type, "f32"); + ast::CheckIdentifier(decl->type, "f32"); EXPECT_EQ(decl->source.range, (Source::Range{{1u, 1u}, {1u, 7u}})); EXPECT_EQ(decl->type->source.range, (Source::Range{{1u, 10u}, {1u, 13u}})); @@ -38,7 +38,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses_AllowInferredType) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), decl->type, "f32"); + ast::CheckIdentifier(decl->type, "f32"); EXPECT_EQ(decl->source.range, (Source::Range{{1u, 1u}, {1u, 7u}})); EXPECT_EQ(decl->type->source.range, (Source::Range{{1u, 10u}, {1u, 13u}})); diff --git a/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc b/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc index 3c25d858eb..d50a962d55 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_qualifier_test.cc @@ -39,13 +39,12 @@ TEST_P(VariableQualifierTest, ParsesAddressSpace) { EXPECT_FALSE(sc.errored); EXPECT_TRUE(sc.matched); if (params.address_space != builtin::AddressSpace::kUndefined) { - ast::CheckIdentifier(p->builder().Symbols(), sc->address_space, - utils::ToString(params.address_space)); + ast::CheckIdentifier(sc->address_space, utils::ToString(params.address_space)); } else { EXPECT_EQ(sc->address_space, nullptr); } if (params.access != builtin::Access::kUndefined) { - ast::CheckIdentifier(p->builder().Symbols(), sc->access, utils::ToString(params.access)); + ast::CheckIdentifier(sc->access, utils::ToString(params.access)); } else { EXPECT_EQ(sc->access, nullptr); } diff --git a/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc b/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc index bd3ee19613..b7df18c076 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc @@ -81,7 +81,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit) { ASSERT_NE(e->variable->initializer, nullptr); auto* call = e->variable->initializer->As(); ASSERT_NE(call, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), call->target, ast::Template("array", "i32")); + ast::CheckIdentifier(call->target, ast::Template("array", "i32")); } TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit_NoSpace) { @@ -98,7 +98,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_ArrayInit_NoSpace) { ASSERT_NE(e->variable->initializer, nullptr); auto* call = e->variable->initializer->As(); ASSERT_NE(call, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), call->target, ast::Template("array", "i32")); + ast::CheckIdentifier(call->target, ast::Template("array", "i32")); } TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit) { @@ -114,7 +114,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit) { ASSERT_NE(e->variable->initializer, nullptr); auto* call = e->variable->initializer->As(); - ast::CheckIdentifier(p->builder().Symbols(), call->target, ast::Template("vec2", "i32")); + ast::CheckIdentifier(call->target, ast::Template("vec2", "i32")); } TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit_NoSpace) { @@ -131,7 +131,7 @@ TEST_F(ParserImplTest, VariableStmt_VariableDecl_VecInit_NoSpace) { ASSERT_NE(e->variable->initializer, nullptr); auto* call = e->variable->initializer->As(); ASSERT_NE(call, nullptr); - ast::CheckIdentifier(p->builder().Symbols(), call->target, ast::Template("vec2", "i32")); + ast::CheckIdentifier(call->target, ast::Template("vec2", "i32")); } TEST_F(ParserImplTest, VariableStmt_Let) { @@ -168,11 +168,11 @@ TEST_F(ParserImplTest, VariableStmt_Let_ComplexExpression) { ASSERT_TRUE(expr->lhs->Is()); auto* ident_expr = expr->lhs->As(); - ast::CheckIdentifier(p->builder().Symbols(), ident_expr->identifier, "collide"); + ast::CheckIdentifier(ident_expr->identifier, "collide"); ASSERT_TRUE(expr->rhs->Is()); ident_expr = expr->rhs->As(); - ast::CheckIdentifier(p->builder().Symbols(), ident_expr->identifier, "collide_1"); + ast::CheckIdentifier(ident_expr->identifier, "collide_1"); } TEST_F(ParserImplTest, VariableStmt_Let_MissingEqual) { diff --git a/src/tint/resolver/bitcast_validation_test.cc b/src/tint/resolver/bitcast_validation_test.cc index b02cf7d87c..fb0b96032e 100644 --- a/src/tint/resolver/bitcast_validation_test.cc +++ b/src/tint/resolver/bitcast_validation_test.cc @@ -115,8 +115,7 @@ TEST_P(ResolverBitcastValidationTestInvalidSrcTy, Test) { auto* cast = Bitcast(dst.ast(*this), Expr(Source{{12, 34}}, "src")); WrapInFunction(Let("src", src.expr(*this, 0)), cast); - auto expected = - "12:34 error: '" + src.sem(*this)->FriendlyName(Symbols()) + "' cannot be bitcast"; + auto expected = "12:34 error: '" + src.sem(*this)->FriendlyName() + "' cannot be bitcast"; EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), expected); @@ -150,8 +149,7 @@ TEST_P(ResolverBitcastValidationTestInvalidDstTy, Test) { Alias("T", dst.ast(*this)); WrapInFunction(Bitcast(ty(Source{{12, 34}}, "T"), src.expr(*this, 0))); - auto expected = - "12:34 error: cannot bitcast to '" + dst.sem(*this)->FriendlyName(Symbols()) + "'"; + auto expected = "12:34 error: cannot bitcast to '" + dst.sem(*this)->FriendlyName() + "'"; EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), expected); @@ -183,8 +181,8 @@ TEST_P(ResolverBitcastValidationTestIncompatible, Test) { WrapInFunction(Bitcast(Source{{12, 34}}, dst.ast(*this), src.expr(*this, 0))); - auto expected = "12:34 error: cannot bitcast from '" + src.sem(*this)->FriendlyName(Symbols()) + - "' to '" + dst.sem(*this)->FriendlyName(Symbols()) + "'"; + auto expected = "12:34 error: cannot bitcast from '" + src.sem(*this)->FriendlyName() + + "' to '" + dst.sem(*this)->FriendlyName() + "'"; EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), expected); diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 80df98f421..8cfbc671d1 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -2120,7 +2120,7 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParamidentifier->symbol); + std::string type_name = type->identifier->symbol.Name(); if (utils::HasPrefix(type_name, "texture") || utils::HasPrefix(type_name, "sampler")) { GlobalVar(name, type, Binding(0_a), Group(0_a)); } else { diff --git a/src/tint/resolver/dependency_graph.cc b/src/tint/resolver/dependency_graph.cc index 47e691c4d1..ec6bda7aa2 100644 --- a/src/tint/resolver/dependency_graph.cc +++ b/src/tint/resolver/dependency_graph.cc @@ -61,7 +61,6 @@ #include "src/tint/scope_stack.h" #include "src/tint/sem/builtin.h" #include "src/tint/switch.h" -#include "src/tint/symbol_table.h" #include "src/tint/utils/block_allocator.h" #include "src/tint/utils/compiler_macros.h" #include "src/tint/utils/defer.h" @@ -143,19 +142,16 @@ void AddNote(diag::List& diagnostics, const std::string& msg, const Source& sour class DependencyScanner { public: /// Constructor - /// @param syms the program symbol table /// @param globals_by_name map of global symbol to Global pointer /// @param diagnostics diagnostic messages, appended with any errors found /// @param graph the dependency graph to populate with resolved symbols /// @param edges the map of globals-to-global dependency edges, which will /// be populated by calls to Scan() - DependencyScanner(const SymbolTable& syms, - const GlobalMap& globals_by_name, + DependencyScanner(const GlobalMap& globals_by_name, diag::List& diagnostics, DependencyGraph& graph, DependencyEdges& edges) - : symbols_(syms), - globals_(globals_by_name), + : globals_(globals_by_name), diagnostics_(diagnostics), graph_(graph), dependency_edges_(edges) { @@ -331,7 +327,7 @@ class DependencyScanner { void Declare(Symbol symbol, const ast::Node* node) { auto* old = scope_stack_.Set(symbol, node); if (old != nullptr && node != old) { - auto name = symbols_.NameFor(symbol); + auto name = symbol.Name(); AddError(diagnostics_, "redeclaration of '" + name + "'", node->source); AddNote(diagnostics_, "'" + name + "' previously declared here", old->source); } @@ -440,7 +436,7 @@ class DependencyScanner { void AddDependency(const ast::Identifier* from, Symbol to) { auto* resolved = scope_stack_.Get(to); if (!resolved) { - auto s = symbols_.NameFor(to); + auto s = to.Name(); if (auto builtin_fn = builtin::ParseFunction(s); builtin_fn != builtin::Function::kNone) { graph_.resolved_identifiers.Add(from, ResolvedIdentifier(builtin_fn)); @@ -496,7 +492,6 @@ class DependencyScanner { } using VariableMap = utils::Hashmap; - const SymbolTable& symbols_; const GlobalMap& globals_; diag::List& diagnostics_; DependencyGraph& graph_; @@ -510,8 +505,8 @@ class DependencyScanner { struct DependencyAnalysis { public: /// Constructor - DependencyAnalysis(const SymbolTable& symbols, diag::List& diagnostics, DependencyGraph& graph) - : symbols_(symbols), diagnostics_(diagnostics), graph_(graph) {} + DependencyAnalysis(diag::List& diagnostics, DependencyGraph& graph) + : diagnostics_(diagnostics), graph_(graph) {} /// Performs global dependency analysis on the module, emitting any errors to /// #diagnostics. @@ -562,7 +557,7 @@ struct DependencyAnalysis { /// @returns the name of the global declaration node /// @note will raise an ICE if the node is not a type, function or variable /// declaration - std::string NameOf(const ast::Node* node) const { return symbols_.NameFor(SymbolOf(node)); } + std::string NameOf(const ast::Node* node) const { return SymbolOf(node).Name(); } /// @param node the ast::Node of the global declaration /// @returns a string representation of the global declaration kind @@ -597,7 +592,7 @@ struct DependencyAnalysis { /// Walks the global declarations, determining the dependencies of each global /// and adding these to each global's Global::deps field. void DetermineDependencies() { - DependencyScanner scanner(symbols_, globals_, diagnostics_, graph_, dependency_edges_); + DependencyScanner scanner(globals_, diagnostics_, graph_, dependency_edges_); for (auto* global : declaration_order_) { scanner.Scan(global); } @@ -762,7 +757,7 @@ struct DependencyAnalysis { for (auto* node : sorted_) { auto symbol = SymbolOf(node); auto* global = *globals_.Find(symbol); - printf("%s depends on:\n", symbols_.NameFor(symbol).c_str()); + printf("%s depends on:\n", symbol.Name().c_str()); for (auto* dep : global->deps) { printf(" %s\n", NameOf(dep->node).c_str()); } @@ -770,9 +765,6 @@ struct DependencyAnalysis { printf("=========================\n"); } - /// Program symbols - const SymbolTable& symbols_; - /// Program diagnostics diag::List& diagnostics_; @@ -802,37 +794,36 @@ DependencyGraph::DependencyGraph(DependencyGraph&&) = default; DependencyGraph::~DependencyGraph() = default; bool DependencyGraph::Build(const ast::Module& module, - const SymbolTable& symbols, diag::List& diagnostics, DependencyGraph& output) { - DependencyAnalysis da{symbols, diagnostics, output}; + DependencyAnalysis da{diagnostics, output}; return da.Run(module); } -std::string ResolvedIdentifier::String(const SymbolTable& symbols, diag::List& diagnostics) const { +std::string ResolvedIdentifier::String(diag::List& diagnostics) const { if (auto* node = Node()) { return Switch( node, [&](const ast::TypeDecl* n) { // - return "type '" + symbols.NameFor(n->name->symbol) + "'"; + return "type '" + n->name->symbol.Name() + "'"; }, [&](const ast::Var* n) { // - return "var '" + symbols.NameFor(n->name->symbol) + "'"; + return "var '" + n->name->symbol.Name() + "'"; }, [&](const ast::Let* n) { // - return "let '" + symbols.NameFor(n->name->symbol) + "'"; + return "let '" + n->name->symbol.Name() + "'"; }, [&](const ast::Const* n) { // - return "const '" + symbols.NameFor(n->name->symbol) + "'"; + return "const '" + n->name->symbol.Name() + "'"; }, [&](const ast::Override* n) { // - return "override '" + symbols.NameFor(n->name->symbol) + "'"; + return "override '" + n->name->symbol.Name() + "'"; }, [&](const ast::Function* n) { // - return "function '" + symbols.NameFor(n->name->symbol) + "'"; + return "function '" + n->name->symbol.Name() + "'"; }, [&](const ast::Parameter* n) { // - return "parameter '" + symbols.NameFor(n->name->symbol) + "'"; + return "parameter '" + n->name->symbol.Name() + "'"; }, [&](Default) { TINT_UNREACHABLE(Resolver, diagnostics) diff --git a/src/tint/resolver/dependency_graph.h b/src/tint/resolver/dependency_graph.h index f58b2a2067..e4f03489f8 100644 --- a/src/tint/resolver/dependency_graph.h +++ b/src/tint/resolver/dependency_graph.h @@ -27,7 +27,6 @@ #include "src/tint/builtin/interpolation_type.h" #include "src/tint/builtin/texel_format.h" #include "src/tint/diagnostic/diagnostic.h" -#include "src/tint/symbol_table.h" #include "src/tint/utils/hashmap.h" namespace tint::resolver { @@ -164,10 +163,9 @@ class ResolvedIdentifier { return !(*this == other); } - /// @param symbols the program's symbol table /// @param diagnostics diagnostics used to report ICEs /// @return a description of the resolved symbol - std::string String(const SymbolTable& symbols, diag::List& diagnostics) const; + std::string String(diag::List& diagnostics) const; private: std::variant ordered_globals; diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc index c9ce3b8342..1850d6f0a4 100644 --- a/src/tint/resolver/dependency_graph_test.cc +++ b/src/tint/resolver/dependency_graph_test.cc @@ -35,8 +35,7 @@ class ResolverDependencyGraphTestWithParam : public ResolverTestWithParam { public: DependencyGraph Build(std::string expected_error = "") { DependencyGraph graph; - auto result = - DependencyGraph::Build(this->AST(), this->Symbols(), this->Diagnostics(), graph); + auto result = DependencyGraph::Build(this->AST(), this->Diagnostics(), graph); if (expected_error.empty()) { EXPECT_TRUE(result) << this->Diagnostics().str(); } else { @@ -1194,7 +1193,7 @@ TEST_P(ResolverDependencyGraphResolveToBuiltinFunc, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); - EXPECT_EQ(resolved->BuiltinFunction(), builtin) << resolved->String(Symbols(), Diagnostics()); + EXPECT_EQ(resolved->BuiltinFunction(), builtin) << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Types, @@ -1234,7 +1233,7 @@ TEST_P(ResolverDependencyGraphResolveToBuiltinType, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); EXPECT_EQ(resolved->BuiltinType(), builtin::ParseBuiltin(name)) - << resolved->String(Symbols(), Diagnostics()); + << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Types, @@ -1273,8 +1272,7 @@ TEST_P(ResolverDependencyGraphResolveToAccess, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); - EXPECT_EQ(resolved->Access(), builtin::ParseAccess(name)) - << resolved->String(Symbols(), Diagnostics()); + EXPECT_EQ(resolved->Access(), builtin::ParseAccess(name)) << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Types, @@ -1314,7 +1312,7 @@ TEST_P(ResolverDependencyGraphResolveToAddressSpace, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); EXPECT_EQ(resolved->AddressSpace(), builtin::ParseAddressSpace(name)) - << resolved->String(Symbols(), Diagnostics()); + << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Types, @@ -1354,7 +1352,7 @@ TEST_P(ResolverDependencyGraphResolveToBuiltinValue, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); EXPECT_EQ(resolved->BuiltinValue(), builtin::ParseBuiltinValue(name)) - << resolved->String(Symbols(), Diagnostics()); + << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Types, @@ -1394,7 +1392,7 @@ TEST_P(ResolverDependencyGraphResolveToInterpolationSampling, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); EXPECT_EQ(resolved->InterpolationSampling(), builtin::ParseInterpolationSampling(name)) - << resolved->String(Symbols(), Diagnostics()); + << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Types, @@ -1434,7 +1432,7 @@ TEST_P(ResolverDependencyGraphResolveToInterpolationType, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); EXPECT_EQ(resolved->InterpolationType(), builtin::ParseInterpolationType(name)) - << resolved->String(Symbols(), Diagnostics()); + << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P( @@ -1477,7 +1475,7 @@ TEST_P(ResolverDependencyGraphResolveToTexelFormat, Resolve) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); EXPECT_EQ(resolved->TexelFormat(), builtin::ParseTexelFormat(name)) - << resolved->String(Symbols(), Diagnostics()); + << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Types, @@ -1558,7 +1556,7 @@ TEST_P(ResolverDependencyGraphShadowKindTest, ShadowedByGlobalVar) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); - EXPECT_EQ(resolved->Node(), decl) << resolved->String(Symbols(), Diagnostics()); + EXPECT_EQ(resolved->Node(), decl) << resolved->String(Diagnostics()); } TEST_P(ResolverDependencyGraphShadowKindTest, ShadowedByStruct) { @@ -1575,7 +1573,7 @@ TEST_P(ResolverDependencyGraphShadowKindTest, ShadowedByStruct) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); - EXPECT_EQ(resolved->Node(), decl) << resolved->String(Symbols(), Diagnostics()); + EXPECT_EQ(resolved->Node(), decl) << resolved->String(Diagnostics()); } TEST_P(ResolverDependencyGraphShadowKindTest, ShadowedByFunc) { @@ -1590,7 +1588,7 @@ TEST_P(ResolverDependencyGraphShadowKindTest, ShadowedByFunc) { auto resolved = Build().resolved_identifiers.Get(ident); ASSERT_TRUE(resolved); - EXPECT_EQ(resolved->Node(), decl) << resolved->String(Symbols(), Diagnostics()); + EXPECT_EQ(resolved->Node(), decl) << resolved->String(Diagnostics()); } INSTANTIATE_TEST_SUITE_P(Access, diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 18e2f81811..62dde26784 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -65,7 +65,7 @@ class Any final : public Castable { // Stub implementations for type::Type conformance. bool Equals(const type::UniqueNode&) const override { return false; } - std::string FriendlyName(const SymbolTable&) const override { return ""; } + std::string FriendlyName() const override { return ""; } type::Type* Clone(type::CloneContext&) const override { return nullptr; } }; @@ -977,11 +977,9 @@ const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const ty } const sem::Struct* build_atomic_compare_exchange_result(MatchState& state, const type::Type* ty) { - return build_struct( - state.builder, - "__atomic_compare_exchange_result" + ty->FriendlyName(state.builder.Symbols()), - {{"old_value", const_cast(ty)}, - {"exchanged", state.builder.create()}}); + return build_struct(state.builder, "__atomic_compare_exchange_result" + ty->FriendlyName(), + {{"old_value", const_cast(ty)}, + {"exchanged", state.builder.create()}}); } /// ParameterInfo describes a parameter @@ -1230,14 +1228,13 @@ class Impl : public IntrinsicTable { /// @return a string representing a call to a builtin with the given argument /// types. -std::string CallSignature(ProgramBuilder& builder, - const char* intrinsic_name, +std::string CallSignature(const char* intrinsic_name, utils::VectorRef args, const type::Type* template_arg = nullptr) { utils::StringStream ss; ss << intrinsic_name; if (template_arg) { - ss << "<" << template_arg->FriendlyName(builder.Symbols()) << ">"; + ss << "<" << template_arg->FriendlyName() << ">"; } ss << "("; { @@ -1247,7 +1244,7 @@ std::string CallSignature(ProgramBuilder& builder, ss << ", "; } first = false; - ss << arg->UnwrapRef()->FriendlyName(builder.Symbols()); + ss << arg->UnwrapRef()->FriendlyName(); } } ss << ")"; @@ -1274,7 +1271,7 @@ Impl::Builtin Impl::Lookup(builtin::Function builtin_type, // Generates an error when no overloads match the provided arguments auto on_no_match = [&](utils::VectorRef candidates) { utils::StringStream ss; - ss << "no matching call to " << CallSignature(builder, intrinsic_name, args) << std::endl; + ss << "no matching call to " << CallSignature(intrinsic_name, args) << std::endl; if (!candidates.IsEmpty()) { ss << std::endl << candidates.Length() << " candidate function" @@ -1343,7 +1340,7 @@ IntrinsicTable::UnaryOperator Impl::Lookup(ast::UnaryOp op, // Generates an error when no overloads match the provided arguments auto on_no_match = [&, name = intrinsic_name](utils::VectorRef candidates) { utils::StringStream ss; - ss << "no matching overload for " << CallSignature(builder, name, args) << std::endl; + ss << "no matching overload for " << CallSignature(name, args) << std::endl; if (!candidates.IsEmpty()) { ss << std::endl << candidates.Length() << " candidate operator" @@ -1421,7 +1418,7 @@ IntrinsicTable::BinaryOperator Impl::Lookup(ast::BinaryOp op, // Generates an error when no overloads match the provided arguments auto on_no_match = [&, name = intrinsic_name](utils::VectorRef candidates) { utils::StringStream ss; - ss << "no matching overload for " << CallSignature(builder, name, args) << std::endl; + ss << "no matching overload for " << CallSignature(name, args) << std::endl; if (!candidates.IsEmpty()) { ss << std::endl << candidates.Length() << " candidate operator" @@ -1456,7 +1453,7 @@ IntrinsicTable::CtorOrConv Impl::Lookup(CtorConvIntrinsic type, // Generates an error when no overloads match the provided arguments auto on_no_match = [&](utils::VectorRef candidates) { utils::StringStream ss; - ss << "no matching constructor for " << CallSignature(builder, name, args, template_arg) + ss << "no matching constructor for " << CallSignature(name, args, template_arg) << std::endl; Candidates ctor, conv; for (auto candidate : candidates) { @@ -1871,7 +1868,7 @@ void Impl::ErrAmbiguousOverload(const char* intrinsic_name, ss << "ambiguous overload while attempting to match " << intrinsic_name; for (size_t i = 0; i < std::numeric_limits::max(); i++) { if (auto* ty = templates.Type(i)) { - ss << ((i == 0) ? "<" : ", ") << ty->FriendlyName(builder.Symbols()); + ss << ((i == 0) ? "<" : ", ") << ty->FriendlyName(); } else { if (i > 0) { ss << ">"; @@ -1886,7 +1883,7 @@ void Impl::ErrAmbiguousOverload(const char* intrinsic_name, ss << ", "; } first = false; - ss << arg->FriendlyName(builder.Symbols()); + ss << arg->FriendlyName(); } ss << "):\n"; for (auto& candidate : candidates) { diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index d509b5c0b5..a8dade1493 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -128,8 +128,7 @@ bool Resolver::Resolve() { // Pre-allocate the marked bitset with the total number of AST nodes. marked_.Resize(builder_->ASTNodes().Count()); - if (!DependencyGraph::Build(builder_->AST(), builder_->Symbols(), diagnostics_, - dependencies_)) { + if (!DependencyGraph::Build(builder_->AST(), diagnostics_, dependencies_)) { return false; } @@ -266,8 +265,7 @@ sem::Variable* Resolver::Let(const ast::Let* v, bool is_global) { if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, const_cast(ty), v->source)) { - AddNote("while instantiating 'let' " + builder_->Symbols().NameFor(v->name->symbol), - v->source); + AddNote("while instantiating 'let' " + v->name->symbol.Name(), v->source); return nullptr; } @@ -329,8 +327,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) { if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, const_cast(ty), v->source)) { - AddNote("while instantiating 'override' " + builder_->Symbols().NameFor(v->name->symbol), - v->source); + AddNote("while instantiating 'override' " + v->name->symbol.Name(), v->source); return nullptr; } @@ -423,8 +420,7 @@ sem::Variable* Resolver::Const(const ast::Const* c, bool is_global) { if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, const_cast(ty), c->source)) { - AddNote("while instantiating 'const' " + builder_->Symbols().NameFor(c->name->symbol), - c->source); + AddNote("while instantiating 'const' " + c->name->symbol.Name(), c->source); return nullptr; } @@ -524,8 +520,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { if (!ApplyAddressSpaceUsageToType(address_space, var_ty, var->type ? var->type->source : var->source)) { - AddNote("while instantiating 'var' " + builder_->Symbols().NameFor(var->name->symbol), - var->source); + AddNote("while instantiating 'var' " + var->name->symbol.Name(), var->source); return nullptr; } @@ -611,8 +606,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) Mark(param->name); auto add_note = [&] { - AddNote("while instantiating parameter " + builder_->Symbols().NameFor(param->name->symbol), - param->source); + AddNote("while instantiating parameter " + param->name->symbol.Name(), param->source); }; for (auto* attr : param->attributes) { @@ -879,7 +873,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) { { // Check the parameter name is unique for the function if (auto added = parameter_names.Add(param->name->symbol, param->source); !added) { - auto name = builder_->Symbols().NameFor(param->name->symbol); + auto name = param->name->symbol.Name(); AddError("redefinition of parameter '" + name + "'", param->source); AddNote("previous definition is here", *added.value); return nullptr; @@ -944,8 +938,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) { if (auto* str = return_type->As()) { if (!ApplyAddressSpaceUsageToType(builtin::AddressSpace::kUndefined, str, decl->source)) { - AddNote("while instantiating return type for " + - builder_->Symbols().NameFor(decl->name->symbol), + AddNote("while instantiating return type for " + decl->name->symbol.Name(), decl->source); return nullptr; } @@ -1577,7 +1570,7 @@ bool Resolver::AliasAnalysis(const sem::Call* call) { break; case Alias::ModuleScope: { auto* func = var.expr->Stmt()->Function(); - auto func_name = builder_->Symbols().NameFor(func->Declaration()->name->symbol); + auto func_name = func->Declaration()->name->symbol.Name(); AddNote( "aliases with module-scope variable " + var.access + " in '" + func_name + "'", var.expr->Declaration()->source); @@ -2147,8 +2140,7 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { auto resolved = dependencies_.resolved_identifiers.Get(ident); if (!resolved) { TINT_ICE(Resolver, diagnostics_) - << "identifier '" << builder_->Symbols().NameFor(ident->symbol) - << "' was not resolved"; + << "identifier '" << ident->symbol.Name() << "' was not resolved"; return nullptr; } @@ -2355,27 +2347,27 @@ type::Type* Resolver::BuiltinType(builtin::Builtin builtin_ty, const ast::Identi auto* tmpl_ident = ident->As(); if (!tmpl_ident) { if (TINT_UNLIKELY(min_args != 0)) { - AddError("expected '<' for '" + b.Symbols().NameFor(ident->symbol) + "'", + AddError("expected '<' for '" + ident->symbol.Name() + "'", Source{ident->source.range.end}); } return nullptr; } if (min_args == max_args) { if (TINT_UNLIKELY(tmpl_ident->arguments.Length() != min_args)) { - AddError("'" + b.Symbols().NameFor(ident->symbol) + "' requires " + - std::to_string(min_args) + " template arguments", + AddError("'" + ident->symbol.Name() + "' requires " + std::to_string(min_args) + + " template arguments", ident->source); return nullptr; } } else { if (TINT_UNLIKELY(tmpl_ident->arguments.Length() < min_args)) { - AddError("'" + b.Symbols().NameFor(ident->symbol) + "' requires at least " + + AddError("'" + ident->symbol.Name() + "' requires at least " + std::to_string(min_args) + " template arguments", ident->source); return nullptr; } if (TINT_UNLIKELY(tmpl_ident->arguments.Length() > max_args)) { - AddError("'" + b.Symbols().NameFor(ident->symbol) + "' requires at most " + + AddError("'" + ident->symbol.Name() + "' requires at most " + std::to_string(max_args) + " template arguments", ident->source); return nullptr; @@ -2752,7 +2744,7 @@ type::Type* Resolver::BuiltinType(builtin::Builtin builtin_ty, const ast::Identi break; } - auto name = builder_->Symbols().NameFor(ident->symbol); + auto name = ident->symbol.Name(); TINT_ICE(Resolver, diagnostics_) << ident->source << " unhandled builtin type '" << name << "'"; return nullptr; } @@ -2940,7 +2932,7 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) { auto resolved = dependencies_.resolved_identifiers.Get(ident); if (!resolved) { TINT_ICE(Resolver, diagnostics_) - << "identifier '" << builder_->Symbols().NameFor(ident->symbol) << "' was not resolved"; + << "identifier '" << ident->symbol.Name() << "' was not resolved"; return nullptr; } @@ -2968,12 +2960,11 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) { if (auto decl = loop_block->Decls().Find(symbol)) { if (decl->order >= loop_block->NumDeclsAtFirstContinue()) { AddError("continue statement bypasses declaration of '" + - builder_->Symbols().NameFor(symbol) + "'", + symbol.Name() + "'", loop_block->FirstContinue()->source); - AddNote("identifier '" + builder_->Symbols().NameFor(symbol) + - "' declared here", + AddNote("identifier '" + symbol.Name() + "' declared here", decl->variable->Declaration()->source); - AddNote("identifier '" + builder_->Symbols().NameFor(symbol) + + AddNote("identifier '" + symbol.Name() + "' referenced in continuing block here", expr->source); return nullptr; @@ -3011,7 +3002,7 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) { // Note: The spec is currently vague around the rules here. See // https://github.com/gpuweb/gpuweb/issues/3081. Remove this comment when // resolved. - std::string desc = "var '" + builder_->Symbols().NameFor(symbol) + "' "; + std::string desc = "var '" + symbol.Name() + "' "; AddError(desc + "cannot be referenced at module-scope", expr->source); AddNote(desc + "declared here", variable->Declaration()->source); return nullptr; @@ -3116,7 +3107,7 @@ sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) { } TINT_UNREACHABLE(Resolver, diagnostics_) - << "unhandled resolved identifier: " << resolved->String(builder_->Symbols(), diagnostics_); + << "unhandled resolved identifier: " << resolved->String(diagnostics_); return nullptr; } @@ -3151,8 +3142,7 @@ sem::ValueExpression* Resolver::MemberAccessor(const ast::MemberAccessorExpressi } if (member == nullptr) { - AddError("struct member " + builder_->Symbols().NameFor(symbol) + " not found", - expr->source); + AddError("struct member " + symbol.Name() + " not found", expr->source); return nullptr; } @@ -3173,7 +3163,7 @@ sem::ValueExpression* Resolver::MemberAccessor(const ast::MemberAccessorExpressi }, [&](const type::Vector* vec) -> sem::ValueExpression* { - std::string s = builder_->Symbols().NameFor(expr->member->symbol); + std::string s = expr->member->symbol.Name(); auto size = s.size(); utils::Vector swizzle; swizzle.Reserve(s.size()); @@ -3474,7 +3464,7 @@ bool Resolver::InternalAttribute(const ast::InternalAttribute* attr) { bool Resolver::DiagnosticControl(const ast::DiagnosticControl& control) { Mark(control.rule_name); - auto rule_name = builder_->Symbols().NameFor(control.rule_name->symbol); + auto rule_name = control.rule_name->symbol.Name(); auto rule = builtin::ParseDiagnosticRule(rule_name); if (rule != builtin::DiagnosticRule::kUndefined) { validator_.DiagnosticFilters().Set(rule, control.severity); @@ -3646,7 +3636,7 @@ type::Type* Resolver::Alias(const ast::Alias* alias) { sem::Struct* Resolver::Structure(const ast::Struct* str) { auto struct_name = [&] { // - return builder_->Symbols().NameFor(str->name->symbol); + return str->name->symbol.Name(); }; if (validator_.IsValidationEnabled(str->attributes, @@ -3687,8 +3677,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) { Mark(member); Mark(member->name); if (auto added = member_map.Add(member->name->symbol, member); !added) { - AddError("redefinition of '" + builder_->Symbols().NameFor(member->name->symbol) + "'", - member->source); + AddError("redefinition of '" + member->name->symbol.Name() + "'", member->source); AddNote("previous definition is here", (*added.value)->source); return nullptr; } @@ -4230,7 +4219,7 @@ bool Resolver::ApplyAddressSpaceUsageToType(builtin::AddressSpace address_space, address_space, const_cast(member->Type()), decl->type->source)) { utils::StringStream err; err << "while analyzing structure member " << sem_.TypeNameOf(str) << "." - << builder_->Symbols().NameFor(member->Name()); + << member->Name().Name(); AddNote(err.str(), member->Source()); return false; } @@ -4369,9 +4358,9 @@ void Resolver::ApplyDiagnosticSeverities(NODE* node) { bool Resolver::CheckNotTemplated(const char* use, const ast::Identifier* ident) { if (TINT_UNLIKELY(ident->Is())) { - AddError(std::string(use) + " '" + builder_->Symbols().NameFor(ident->symbol) + - "' does not take template arguments", - ident->source); + AddError( + std::string(use) + " '" + ident->symbol.Name() + "' does not take template arguments", + ident->source); if (auto resolved = dependencies_.resolved_identifiers.Get(ident)) { if (auto* ast_node = resolved->Node()) { sem_.NoteDeclarationSource(ast_node); @@ -4385,9 +4374,7 @@ bool Resolver::CheckNotTemplated(const char* use, const ast::Identifier* ident) void Resolver::ErrorMismatchedResolvedIdentifier(const Source& source, const ResolvedIdentifier& resolved, std::string_view wanted) { - AddError("cannot use " + resolved.String(builder_->Symbols(), diagnostics_) + " as " + - std::string(wanted), - source); + AddError("cannot use " + resolved.String(diagnostics_) + " as " + std::string(wanted), source); sem_.NoteDeclarationSource(resolved.Node()); } diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h index 0e1b7d5a6d..1afa838ef5 100644 --- a/src/tint/resolver/resolver_test_helper.h +++ b/src/tint/resolver/resolver_test_helper.h @@ -112,12 +112,12 @@ class TestHelper : public ProgramBuilder { /// @param type a type /// @returns the name for `type` that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(ast::Type type) { return Symbols().NameFor(type->identifier->symbol); } + std::string FriendlyName(ast::Type type) { return type->identifier->symbol.Name(); } /// @param type a type /// @returns the name for `type` that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const type::Type* type) { return type->FriendlyName(Symbols()); } + std::string FriendlyName(const type::Type* type) { return type->FriendlyName(); } private: std::unique_ptr resolver_; diff --git a/src/tint/resolver/sem_helper.cc b/src/tint/resolver/sem_helper.cc index 36cc4c74d1..2357ce1dd7 100644 --- a/src/tint/resolver/sem_helper.cc +++ b/src/tint/resolver/sem_helper.cc @@ -32,7 +32,7 @@ std::string SemHelper::TypeNameOf(const type::Type* ty) const { } std::string SemHelper::RawTypeNameOf(const type::Type* ty) const { - return ty->FriendlyName(builder_->Symbols()); + return ty->FriendlyName(); } type::Type* SemHelper::TypeOf(const ast::Expression* expr) const { @@ -45,7 +45,7 @@ std::string SemHelper::Describe(const sem::Expression* expr) const { expr, // [&](const sem::VariableUser* var_expr) { auto* variable = var_expr->Variable()->Declaration(); - auto name = builder_->Symbols().NameFor(variable->name->symbol); + auto name = variable->name->symbol.Name(); auto* kind = Switch( variable, // [&](const ast::Var*) { return "var"; }, // @@ -57,16 +57,16 @@ std::string SemHelper::Describe(const sem::Expression* expr) const { return std::string(kind) + " '" + name + "'"; }, [&](const sem::ValueExpression* val_expr) { - auto type = val_expr->Type()->FriendlyName(builder_->Symbols()); + auto type = val_expr->Type()->FriendlyName(); return "value expression of type '" + type + "'"; }, [&](const sem::TypeExpression* ty_expr) { - auto name = ty_expr->Type()->FriendlyName(builder_->Symbols()); + auto name = ty_expr->Type()->FriendlyName(); return "type '" + name + "'"; }, [&](const sem::FunctionExpression* fn_expr) { auto* fn = fn_expr->Function()->Declaration(); - auto name = builder_->Symbols().NameFor(fn->name->symbol); + auto name = fn->name->symbol.Name(); return "function '" + name + "'"; }, [&](const sem::BuiltinEnumExpression* access) { @@ -128,37 +128,28 @@ void SemHelper::NoteDeclarationSource(const ast::Node* node) const { Switch( node, [&](const ast::Struct* n) { - AddNote("struct '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("struct '" + n->name->symbol.Name() + "' declared here", n->source); }, [&](const ast::Alias* n) { - AddNote("alias '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("alias '" + n->name->symbol.Name() + "' declared here", n->source); }, [&](const ast::Var* n) { - AddNote("var '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("var '" + n->name->symbol.Name() + "' declared here", n->source); }, [&](const ast::Let* n) { - AddNote("let '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("let '" + n->name->symbol.Name() + "' declared here", n->source); }, [&](const ast::Override* n) { - AddNote("override '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("override '" + n->name->symbol.Name() + "' declared here", n->source); }, [&](const ast::Const* n) { - AddNote("const '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("const '" + n->name->symbol.Name() + "' declared here", n->source); }, [&](const ast::Parameter* n) { - AddNote( - "parameter '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("parameter '" + n->name->symbol.Name() + "' declared here", n->source); }, [&](const ast::Function* n) { - AddNote("function '" + builder_->Symbols().NameFor(n->name->symbol) + "' declared here", - n->source); + AddNote("function '" + n->name->symbol.Name() + "' declared here", n->source); }); } diff --git a/src/tint/resolver/uniformity.cc b/src/tint/resolver/uniformity.cc index 7a4d25ef57..fc848261bd 100644 --- a/src/tint/resolver/uniformity.cc +++ b/src/tint/resolver/uniformity.cc @@ -178,7 +178,7 @@ struct FunctionInfo { /// @param func the AST function /// @param builder the program builder FunctionInfo(const ast::Function* func, const ProgramBuilder* builder) { - name = builder->Symbols().NameFor(func->name->symbol); + name = func->name->symbol.Name(); callsite_tag = {CallSiteTag::CallSiteNoRestriction}; function_tag = NoRestriction; @@ -196,7 +196,7 @@ struct FunctionInfo { parameters.Resize(func->params.Length()); for (size_t i = 0; i < func->params.Length(); i++) { auto* param = func->params[i]; - auto param_name = builder->Symbols().NameFor(param->name->symbol); + auto param_name = param->name->symbol.Name(); auto* sem = builder->Sem().Get(param); parameters[i].sem = sem; @@ -397,14 +397,12 @@ class UniformityGraph { /// @param expr the expression to get the symbol name of /// @returns the symbol name inline std::string NameFor(const ast::IdentifierExpression* expr) { - return builder_->Symbols().NameFor(expr->identifier->symbol); + return expr->identifier->symbol.Name(); } /// @param var the variable to get the name of /// @returns the name of the variable @p var - inline std::string NameFor(const ast::Variable* var) { - return builder_->Symbols().NameFor(var->name->symbol); - } + inline std::string NameFor(const ast::Variable* var) { return var->name->symbol.Name(); } /// @param var the variable to get the name of /// @returns the name of the variable @p var @@ -413,7 +411,7 @@ class UniformityGraph { /// @param fn the function to get the name of /// @returns the name of the function @p fn inline std::string NameFor(const sem::Function* fn) { - return builder_->Symbols().NameFor(fn->Declaration()->name->symbol); + return fn->Declaration()->name->symbol.Name(); } /// Process a function. diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index b005779d08..65d731028d 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -413,9 +413,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, return required_align; }; - auto member_name_of = [this](const sem::StructMember* sm) { - return symbols_.NameFor(sm->Name()); - }; + auto member_name_of = [](const sem::StructMember* sm) { return sm->Name().Name(); }; // Only validate the [type + address space] once if (!valid_type_storage_layouts_.Add(TypeAndAddressSpace{store_ty, address_space})) { @@ -427,7 +425,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, } auto note_usage = [&] { - AddNote("'" + store_ty->FriendlyName(symbols_) + "' used in address space '" + + AddNote("'" + store_ty->FriendlyName() + "' used in address space '" + utils::ToString(address_space) + "' here", source); }; @@ -447,7 +445,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, // Recurse into the member type. if (!AddressSpaceLayout(m->Type(), address_space, m->Declaration()->type->source)) { - AddNote("see layout of struct:\n" + str->Layout(symbols_), str->Source()); + AddNote("see layout of struct:\n" + str->Layout(), str->Source()); note_usage(); return false; } @@ -457,18 +455,18 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, !enabled_extensions_.Contains( builtin::Extension::kChromiumInternalRelaxedUniformLayout)) { AddError("the offset of a struct member of type '" + - m->Type()->UnwrapRef()->FriendlyName(symbols_) + - "' in address space '" + utils::ToString(address_space) + - "' must be a multiple of " + std::to_string(required_align) + - " bytes, but '" + member_name_of(m) + "' is currently at offset " + - std::to_string(m->Offset()) + ". Consider setting @align(" + - std::to_string(required_align) + ") on this member", + m->Type()->UnwrapRef()->FriendlyName() + "' in address space '" + + utils::ToString(address_space) + "' must be a multiple of " + + std::to_string(required_align) + " bytes, but '" + member_name_of(m) + + "' is currently at offset " + std::to_string(m->Offset()) + + ". Consider setting @align(" + std::to_string(required_align) + + ") on this member", m->Source()); - AddNote("see layout of struct:\n" + str->Layout(symbols_), str->Source()); + AddNote("see layout of struct:\n" + str->Layout(), str->Source()); if (auto* member_str = m->Type()->As()) { - AddNote("and layout of struct member:\n" + member_str->Layout(symbols_), + AddNote("and layout of struct member:\n" + member_str->Layout(), member_str->Source()); } @@ -493,11 +491,10 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, "'. Consider setting @align(16) on this member", m->Source()); - AddNote("see layout of struct:\n" + str->Layout(symbols_), str->Source()); + AddNote("see layout of struct:\n" + str->Layout(), str->Source()); auto* prev_member_str = prev_member->Type()->As(); - AddNote("and layout of previous member struct:\n" + - prev_member_str->Layout(symbols_), + AddNote("and layout of previous member struct:\n" + prev_member_str->Layout(), prev_member_str->Source()); note_usage(); return false; @@ -540,7 +537,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, AddError( "uniform storage requires that array elements are aligned to 16 bytes, but " "array element of type '" + - arr->ElemType()->FriendlyName(symbols_) + "' has a stride of " + + arr->ElemType()->FriendlyName() + "' has a stride of " + std::to_string(arr->Stride()) + " bytes. " + hint, source); return false; @@ -1070,7 +1067,7 @@ bool Validator::Function(const sem::Function* func, ast::PipelineStage stage) co } else if (TINT_UNLIKELY(IsValidationEnabled( decl->attributes, ast::DisabledValidation::kFunctionHasNoBody))) { TINT_ICE(Resolver, diagnostics_) - << "Function " << symbols_.NameFor(decl->name->symbol) << " has no body"; + << "Function " << decl->name->symbol.Name() << " has no body"; } for (auto* attr : decl->return_type_attributes) { @@ -1102,7 +1099,7 @@ bool Validator::Function(const sem::Function* func, ast::PipelineStage stage) co // a function behavior is always one of {}, or {Next}. if (TINT_UNLIKELY(func->Behaviors() != sem::Behaviors{} && func->Behaviors() != sem::Behavior::kNext)) { - auto name = symbols_.NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); TINT_ICE(Resolver, diagnostics_) << "function '" << name << "' behaviors are: " << func->Behaviors(); } @@ -1284,8 +1281,7 @@ bool Validator::EntryPoint(const sem::Function* func, ast::PipelineStage stage) member->Declaration()->attributes, member->Type(), member->Source(), param_or_ret, /*is_struct_member*/ true, member->Location())) { - AddNote("while analyzing entry point '" + - symbols_.NameFor(decl->name->symbol) + "'", + AddNote("while analyzing entry point '" + decl->name->symbol.Name() + "'", decl->source); return false; } @@ -1364,7 +1360,7 @@ bool Validator::EntryPoint(const sem::Function* func, ast::PipelineStage stage) // Bindings must not alias within a shader stage: two different variables in the // resource interface of a given shader must not have the same group and binding values, // when considered as a pair of values. - auto func_name = symbols_.NameFor(decl->name->symbol); + auto func_name = decl->name->symbol.Name(); AddError( "entry point '" + func_name + "' references multiple variables that use the same resource binding @group(" + @@ -1505,8 +1501,7 @@ bool Validator::Call(const sem::Call* call, sem::Statement* current_statement) c call->Target(), // [&](const sem::Function* fn) { AddError("ignoring return value of function '" + - symbols_.NameFor(fn->Declaration()->name->symbol) + - "' annotated with @must_use", + fn->Declaration()->name->symbol.Name() + "' annotated with @must_use", call->Declaration()->source); sem_.NoteDeclarationSource(fn->Declaration()); }, @@ -1741,7 +1736,7 @@ bool Validator::FunctionCall(const sem::Call* call, sem::Statement* current_stat auto* decl = call->Declaration(); auto* target = call->Target()->As(); auto sym = target->Declaration()->name->symbol; - auto name = symbols_.NameFor(sym); + auto name = sym.Name(); if (!current_statement) { // Function call at module-scope. AddError("functions cannot be called at module-scope", decl->source); @@ -1928,13 +1923,12 @@ bool Validator::PipelineStages(utils::VectorRef entry_points) co auto backtrace = [&](const sem::Function* func, const sem::Function* entry_point) { if (func != entry_point) { TraverseCallChain(diagnostics_, entry_point, func, [&](const sem::Function* f) { - AddNote( - "called by function '" + symbols_.NameFor(f->Declaration()->name->symbol) + "'", - f->Declaration()->source); + AddNote("called by function '" + f->Declaration()->name->symbol.Name() + "'", + f->Declaration()->source); }); - AddNote("called by entry point '" + - symbols_.NameFor(entry_point->Declaration()->name->symbol) + "'", - entry_point->Declaration()->source); + AddNote( + "called by entry point '" + entry_point->Declaration()->name->symbol.Name() + "'", + entry_point->Declaration()->source); } }; @@ -2040,33 +2034,33 @@ bool Validator::PushConstants(utils::VectorRef entry_points) con continue; } - AddError("entry point '" + symbols_.NameFor(ep->Declaration()->name->symbol) + + AddError("entry point '" + ep->Declaration()->name->symbol.Name() + "' uses two different 'push_constant' variables.", ep->Declaration()->source); AddNote("first 'push_constant' variable declaration is here", var->Declaration()->source); if (func != ep) { TraverseCallChain(diagnostics_, ep, func, [&](const sem::Function* f) { - AddNote("called by function '" + - symbols_.NameFor(f->Declaration()->name->symbol) + "'", - f->Declaration()->source); + AddNote( + "called by function '" + f->Declaration()->name->symbol.Name() + "'", + f->Declaration()->source); }); - AddNote("called by entry point '" + - symbols_.NameFor(ep->Declaration()->name->symbol) + "'", - ep->Declaration()->source); + AddNote( + "called by entry point '" + ep->Declaration()->name->symbol.Name() + "'", + ep->Declaration()->source); } AddNote("second 'push_constant' variable declaration is here", push_constant_var->Declaration()->source); if (push_constant_func != ep) { - TraverseCallChain( - diagnostics_, ep, push_constant_func, [&](const sem::Function* f) { - AddNote("called by function '" + - symbols_.NameFor(f->Declaration()->name->symbol) + "'", - f->Declaration()->source); - }); - AddNote("called by entry point '" + - symbols_.NameFor(ep->Declaration()->name->symbol) + "'", - ep->Declaration()->source); + TraverseCallChain(diagnostics_, ep, push_constant_func, + [&](const sem::Function* f) { + AddNote("called by function '" + + f->Declaration()->name->symbol.Name() + "'", + f->Declaration()->source); + }); + AddNote( + "called by entry point '" + ep->Declaration()->name->symbol.Name() + "'", + ep->Declaration()->source); } return false; } @@ -2484,7 +2478,7 @@ bool Validator::IncrementDecrementStatement(const ast::IncrementDecrementStateme [&](const ast::Override*) { return "cannot modify 'override'"; }); if (err) { AddError(err, lhs->source); - AddNote("'" + symbols_.NameFor(v->name->symbol) + "' is declared here:", v->source); + AddNote("'" + v->name->symbol.Name() + "' is declared here:", v->source); return false; } } @@ -2544,7 +2538,7 @@ bool Validator::DiagnosticControls(utils::VectorRefrule_name->symbol) << "' set to '" + ss << "severity of '" << dc->rule_name->symbol.Name() << "' set to '" << dc->severity << "' here"; AddNote(ss.str(), (*diag_added.value)->rule_name->source); } @@ -2589,7 +2583,7 @@ void Validator::RaiseArrayWithOverrideCountError(const Source& source) const { std::string Validator::VectorPretty(uint32_t size, const type::Type* element_type) const { type::Vector vec_type(element_type, size); - return vec_type.FriendlyName(symbols_); + return vec_type.FriendlyName(); } bool Validator::CheckTypeAccessAddressSpace( diff --git a/src/tint/sem/array_count.cc b/src/tint/sem/array_count.cc index d0f5145e40..90abb691ef 100644 --- a/src/tint/sem/array_count.cc +++ b/src/tint/sem/array_count.cc @@ -33,8 +33,8 @@ bool NamedOverrideArrayCount::Equals(const UniqueNode& other) const { return false; } -std::string NamedOverrideArrayCount::FriendlyName(const SymbolTable& symbols) const { - return symbols.NameFor(variable->Declaration()->name->symbol); +std::string NamedOverrideArrayCount::FriendlyName() const { + return variable->Declaration()->name->symbol.Name(); } type::ArrayCount* NamedOverrideArrayCount::Clone(type::CloneContext&) const { @@ -53,7 +53,7 @@ bool UnnamedOverrideArrayCount::Equals(const UniqueNode& other) const { return false; } -std::string UnnamedOverrideArrayCount::FriendlyName(const SymbolTable&) const { +std::string UnnamedOverrideArrayCount::FriendlyName() const { return "[unnamed override-expression]"; } diff --git a/src/tint/sem/array_count.h b/src/tint/sem/array_count.h index 9147160797..a4143d8244 100644 --- a/src/tint/sem/array_count.h +++ b/src/tint/sem/array_count.h @@ -40,9 +40,8 @@ class NamedOverrideArrayCount final : public Castable(Ident(name), utils::Empty, utils::Empty); auto* s = create(impl, impl->source, impl->name->symbol, utils::Empty, 4u /* align */, 4u /* size */, 4u /* size_no_padding */); - EXPECT_EQ(s->FriendlyName(Symbols()), "my_struct"); + EXPECT_EQ(s->FriendlyName(), "my_struct"); } } // namespace diff --git a/src/tint/symbol_table.cc b/src/tint/symbol_table.cc index c82a2843d2..aae76ffb75 100644 --- a/src/tint/symbol_table.cc +++ b/src/tint/symbol_table.cc @@ -56,11 +56,6 @@ Symbol SymbolTable::Get(const std::string& name) const { return it ? *it : Symbol(); } -std::string SymbolTable::NameFor(const Symbol symbol) const { - TINT_ASSERT_PROGRAM_IDS_EQUAL(Symbol, program_id_, symbol); - return symbol.Name(); -} - Symbol SymbolTable::New(std::string prefix /* = "" */) { if (prefix.empty()) { prefix = "tint_symbol"; diff --git a/src/tint/symbol_table.h b/src/tint/symbol_table.h index ea9199ebae..5eeaec2452 100644 --- a/src/tint/symbol_table.h +++ b/src/tint/symbol_table.h @@ -63,11 +63,6 @@ class SymbolTable { /// @returns the symbol for the name or Symbol() if not found. Symbol Get(const std::string& name) const; - /// Returns the name for the given symbol - /// @param symbol the symbol to retrieve the name for - /// @returns the symbol name or "" if not found - std::string NameFor(const Symbol symbol) const; - /// Returns a new unique symbol with the given name, possibly suffixed with a /// unique number. /// @param name the symbol name diff --git a/src/tint/symbol_table_test.cc b/src/tint/symbol_table_test.cc index 28f664dcb4..ebdb6d8927 100644 --- a/src/tint/symbol_table_test.cc +++ b/src/tint/symbol_table_test.cc @@ -36,19 +36,6 @@ TEST_F(SymbolTableTest, DeduplicatesNames) { EXPECT_EQ(Symbol(1, program_id, "name"), s.Register("name")); } -TEST_F(SymbolTableTest, ReturnsNameForSymbol) { - auto program_id = ProgramID::New(); - SymbolTable s{program_id}; - auto sym = s.Register("name"); - EXPECT_EQ("name", s.NameFor(sym)); -} - -TEST_F(SymbolTableTest, ReturnsBlankForMissingSymbol) { - auto program_id = ProgramID::New(); - SymbolTable s{program_id}; - EXPECT_EQ("$2", s.NameFor(Symbol(2, program_id, "$2"))); -} - TEST_F(SymbolTableTest, AssertsForBlankString) { EXPECT_FATAL_FAILURE( { diff --git a/src/tint/transform/add_block_attribute.cc b/src/tint/transform/add_block_attribute.cc index c486936788..a629fc461c 100644 --- a/src/tint/transform/add_block_attribute.cc +++ b/src/tint/transform/add_block_attribute.cc @@ -70,7 +70,7 @@ Transform::ApplyResult AddBlockAttribute::Apply(const Program* src, auto* wrapper = wrapper_structs.GetOrCreate(ty, [&] { auto* block = b.ASTNodes().Create(b.ID(), b.AllocateNodeID()); - auto wrapper_name = src->Symbols().NameFor(global->name->symbol) + "_block"; + auto wrapper_name = global->name->symbol.Name() + "_block"; auto* ret = b.create( b.Ident(b.Symbols().New(wrapper_name)), utils::Vector{b.Member(kMemberName, CreateASTTypeFor(ctx, ty))}, diff --git a/src/tint/transform/canonicalize_entry_point_io.cc b/src/tint/transform/canonicalize_entry_point_io.cc index 3c9c6d0469..840f8ffbc7 100644 --- a/src/tint/transform/canonicalize_entry_point_io.cc +++ b/src/tint/transform/canonicalize_entry_point_io.cc @@ -351,7 +351,7 @@ struct CanonicalizeEntryPointIO::State { } } - auto name = ctx.src->Symbols().NameFor(param->Declaration()->name->symbol); + auto name = param->Declaration()->name->symbol.Name(); auto* input_expr = AddInput(name, param->Type(), param->Location(), std::move(attributes)); inner_call_parameters.Push(input_expr); } @@ -376,7 +376,7 @@ struct CanonicalizeEntryPointIO::State { continue; } - auto name = ctx.src->Symbols().NameFor(member->Name()); + auto name = member->Name().Name(); auto attributes = CloneShaderIOAttributes(member->Declaration()->attributes, do_interpolate); @@ -405,7 +405,7 @@ struct CanonicalizeEntryPointIO::State { continue; } - auto name = ctx.src->Symbols().NameFor(member->Name()); + auto name = member->Name().Name(); auto attributes = CloneShaderIOAttributes(member->Declaration()->attributes, do_interpolate); @@ -530,7 +530,7 @@ struct CanonicalizeEntryPointIO::State { } else { name = ctx.dst->Symbols().Register(outval.name); } - member_names.insert(ctx.dst->Symbols().NameFor(name)); + member_names.insert(name.Name()); wrapper_struct_output_members.Push({ ctx.dst->Member(name, outval.type, std::move(outval.attributes)), @@ -598,7 +598,7 @@ struct CanonicalizeEntryPointIO::State { } else { // Add a suffix to the function name, as the wrapper function will take // the original entry point name. - auto ep_name = ctx.src->Symbols().NameFor(func_ast->name->symbol); + auto ep_name = func_ast->name->symbol.Name(); inner_name = ctx.dst->Symbols().New(ep_name + "_inner"); } diff --git a/src/tint/transform/clamp_frag_depth.cc b/src/tint/transform/clamp_frag_depth.cc index 77d897d009..4948ec58fb 100644 --- a/src/tint/transform/clamp_frag_depth.cc +++ b/src/tint/transform/clamp_frag_depth.cc @@ -127,7 +127,7 @@ struct ClampFragDepth::State { auto helper = io_structs_clamp_helpers.GetOrCreate(struct_ty, [&] { auto return_ty = fn->return_type; auto fn_sym = - b.Symbols().New("clamp_frag_depth_" + sym.NameFor(struct_ty->name->symbol)); + b.Symbols().New("clamp_frag_depth_" + struct_ty->name->symbol.Name()); utils::Vector initializer_args; for (auto* member : struct_ty->members) { diff --git a/src/tint/transform/combine_samplers.cc b/src/tint/transform/combine_samplers.cc index ca8111c7fb..aa1a6866e0 100644 --- a/src/tint/transform/combine_samplers.cc +++ b/src/tint/transform/combine_samplers.cc @@ -183,11 +183,9 @@ struct CombineSamplers::State { for (auto pair : fn->TextureSamplerPairs()) { const sem::Variable* texture_var = pair.first; const sem::Variable* sampler_var = pair.second; - std::string name = - ctx.src->Symbols().NameFor(texture_var->Declaration()->name->symbol); + std::string name = texture_var->Declaration()->name->symbol.Name(); if (sampler_var) { - name += "_" + ctx.src->Symbols().NameFor( - sampler_var->Declaration()->name->symbol); + name += "_" + sampler_var->Declaration()->name->symbol.Name(); } if (IsGlobal(pair)) { // Both texture and sampler are global; add a new global variable diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index f2146f3bcc..fb8dc62303 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -468,7 +468,7 @@ struct DecomposeMemoryAccess::State { return utils::GetOrCreate(load_funcs, LoadStoreKey{el_ty, buffer}, [&] { utils::Vector params{b.Param("offset", b.ty.u32())}; - auto name = b.Symbols().New(ctx.dst->Symbols().NameFor(buffer) + "_load"); + auto name = b.Symbols().New(buffer.Name() + "_load"); if (auto* intrinsic = IntrinsicLoadFor(ctx.dst, el_ty, address_space, buffer)) { auto el_ast_ty = CreateASTTypeFor(ctx, el_ty); @@ -551,7 +551,7 @@ struct DecomposeMemoryAccess::State { b.Param("value", CreateASTTypeFor(ctx, el_ty)), }; - auto name = b.Symbols().New(ctx.dst->Symbols().NameFor(buffer) + "_store"); + auto name = b.Symbols().New(buffer.Name() + "_store"); if (auto* intrinsic = IntrinsicStoreFor(ctx.dst, el_ty, buffer)) { b.Func(name, params, b.ty.void_(), nullptr, @@ -677,7 +677,7 @@ struct DecomposeMemoryAccess::State { ret_ty = CreateASTTypeFor(ctx, intrinsic->ReturnType()); } - auto name = b.Symbols().New(ctx.dst->Symbols().NameFor(buffer) + intrinsic->str()); + auto name = b.Symbols().New(buffer.Name() + intrinsic->str()); b.Func(name, std::move(params), ret_ty, nullptr, utils::Vector{ atomic, diff --git a/src/tint/transform/direct_variable_access.cc b/src/tint/transform/direct_variable_access.cc index 00d1e6733f..8c06afce47 100644 --- a/src/tint/transform/direct_variable_access.cc +++ b/src/tint/transform/direct_variable_access.cc @@ -689,7 +689,7 @@ struct DirectVariableAccess::State { // This is derived from the original function name and the pointer parameter // chains. utils::StringStream ss; - ss << ctx.src->Symbols().NameFor(target->Declaration()->name->symbol); + ss << target->Declaration()->name->symbol.Name(); for (auto* param : target->Parameters()) { if (auto indices = target_signature.Find(param)) { ss << "_" << AccessShapeName(*indices); @@ -1086,7 +1086,7 @@ struct DirectVariableAccess::State { if (IsPrivateOrFunction(shape.root.address_space)) { ss << "F"; } else { - ss << ctx.src->Symbols().NameFor(shape.root.variable->Declaration()->name->symbol); + ss << shape.root.variable->Declaration()->name->symbol.Name(); } for (auto& op : shape.ops) { @@ -1100,7 +1100,7 @@ struct DirectVariableAccess::State { auto* member = std::get_if(&op); if (TINT_LIKELY(member)) { - ss << sym.NameFor(*member); + ss << member->Name(); continue; } @@ -1160,7 +1160,7 @@ struct DirectVariableAccess::State { /// @returns a new Symbol starting with @p symbol concatenated with @p suffix, and possibly an /// underscore and number, if the symbol is already taken. Symbol UniqueSymbolWithSuffix(Symbol symbol, const std::string& suffix) { - auto str = ctx.src->Symbols().NameFor(symbol) + suffix; + auto str = symbol.Name() + suffix; return unique_symbols.GetOrCreate(str, [&] { return b.Symbols().New(str); }); } diff --git a/src/tint/transform/packed_vec3.cc b/src/tint/transform/packed_vec3.cc index 8a23221d7b..9ef78a6e12 100644 --- a/src/tint/transform/packed_vec3.cc +++ b/src/tint/transform/packed_vec3.cc @@ -120,7 +120,7 @@ struct PackedVec3::State { // type, to avoid changing the array element stride. return b.ty(packed_vec3_wrapper_struct_names.GetOrCreate(vec, [&]() { auto name = b.Symbols().New( - "tint_packed_vec3_" + vec->type()->FriendlyName(src->Symbols()) + + "tint_packed_vec3_" + vec->type()->FriendlyName() + (array_element ? "_array_element" : "_struct_member")); auto* member = b.Member(kStructMemberName, MakePackedVec3(vec), @@ -191,9 +191,8 @@ struct PackedVec3::State { } } // Create the new structure. - auto struct_name = b.Symbols().New( - src->Symbols().NameFor(str->Declaration()->name->symbol) + - "_tint_packed_vec3"); + auto struct_name = b.Symbols().New(str->Declaration()->name->symbol.Name() + + "_tint_packed_vec3"); b.Structure(struct_name, std::move(members)); return struct_name; }); diff --git a/src/tint/transform/pad_structs.cc b/src/tint/transform/pad_structs.cc index 8516aa3d98..90f2e59a88 100644 --- a/src/tint/transform/pad_structs.cc +++ b/src/tint/transform/pad_structs.cc @@ -71,7 +71,7 @@ Transform::ApplyResult PadStructs::Apply(const Program* src, const DataMap&, Dat bool has_runtime_sized_array = false; utils::Vector new_members; for (auto* mem : str->Members()) { - auto name = src->Symbols().NameFor(mem->Name()); + auto name = mem->Name().Name(); if (offset < mem->Offset()) { CreatePadding(&new_members, &padding_members, ctx.dst, mem->Offset() - offset); diff --git a/src/tint/transform/preserve_padding.cc b/src/tint/transform/preserve_padding.cc index e8c95e3de0..6df1a1c210 100644 --- a/src/tint/transform/preserve_padding.cc +++ b/src/tint/transform/preserve_padding.cc @@ -165,7 +165,7 @@ struct PreservePadding::State { return call_helper([&]() { utils::Vector body; for (auto member : str->Members()) { - auto name = sym.NameFor(member->Declaration()->name->symbol); + auto name = member->Declaration()->name->symbol.Name(); body.Push(MakeAssignment(member->Type(), b.MemberAccessor(b.Deref(kDestParamName), name), b.MemberAccessor(kValueParamName, name))); diff --git a/src/tint/transform/renamer.cc b/src/tint/transform/renamer.cc index 708c6ec94a..af26109e80 100644 --- a/src/tint/transform/renamer.cc +++ b/src/tint/transform/renamer.cc @@ -1332,7 +1332,7 @@ Transform::ApplyResult Renamer::Apply(const Program* src, if (target == Target::kAll) { return true; } - auto name = src->Symbols().NameFor(symbol); + auto name = symbol.Name(); if (!text::utf8::IsASCII(name)) { // name is non-ascii. All of the backend keywords are ascii, so rename if we're not // preserving unicode symbols. @@ -1388,7 +1388,7 @@ Transform::ApplyResult Renamer::Apply(const Program* src, Data::Remappings out; for (auto it : remappings) { - out[ctx.src->Symbols().NameFor(it.key)] = ctx.dst->Symbols().NameFor(it.value); + out[it.key.Name()] = it.value.Name(); } outputs.Add(std::move(out)); diff --git a/src/tint/transform/robustness.cc b/src/tint/transform/robustness.cc index 2eb74a14f4..c25bcac5a8 100644 --- a/src/tint/transform/robustness.cc +++ b/src/tint/transform/robustness.cc @@ -264,8 +264,7 @@ struct Robustness::State { auto* sem_param = sem.Get(param); if (auto* ptr = sem_param->Type()->As()) { if (ActionFor(ptr->AddressSpace()) == Action::kPredicate) { - auto name = b.Symbols().New(src->Symbols().NameFor(param->name->symbol) + - "_predicate"); + auto name = b.Symbols().New(param->name->symbol.Name() + "_predicate"); ctx.InsertAfter(fn->params, param, b.Param(name, b.ty.bool_())); // Associate the pointer parameter expressions with the predicate. diff --git a/src/tint/transform/simplify_pointers.cc b/src/tint/transform/simplify_pointers.cc index b5af458a48..e8c2bf9ec5 100644 --- a/src/tint/transform/simplify_pointers.cc +++ b/src/tint/transform/simplify_pointers.cc @@ -166,8 +166,7 @@ struct SimplifyPointers::State { // We have a sub-expression that needs to be saved. // Create a new variable auto saved_name = ctx.dst->Symbols().New( - ctx.src->Symbols().NameFor(var->Declaration()->name->symbol) + - "_save"); + var->Declaration()->name->symbol.Name() + "_save"); auto* decl = ctx.dst->Decl(ctx.dst->Let(saved_name, ctx.Clone(idx_expr))); saved.Push(decl); diff --git a/src/tint/transform/single_entry_point.cc b/src/tint/transform/single_entry_point.cc index 8be90bb5e7..5e8081202d 100644 --- a/src/tint/transform/single_entry_point.cc +++ b/src/tint/transform/single_entry_point.cc @@ -50,7 +50,7 @@ Transform::ApplyResult SingleEntryPoint::Apply(const Program* src, if (!f->IsEntryPoint()) { continue; } - if (src->Symbols().NameFor(f->name->symbol) == cfg->entry_point_name) { + if (f->name->symbol.Name() == cfg->entry_point_name) { entry_point = f; break; } diff --git a/src/tint/transform/spirv_atomic.cc b/src/tint/transform/spirv_atomic.cc index f41fbb7127..82b955ce3a 100644 --- a/src/tint/transform/spirv_atomic.cc +++ b/src/tint/transform/spirv_atomic.cc @@ -133,7 +133,7 @@ struct SpirvAtomic::State { auto* member = str->members[i]; if (forked.atomic_members.count(i)) { auto type = AtomicTypeFor(ctx.src->Sem().Get(member)->Type()); - auto name = ctx.src->Symbols().NameFor(member->name->symbol); + auto name = member->name->symbol.Name(); members.Push(b.Member(name, type, ctx.Clone(member->attributes))); } else { members.Push(ctx.Clone(member)); @@ -157,8 +157,7 @@ struct SpirvAtomic::State { ForkedStruct& Fork(const ast::Struct* str) { auto& forked = forked_structs[str]; if (!forked.name.IsValid()) { - forked.name = - b.Symbols().New(ctx.src->Symbols().NameFor(str->name->symbol) + "_atomic"); + forked.name = b.Symbols().New(str->name->symbol.Name() + "_atomic"); } return forked; } @@ -220,8 +219,7 @@ struct SpirvAtomic::State { }, [&](const type::Reference* ref) { return AtomicTypeFor(ref->StoreType()); }, [&](Default) { - TINT_ICE(Transform, b.Diagnostics()) - << "unhandled type: " << ty->FriendlyName(ctx.src->Symbols()); + TINT_ICE(Transform, b.Diagnostics()) << "unhandled type: " << ty->FriendlyName(); return ast::Type{}; }); } diff --git a/src/tint/transform/std140.cc b/src/tint/transform/std140.cc index bfd8c80e83..b22a6e07c4 100644 --- a/src/tint/transform/std140.cc +++ b/src/tint/transform/std140.cc @@ -313,8 +313,7 @@ struct Std140::State { // Member is of a type that requires forking for std140-layout fork_std140 = true; auto attrs = ctx.Clone(member->Declaration()->attributes); - members.Push( - b.Member(sym.NameFor(member->Name()), std140_ty, std::move(attrs))); + members.Push(b.Member(member->Name().Name(), std140_ty, std::move(attrs))); continue; // Next member } @@ -335,7 +334,7 @@ struct Std140::State { } // Create a new forked structure, and insert it just under the original // structure. - auto name = b.Symbols().New(sym.NameFor(str->Name()) + "_std140"); + auto name = b.Symbols().New(str->Name().Name() + "_std140"); auto* std140 = b.create(b.Ident(name), std::move(members), ctx.Clone(str->Declaration()->attributes)); ctx.InsertAfter(src->AST().GlobalDeclarations(), global, std140); @@ -371,7 +370,7 @@ struct Std140::State { std::string PrefixForUniqueNames(const ast::Struct* str, Symbol unsuffixed, uint32_t count) const { - auto prefix = sym.NameFor(unsuffixed); + auto prefix = unsuffixed.Name(); // Keep on inserting '_' between the unsuffixed name and the suffix numbers until the name // is unique. while (true) { @@ -385,7 +384,7 @@ struct Std140::State { bool unique = true; for (auto* member : str->members) { // The member name must be unique over the entire set of `count` suffixed names. - if (strings.Contains(sym.NameFor(member->name->symbol))) { + if (strings.Contains(member->name->symbol.Name())) { unique = false; break; } @@ -529,7 +528,7 @@ struct Std140::State { } TINT_ICE(Transform, b.Diagnostics()) << "unexpected variable found walking access chain: " - << sym.NameFor(user->Variable()->Declaration()->name->symbol); + << user->Variable()->Declaration()->name->symbol.Name(); return Action::kError; }, [&](const sem::StructMemberAccess* a) { @@ -632,7 +631,7 @@ struct Std140::State { const std::string ConvertSuffix(const type::Type* ty) { return Switch( ty, // - [&](const sem::Struct* str) { return sym.NameFor(str->Name()); }, + [&](const sem::Struct* str) { return str->Name().Name(); }, [&](const type::Array* arr) { auto count = arr->ConstantCount(); if (TINT_UNLIKELY(!count)) { @@ -710,9 +709,8 @@ struct Std140::State { args.Push(b.Call(mat_ty, std::move(mat_args))); } else { // Convert the member - args.Push( - Convert(member->Type(), - b.MemberAccessor(param, sym.NameFor(member->Name())))); + args.Push(Convert(member->Type(), + b.MemberAccessor(param, member->Name().Name()))); } } stmts.Push(b.Return(b.Call(CreateASTTypeFor(ctx, ty), std::move(args)))); @@ -920,8 +918,8 @@ struct Std140::State { auto mat_member_idx = std::get(chain.indices[std140_mat_idx]); auto* mat_member = str->Members()[mat_member_idx]; if (column_idx == 0) { - name += "_" + sym.NameFor(mat_member->Name()) + "_p" + - std::to_string(column_param_idx); + name += + "_" + mat_member->Name().Name() + "_p" + std::to_string(column_param_idx); } auto mat_columns = *std140_mat_members.Get(mat_member); expr = b.MemberAccessor(expr, mat_columns[column_idx]->name->symbol); @@ -1023,7 +1021,7 @@ struct Std140::State { return b.MemberAccessor(b.Deref(let), column_member->name->symbol); }); ty = mat_member->Type(); - name += "_" + sym.NameFor(mat_member->Name()); + name += "_" + mat_member->Name().Name(); } else { // Non-structure-member matrix. The columns are decomposed into a new, bespoke // std140 structure. @@ -1079,7 +1077,7 @@ struct Std140::State { if (std::get_if(&access)) { const auto symbol = chain.var->Declaration()->name->symbol; const auto* expr = b.Expr(ctx.Clone(symbol)); - const auto name = src->Symbols().NameFor(symbol); + const auto name = symbol.Name(); ty = chain.var->Type()->UnwrapRef(); return {expr, ty, name}; } @@ -1137,7 +1135,7 @@ struct Std140::State { ty, // [&](const sem::Struct* str) -> ExprTypeName { auto* member = str->Members()[idx]; - auto member_name = sym.NameFor(member->Name()); + auto member_name = member->Name().Name(); auto* expr = b.MemberAccessor(lhs, member_name); ty = member->Type(); return {expr, ty, member_name}; diff --git a/src/tint/transform/transform_test.cc b/src/tint/transform/transform_test.cc index deffae3210..1201e98f33 100644 --- a/src/tint/transform/transform_test.cc +++ b/src/tint/transform/transform_test.cc @@ -45,7 +45,7 @@ struct CreateASTTypeForTest : public testing::Test, public Transform { TEST_F(CreateASTTypeForTest, Basic) { auto check = [&](ast::Type ty, const char* expect) { - ast::CheckIdentifier(ast_type_builder.Symbols(), ty->identifier, expect); + ast::CheckIdentifier(ty->identifier, expect); }; check(create([](ProgramBuilder& b) { return b.create(); }), "i32"); @@ -61,14 +61,14 @@ TEST_F(CreateASTTypeForTest, Matrix) { return b.create(column_type, 3u); }); - ast::CheckIdentifier(ast_type_builder.Symbols(), mat, ast::Template("mat3x2", "f32")); + ast::CheckIdentifier(mat, ast::Template("mat3x2", "f32")); } TEST_F(CreateASTTypeForTest, Vector) { auto vec = create([](ProgramBuilder& b) { return b.create(b.create(), 2u); }); - ast::CheckIdentifier(ast_type_builder.Symbols(), vec, ast::Template("vec2", "f32")); + ast::CheckIdentifier(vec, ast::Template("vec2", "f32")); } TEST_F(CreateASTTypeForTest, ArrayImplicitStride) { @@ -77,7 +77,7 @@ TEST_F(CreateASTTypeForTest, ArrayImplicitStride) { 4u, 4u, 32u, 32u); }); - ast::CheckIdentifier(ast_type_builder.Symbols(), arr, ast::Template("array", "f32", 2_u)); + ast::CheckIdentifier(arr, ast::Template("array", "f32", 2_u)); auto* tmpl_attr = arr->identifier->As(); ASSERT_NE(tmpl_attr, nullptr); EXPECT_TRUE(tmpl_attr->attributes.IsEmpty()); @@ -88,7 +88,7 @@ TEST_F(CreateASTTypeForTest, ArrayNonImplicitStride) { return b.create(b.create(), b.create(2u), 4u, 4u, 64u, 32u); }); - ast::CheckIdentifier(ast_type_builder.Symbols(), arr, ast::Template("array", "f32", 2_u)); + ast::CheckIdentifier(arr, ast::Template("array", "f32", 2_u)); auto* tmpl_attr = arr->identifier->As(); ASSERT_NE(tmpl_attr, nullptr); ASSERT_EQ(tmpl_attr->attributes.Length(), 1u); @@ -114,7 +114,7 @@ TEST_F(CreateASTTypeForTest, AliasedArrayWithComplexOverrideLength) { CloneContext ctx(&ast_type_builder, &program, false); auto ast_ty = CreateASTTypeFor(ctx, arr_ty); - ast::CheckIdentifier(ast_type_builder.Symbols(), ast_ty, "A"); + ast::CheckIdentifier(ast_ty, "A"); } TEST_F(CreateASTTypeForTest, Struct) { @@ -124,7 +124,7 @@ TEST_F(CreateASTTypeForTest, Struct) { 4u /* align */, 4u /* size */, 4u /* size_no_padding */); }); - ast::CheckIdentifier(ast_type_builder.Symbols(), str, "S"); + ast::CheckIdentifier(str, "S"); } TEST_F(CreateASTTypeForTest, PrivatePointer) { @@ -133,7 +133,7 @@ TEST_F(CreateASTTypeForTest, PrivatePointer) { builtin::Access::kReadWrite); }); - ast::CheckIdentifier(ast_type_builder.Symbols(), ptr, ast::Template("ptr", "private", "i32")); + ast::CheckIdentifier(ptr, ast::Template("ptr", "private", "i32")); } TEST_F(CreateASTTypeForTest, StorageReadWritePointer) { @@ -142,8 +142,7 @@ TEST_F(CreateASTTypeForTest, StorageReadWritePointer) { builtin::Access::kReadWrite); }); - ast::CheckIdentifier(ast_type_builder.Symbols(), ptr, - ast::Template("ptr", "storage", "i32", "read_write")); + ast::CheckIdentifier(ptr, ast::Template("ptr", "storage", "i32", "read_write")); } } // namespace diff --git a/src/tint/transform/unshadow.cc b/src/tint/transform/unshadow.cc index 9639cfcc8c..1dd4234473 100644 --- a/src/tint/transform/unshadow.cc +++ b/src/tint/transform/unshadow.cc @@ -52,7 +52,7 @@ struct Unshadow::State { auto rename = [&](const sem::Variable* v) -> const ast::Variable* { auto* decl = v->Declaration(); - auto name = src->Symbols().NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); auto symbol = b.Symbols().New(name); renamed_to.Add(v, symbol); diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc index d8871987e4..064be002f8 100644 --- a/src/tint/transform/vertex_pulling.cc +++ b/src/tint/transform/vertex_pulling.cc @@ -385,7 +385,7 @@ struct VertexPulling::State { err << "VertexAttributeDescriptor for location " << std::to_string(attribute_desc.shader_location) << " has format " << attribute_desc.format << " but shader expects " - << var.type->FriendlyName(src->Symbols()); + << var.type->FriendlyName(); b.Diagnostics().add_error(diag::System::Transform, err.str()); return nullptr; } diff --git a/src/tint/transform/zero_init_workgroup_memory.cc b/src/tint/transform/zero_init_workgroup_memory.cc index 9040e09b3d..8572ef28ec 100644 --- a/src/tint/transform/zero_init_workgroup_memory.cc +++ b/src/tint/transform/zero_init_workgroup_memory.cc @@ -365,7 +365,7 @@ struct ZeroInitWorkgroupMemory::State { } TINT_UNREACHABLE(Transform, b.Diagnostics()) - << "could not zero workgroup type: " << ty->FriendlyName(ctx.src->Symbols()); + << "could not zero workgroup type: " << ty->FriendlyName(); return false; } diff --git a/src/tint/type/abstract_float.cc b/src/tint/type/abstract_float.cc index 46cbf154e3..74e5d347a9 100644 --- a/src/tint/type/abstract_float.cc +++ b/src/tint/type/abstract_float.cc @@ -28,7 +28,7 @@ bool AbstractFloat::Equals(const UniqueNode& other) const { return other.Is(); } -std::string AbstractFloat::FriendlyName(const SymbolTable&) const { +std::string AbstractFloat::FriendlyName() const { return "abstract-float"; } diff --git a/src/tint/type/abstract_float.h b/src/tint/type/abstract_float.h index 8ec08823b9..2c6ac09c56 100644 --- a/src/tint/type/abstract_float.h +++ b/src/tint/type/abstract_float.h @@ -35,9 +35,8 @@ class AbstractFloat final : public Castable { /// @returns true if this type is equal to the given type bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type when printed in diagnostics. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/abstract_int.cc b/src/tint/type/abstract_int.cc index 4b409372e3..7fc883df45 100644 --- a/src/tint/type/abstract_int.cc +++ b/src/tint/type/abstract_int.cc @@ -29,7 +29,7 @@ bool AbstractInt::Equals(const UniqueNode& other) const { return other.Is(); } -std::string AbstractInt::FriendlyName(const SymbolTable&) const { +std::string AbstractInt::FriendlyName() const { return "abstract-int"; } diff --git a/src/tint/type/abstract_int.h b/src/tint/type/abstract_int.h index 7c96c8f7a1..f1f67d86eb 100644 --- a/src/tint/type/abstract_int.h +++ b/src/tint/type/abstract_int.h @@ -35,9 +35,8 @@ class AbstractInt final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type when printed in diagnostics. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/array.cc b/src/tint/type/array.cc index 96c745c8cf..71ec6b3b99 100644 --- a/src/tint/type/array.cc +++ b/src/tint/type/array.cc @@ -81,14 +81,14 @@ bool Array::Equals(const UniqueNode& other) const { return false; } -std::string Array::FriendlyName(const SymbolTable& symbols) const { +std::string Array::FriendlyName() const { utils::StringStream out; if (!IsStrideImplicit()) { out << "@stride(" << stride_ << ") "; } - out << "array<" << element_->FriendlyName(symbols); + out << "array<" << element_->FriendlyName(); - auto count_str = count_->FriendlyName(symbols); + auto count_str = count_->FriendlyName(); if (!count_str.empty()) { out << ", " << count_str; } diff --git a/src/tint/type/array.h b/src/tint/type/array.h index 95ed164032..79b8e3c104 100644 --- a/src/tint/type/array.h +++ b/src/tint/type/array.h @@ -93,10 +93,9 @@ class Array final : public Castable { /// natural stride bool IsStrideImplicit() const { return stride_ == implicit_stride_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/array_count.cc b/src/tint/type/array_count.cc index e50db29f50..8ddda4cd52 100644 --- a/src/tint/type/array_count.cc +++ b/src/tint/type/array_count.cc @@ -36,7 +36,7 @@ bool ConstantArrayCount::Equals(const UniqueNode& other) const { return false; } -std::string ConstantArrayCount::FriendlyName(const SymbolTable&) const { +std::string ConstantArrayCount::FriendlyName() const { return std::to_string(value); } @@ -52,7 +52,7 @@ bool RuntimeArrayCount::Equals(const UniqueNode& other) const { return other.Is(); } -std::string RuntimeArrayCount::FriendlyName(const SymbolTable&) const { +std::string RuntimeArrayCount::FriendlyName() const { return ""; } diff --git a/src/tint/type/array_count.h b/src/tint/type/array_count.h index 90fc253606..94dc135363 100644 --- a/src/tint/type/array_count.h +++ b/src/tint/type/array_count.h @@ -29,9 +29,8 @@ class ArrayCount : public Castable { public: ~ArrayCount() override; - /// @param symbols the symbol table /// @returns the friendly name for this array count - virtual std::string FriendlyName(const SymbolTable& symbols) const = 0; + virtual std::string FriendlyName() const = 0; /// @param ctx the clone context /// @returns a clone of this type @@ -60,9 +59,8 @@ class ConstantArrayCount final : public Castable /// @returns true if this array count is equal to other bool Equals(const UniqueNode& other) const override; - /// @param symbols the symbol table /// @returns the friendly name for this array count - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type @@ -87,9 +85,8 @@ class RuntimeArrayCount final : public Castable { /// @returns true if this array count is equal to other bool Equals(const UniqueNode& other) const override; - /// @param symbols the symbol table /// @returns the friendly name for this array count - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/array_test.cc b/src/tint/type/array_test.cc index 8f80a63638..545fd746c4 100644 --- a/src/tint/type/array_test.cc +++ b/src/tint/type/array_test.cc @@ -98,22 +98,22 @@ TEST_F(ArrayTest, Equals) { TEST_F(ArrayTest, FriendlyNameRuntimeSized) { auto* arr = create(create(), create(), 0u, 4u, 4u, 4u); - EXPECT_EQ(arr->FriendlyName(Symbols()), "array"); + EXPECT_EQ(arr->FriendlyName(), "array"); } TEST_F(ArrayTest, FriendlyNameStaticSized) { auto* arr = create(create(), create(5u), 4u, 20u, 4u, 4u); - EXPECT_EQ(arr->FriendlyName(Symbols()), "array"); + EXPECT_EQ(arr->FriendlyName(), "array"); } TEST_F(ArrayTest, FriendlyNameRuntimeSizedNonImplicitStride) { auto* arr = create(create(), create(), 0u, 4u, 8u, 4u); - EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array"); + EXPECT_EQ(arr->FriendlyName(), "@stride(8) array"); } TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) { auto* arr = create(create(), create(5u), 4u, 20u, 8u, 4u); - EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array"); + EXPECT_EQ(arr->FriendlyName(), "@stride(8) array"); } TEST_F(ArrayTest, IsConstructable) { diff --git a/src/tint/type/atomic.cc b/src/tint/type/atomic.cc index 39e2aaee16..a1d5da1022 100644 --- a/src/tint/type/atomic.cc +++ b/src/tint/type/atomic.cc @@ -42,9 +42,9 @@ bool Atomic::Equals(const type::UniqueNode& other) const { return false; } -std::string Atomic::FriendlyName(const SymbolTable& symbols) const { +std::string Atomic::FriendlyName() const { utils::StringStream out; - out << "atomic<" << subtype_->FriendlyName(symbols) << ">"; + out << "atomic<" << subtype_->FriendlyName() << ">"; return out.str(); } diff --git a/src/tint/type/atomic.h b/src/tint/type/atomic.h index 9b3d4fc451..4f304f07cb 100644 --- a/src/tint/type/atomic.h +++ b/src/tint/type/atomic.h @@ -38,10 +38,9 @@ class Atomic final : public Castable { /// @returns the atomic type const type::Type* Type() const { return subtype_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the size in bytes of the type. uint32_t Size() const override; diff --git a/src/tint/type/atomic_test.cc b/src/tint/type/atomic_test.cc index e7126cbd28..261d4aef59 100644 --- a/src/tint/type/atomic_test.cc +++ b/src/tint/type/atomic_test.cc @@ -47,7 +47,7 @@ TEST_F(AtomicTest, Equals) { TEST_F(AtomicTest, FriendlyName) { auto* a = create(create()); - EXPECT_EQ(a->FriendlyName(Symbols()), "atomic"); + EXPECT_EQ(a->FriendlyName(), "atomic"); } TEST_F(AtomicTest, Clone) { diff --git a/src/tint/type/bool.cc b/src/tint/type/bool.cc index 31fcb270a3..6c972c32be 100644 --- a/src/tint/type/bool.cc +++ b/src/tint/type/bool.cc @@ -34,7 +34,7 @@ bool Bool::Equals(const UniqueNode& other) const { return other.Is(); } -std::string Bool::FriendlyName(const SymbolTable&) const { +std::string Bool::FriendlyName() const { return "bool"; } diff --git a/src/tint/type/bool.h b/src/tint/type/bool.h index d73341c80e..6173bbb45d 100644 --- a/src/tint/type/bool.h +++ b/src/tint/type/bool.h @@ -40,10 +40,9 @@ class Bool final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the size in bytes of the type. /// @note: booleans are not host-sharable, but still may exist in workgroup diff --git a/src/tint/type/bool_test.cc b/src/tint/type/bool_test.cc index b061927310..347ccd64b5 100644 --- a/src/tint/type/bool_test.cc +++ b/src/tint/type/bool_test.cc @@ -41,7 +41,7 @@ TEST_F(BoolTest, Equals) { TEST_F(BoolTest, FriendlyName) { Bool b; - EXPECT_EQ(b.FriendlyName(Symbols()), "bool"); + EXPECT_EQ(b.FriendlyName(), "bool"); } TEST_F(BoolTest, Clone) { diff --git a/src/tint/type/depth_multisampled_texture.cc b/src/tint/type/depth_multisampled_texture.cc index fc3b753de3..765fec33e5 100644 --- a/src/tint/type/depth_multisampled_texture.cc +++ b/src/tint/type/depth_multisampled_texture.cc @@ -46,7 +46,7 @@ bool DepthMultisampledTexture::Equals(const UniqueNode& other) const { return false; } -std::string DepthMultisampledTexture::FriendlyName(const SymbolTable&) const { +std::string DepthMultisampledTexture::FriendlyName() const { utils::StringStream out; out << "texture_depth_multisampled_" << dim(); return out.str(); diff --git a/src/tint/type/depth_multisampled_texture.h b/src/tint/type/depth_multisampled_texture.h index 31efaeb842..4a6d3c2dd4 100644 --- a/src/tint/type/depth_multisampled_texture.h +++ b/src/tint/type/depth_multisampled_texture.h @@ -36,10 +36,9 @@ class DepthMultisampledTexture final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/depth_texture_test.cc b/src/tint/type/depth_texture_test.cc index 4ff970a719..14ec2e4cc1 100644 --- a/src/tint/type/depth_texture_test.cc +++ b/src/tint/type/depth_texture_test.cc @@ -67,7 +67,7 @@ TEST_F(DepthTextureTest, Dim) { TEST_F(DepthTextureTest, FriendlyName) { DepthTexture d(TextureDimension::kCube); - EXPECT_EQ(d.FriendlyName(Symbols()), "texture_depth_cube"); + EXPECT_EQ(d.FriendlyName(), "texture_depth_cube"); } TEST_F(DepthTextureTest, Clone) { diff --git a/src/tint/type/external_texture.cc b/src/tint/type/external_texture.cc index 986c2b487d..85469a7904 100644 --- a/src/tint/type/external_texture.cc +++ b/src/tint/type/external_texture.cc @@ -31,7 +31,7 @@ bool ExternalTexture::Equals(const UniqueNode& other) const { return other.Is(); } -std::string ExternalTexture::FriendlyName(const SymbolTable&) const { +std::string ExternalTexture::FriendlyName() const { return "texture_external"; } diff --git a/src/tint/type/external_texture.h b/src/tint/type/external_texture.h index 947eb88b36..be46048457 100644 --- a/src/tint/type/external_texture.h +++ b/src/tint/type/external_texture.h @@ -34,10 +34,9 @@ class ExternalTexture final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/external_texture_test.cc b/src/tint/type/external_texture_test.cc index 0752590883..5610ae5d4c 100644 --- a/src/tint/type/external_texture_test.cc +++ b/src/tint/type/external_texture_test.cc @@ -64,7 +64,7 @@ TEST_F(ExternalTextureTest, Dim) { TEST_F(ExternalTextureTest, FriendlyName) { ExternalTexture s; - EXPECT_EQ(s.FriendlyName(Symbols()), "texture_external"); + EXPECT_EQ(s.FriendlyName(), "texture_external"); } TEST_F(ExternalTextureTest, Clone) { diff --git a/src/tint/type/f16.cc b/src/tint/type/f16.cc index 45b88ddcb8..842d147c73 100644 --- a/src/tint/type/f16.cc +++ b/src/tint/type/f16.cc @@ -34,7 +34,7 @@ bool F16::Equals(const UniqueNode& other) const { return other.Is(); } -std::string F16::FriendlyName(const SymbolTable&) const { +std::string F16::FriendlyName() const { return "f16"; } diff --git a/src/tint/type/f16.h b/src/tint/type/f16.h index c35d878cab..21100ffdb7 100644 --- a/src/tint/type/f16.h +++ b/src/tint/type/f16.h @@ -34,10 +34,9 @@ class F16 final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the size in bytes of the type. uint32_t Size() const override; diff --git a/src/tint/type/f16_test.cc b/src/tint/type/f16_test.cc index a9a2fe0c9e..a477f70bd1 100644 --- a/src/tint/type/f16_test.cc +++ b/src/tint/type/f16_test.cc @@ -41,7 +41,7 @@ TEST_F(F16Test, Equals) { TEST_F(F16Test, FriendlyName) { F16 f; - EXPECT_EQ(f.FriendlyName(Symbols()), "f16"); + EXPECT_EQ(f.FriendlyName(), "f16"); } TEST_F(F16Test, Clone) { diff --git a/src/tint/type/f32.cc b/src/tint/type/f32.cc index 8af826c11f..b7c5135596 100644 --- a/src/tint/type/f32.cc +++ b/src/tint/type/f32.cc @@ -34,7 +34,7 @@ bool F32::Equals(const UniqueNode& other) const { return other.Is(); } -std::string F32::FriendlyName(const SymbolTable&) const { +std::string F32::FriendlyName() const { return "f32"; } diff --git a/src/tint/type/f32.h b/src/tint/type/f32.h index 12b298f07e..397911d990 100644 --- a/src/tint/type/f32.h +++ b/src/tint/type/f32.h @@ -34,10 +34,9 @@ class F32 final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the size in bytes of the type. uint32_t Size() const override; diff --git a/src/tint/type/f32_test.cc b/src/tint/type/f32_test.cc index 43d7823a9c..ae9e6d486f 100644 --- a/src/tint/type/f32_test.cc +++ b/src/tint/type/f32_test.cc @@ -41,7 +41,7 @@ TEST_F(F32Test, Equals) { TEST_F(F32Test, FriendlyName) { F32 f; - EXPECT_EQ(f.FriendlyName(Symbols()), "f32"); + EXPECT_EQ(f.FriendlyName(), "f32"); } TEST_F(F32Test, Clone) { diff --git a/src/tint/type/i32.cc b/src/tint/type/i32.cc index 9ca1c690b8..045706d8b0 100644 --- a/src/tint/type/i32.cc +++ b/src/tint/type/i32.cc @@ -34,7 +34,7 @@ bool I32::Equals(const UniqueNode& other) const { return other.Is(); } -std::string I32::FriendlyName(const SymbolTable&) const { +std::string I32::FriendlyName() const { return "i32"; } diff --git a/src/tint/type/i32.h b/src/tint/type/i32.h index bdbf559561..ddf59b4bd9 100644 --- a/src/tint/type/i32.h +++ b/src/tint/type/i32.h @@ -34,10 +34,9 @@ class I32 final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the size in bytes of the type. uint32_t Size() const override; diff --git a/src/tint/type/i32_test.cc b/src/tint/type/i32_test.cc index 97c90b1882..6535667f1c 100644 --- a/src/tint/type/i32_test.cc +++ b/src/tint/type/i32_test.cc @@ -41,7 +41,7 @@ TEST_F(I32Test, Equals) { TEST_F(I32Test, FriendlyName) { I32 i; - EXPECT_EQ(i.FriendlyName(Symbols()), "i32"); + EXPECT_EQ(i.FriendlyName(), "i32"); } TEST_F(I32Test, Clone) { diff --git a/src/tint/type/matrix.cc b/src/tint/type/matrix.cc index 195a9e9da0..59dfaa9abc 100644 --- a/src/tint/type/matrix.cc +++ b/src/tint/type/matrix.cc @@ -51,9 +51,9 @@ bool Matrix::Equals(const UniqueNode& other) const { return false; } -std::string Matrix::FriendlyName(const SymbolTable& symbols) const { +std::string Matrix::FriendlyName() const { utils::StringStream out; - out << "mat" << columns_ << "x" << rows_ << "<" << subtype_->FriendlyName(symbols) << ">"; + out << "mat" << columns_ << "x" << rows_ << "<" << subtype_->FriendlyName() << ">"; return out.str(); } diff --git a/src/tint/type/matrix.h b/src/tint/type/matrix.h index 72bb2e55fc..c6707a2a2a 100644 --- a/src/tint/type/matrix.h +++ b/src/tint/type/matrix.h @@ -51,10 +51,9 @@ class Matrix final : public Castable { /// @returns the column-vector type of the matrix const Vector* ColumnType() const { return column_type_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the size in bytes of the type. This may include tail padding. uint32_t Size() const override; diff --git a/src/tint/type/matrix_test.cc b/src/tint/type/matrix_test.cc index 09b46f1e51..e9c81a79d4 100644 --- a/src/tint/type/matrix_test.cc +++ b/src/tint/type/matrix_test.cc @@ -62,7 +62,7 @@ TEST_F(MatrixTest, FriendlyName) { I32 i32; Vector c{&i32, 3}; Matrix m{&c, 2}; - EXPECT_EQ(m.FriendlyName(Symbols()), "mat2x3"); + EXPECT_EQ(m.FriendlyName(), "mat2x3"); } TEST_F(MatrixTest, Clone) { diff --git a/src/tint/type/multisampled_texture.cc b/src/tint/type/multisampled_texture.cc index 0b2dfd0b63..b63c68113e 100644 --- a/src/tint/type/multisampled_texture.cc +++ b/src/tint/type/multisampled_texture.cc @@ -40,9 +40,9 @@ bool MultisampledTexture::Equals(const UniqueNode& other) const { return false; } -std::string MultisampledTexture::FriendlyName(const SymbolTable& symbols) const { +std::string MultisampledTexture::FriendlyName() const { utils::StringStream out; - out << "texture_multisampled_" << dim() << "<" << type_->FriendlyName(symbols) << ">"; + out << "texture_multisampled_" << dim() << "<" << type_->FriendlyName() << ">"; return out.str(); } diff --git a/src/tint/type/multisampled_texture.h b/src/tint/type/multisampled_texture.h index c5e66d73c1..d6c2e50423 100644 --- a/src/tint/type/multisampled_texture.h +++ b/src/tint/type/multisampled_texture.h @@ -40,10 +40,9 @@ class MultisampledTexture final : public Castable /// @returns the subtype of the sampled texture const Type* type() const { return type_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/multisampled_texture_test.cc b/src/tint/type/multisampled_texture_test.cc index 1a4c2b0aa6..e02a109f98 100644 --- a/src/tint/type/multisampled_texture_test.cc +++ b/src/tint/type/multisampled_texture_test.cc @@ -79,7 +79,7 @@ TEST_F(MultisampledTextureTest, Type) { TEST_F(MultisampledTextureTest, FriendlyName) { F32 f32; MultisampledTexture s(TextureDimension::k3d, &f32); - EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d"); + EXPECT_EQ(s.FriendlyName(), "texture_multisampled_3d"); } TEST_F(MultisampledTextureTest, Clone) { diff --git a/src/tint/type/pointer.cc b/src/tint/type/pointer.cc index aa77816832..2922b0e797 100644 --- a/src/tint/type/pointer.cc +++ b/src/tint/type/pointer.cc @@ -43,13 +43,13 @@ bool Pointer::Equals(const UniqueNode& other) const { return false; } -std::string Pointer::FriendlyName(const SymbolTable& symbols) const { +std::string Pointer::FriendlyName() const { utils::StringStream out; out << "ptr<"; if (address_space_ != builtin::AddressSpace::kUndefined) { out << address_space_ << ", "; } - out << subtype_->FriendlyName(symbols) << ", " << access_; + out << subtype_->FriendlyName() << ", " << access_; out << ">"; return out.str(); } diff --git a/src/tint/type/pointer.h b/src/tint/type/pointer.h index 6e73999629..0eed27ceb0 100644 --- a/src/tint/type/pointer.h +++ b/src/tint/type/pointer.h @@ -48,10 +48,9 @@ class Pointer final : public Castable { /// @returns the access control of the reference builtin::Access Access() const { return access_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/pointer_test.cc b/src/tint/type/pointer_test.cc index ff030cc66d..63992428a2 100644 --- a/src/tint/type/pointer_test.cc +++ b/src/tint/type/pointer_test.cc @@ -74,13 +74,13 @@ TEST_F(PointerTest, Equals) { TEST_F(PointerTest, FriendlyName) { auto* r = create(create(), builtin::AddressSpace::kUndefined, builtin::Access::kRead); - EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); + EXPECT_EQ(r->FriendlyName(), "ptr"); } TEST_F(PointerTest, FriendlyNameWithAddressSpace) { auto* r = create(create(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead); - EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); + EXPECT_EQ(r->FriendlyName(), "ptr"); } TEST_F(PointerTest, Clone) { diff --git a/src/tint/type/reference.cc b/src/tint/type/reference.cc index 03ed224576..bf2d22ce4e 100644 --- a/src/tint/type/reference.cc +++ b/src/tint/type/reference.cc @@ -44,13 +44,13 @@ bool Reference::Equals(const UniqueNode& other) const { return false; } -std::string Reference::FriendlyName(const SymbolTable& symbols) const { +std::string Reference::FriendlyName() const { utils::StringStream out; out << "ref<"; if (address_space_ != builtin::AddressSpace::kUndefined) { out << address_space_ << ", "; } - out << subtype_->FriendlyName(symbols) << ", " << access_; + out << subtype_->FriendlyName() << ", " << access_; out << ">"; return out.str(); } diff --git a/src/tint/type/reference.h b/src/tint/type/reference.h index 8bc5e33e28..794b48b413 100644 --- a/src/tint/type/reference.h +++ b/src/tint/type/reference.h @@ -48,10 +48,9 @@ class Reference final : public Castable { /// @returns the resolved access control of the reference. builtin::Access Access() const { return access_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/reference_test.cc b/src/tint/type/reference_test.cc index 634b17ae73..a34ffa1803 100644 --- a/src/tint/type/reference_test.cc +++ b/src/tint/type/reference_test.cc @@ -74,13 +74,13 @@ TEST_F(ReferenceTest, Equals) { TEST_F(ReferenceTest, FriendlyName) { auto* r = create(create(), builtin::AddressSpace::kUndefined, builtin::Access::kRead); - EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); + EXPECT_EQ(r->FriendlyName(), "ref"); } TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) { auto* r = create(create(), builtin::AddressSpace::kWorkgroup, builtin::Access::kRead); - EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); + EXPECT_EQ(r->FriendlyName(), "ref"); } TEST_F(ReferenceTest, Clone) { diff --git a/src/tint/type/sampled_texture.cc b/src/tint/type/sampled_texture.cc index b3e6e1061f..8a4e440f46 100644 --- a/src/tint/type/sampled_texture.cc +++ b/src/tint/type/sampled_texture.cc @@ -39,9 +39,9 @@ bool SampledTexture::Equals(const UniqueNode& other) const { return false; } -std::string SampledTexture::FriendlyName(const SymbolTable& symbols) const { +std::string SampledTexture::FriendlyName() const { utils::StringStream out; - out << "texture_" << dim() << "<" << type_->FriendlyName(symbols) << ">"; + out << "texture_" << dim() << "<" << type_->FriendlyName() << ">"; return out.str(); } diff --git a/src/tint/type/sampled_texture.h b/src/tint/type/sampled_texture.h index 1a83165aca..35208b7336 100644 --- a/src/tint/type/sampled_texture.h +++ b/src/tint/type/sampled_texture.h @@ -40,10 +40,9 @@ class SampledTexture final : public Castable { /// @returns the subtype of the sampled texture Type* type() const { return const_cast(type_); } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/sampled_texture_test.cc b/src/tint/type/sampled_texture_test.cc index 23635410fb..bfe2354901 100644 --- a/src/tint/type/sampled_texture_test.cc +++ b/src/tint/type/sampled_texture_test.cc @@ -83,7 +83,7 @@ TEST_F(SampledTextureTest, Type) { TEST_F(SampledTextureTest, FriendlyName) { F32 f32; SampledTexture s(TextureDimension::k3d, &f32); - EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d"); + EXPECT_EQ(s.FriendlyName(), "texture_3d"); } TEST_F(SampledTextureTest, Clone) { diff --git a/src/tint/type/sampler.cc b/src/tint/type/sampler.cc index b7e0aa212b..271b8be6d2 100644 --- a/src/tint/type/sampler.cc +++ b/src/tint/type/sampler.cc @@ -33,7 +33,7 @@ bool Sampler::Equals(const UniqueNode& other) const { return false; } -std::string Sampler::FriendlyName(const SymbolTable&) const { +std::string Sampler::FriendlyName() const { return kind_ == SamplerKind::kSampler ? "sampler" : "sampler_comparison"; } diff --git a/src/tint/type/sampler.h b/src/tint/type/sampler.h index fb2ebb4283..9a3554f965 100644 --- a/src/tint/type/sampler.h +++ b/src/tint/type/sampler.h @@ -42,10 +42,9 @@ class Sampler final : public Castable { /// @returns true if this is a comparison sampler bool IsComparison() const { return kind_ == SamplerKind::kComparisonSampler; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/type/sampler_test.cc b/src/tint/type/sampler_test.cc index 8323e292fa..fd0b1d426f 100644 --- a/src/tint/type/sampler_test.cc +++ b/src/tint/type/sampler_test.cc @@ -55,12 +55,12 @@ TEST_F(SamplerTest, Equals) { TEST_F(SamplerTest, FriendlyNameSampler) { Sampler s{SamplerKind::kSampler}; - EXPECT_EQ(s.FriendlyName(Symbols()), "sampler"); + EXPECT_EQ(s.FriendlyName(), "sampler"); } TEST_F(SamplerTest, FriendlyNameComparisonSampler) { Sampler s{SamplerKind::kComparisonSampler}; - EXPECT_EQ(s.FriendlyName(Symbols()), "sampler_comparison"); + EXPECT_EQ(s.FriendlyName(), "sampler_comparison"); } TEST_F(SamplerTest, Clone) { diff --git a/src/tint/type/storage_texture.cc b/src/tint/type/storage_texture.cc index 180db4f9f3..7aa84c1a0c 100644 --- a/src/tint/type/storage_texture.cc +++ b/src/tint/type/storage_texture.cc @@ -43,7 +43,7 @@ bool StorageTexture::Equals(const UniqueNode& other) const { return false; } -std::string StorageTexture::FriendlyName(const SymbolTable&) const { +std::string StorageTexture::FriendlyName() const { utils::StringStream out; out << "texture_storage_" << dim() << "<" << texel_format_ << ", " << access_ << ">"; return out.str(); diff --git a/src/tint/type/storage_texture.h b/src/tint/type/storage_texture.h index de1b6de059..206e40331c 100644 --- a/src/tint/type/storage_texture.h +++ b/src/tint/type/storage_texture.h @@ -58,10 +58,9 @@ class StorageTexture final : public Castable { /// @returns the access control builtin::Access access() const { return access_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param format the storage texture image format /// @param type_mgr the Manager used to build the returned type diff --git a/src/tint/type/storage_texture_test.cc b/src/tint/type/storage_texture_test.cc index 8e0174e172..1779a9f16b 100644 --- a/src/tint/type/storage_texture_test.cc +++ b/src/tint/type/storage_texture_test.cc @@ -96,7 +96,7 @@ TEST_F(StorageTextureTest, Format) { TEST_F(StorageTextureTest, FriendlyName) { auto* s = Create(TextureDimension::k2dArray, builtin::TexelFormat::kRgba32Float, builtin::Access::kReadWrite); - EXPECT_EQ(s->FriendlyName(Symbols()), "texture_storage_2d_array"); + EXPECT_EQ(s->FriendlyName(), "texture_storage_2d_array"); } TEST_F(StorageTextureTest, F32) { diff --git a/src/tint/type/struct.cc b/src/tint/type/struct.cc index 7649691288..bffaa215a7 100644 --- a/src/tint/type/struct.cc +++ b/src/tint/type/struct.cc @@ -92,14 +92,14 @@ uint32_t Struct::Size() const { return size_; } -std::string Struct::FriendlyName(const SymbolTable& symbols) const { - return symbols.NameFor(name_); +std::string Struct::FriendlyName() const { + return name_.Name(); } -std::string Struct::Layout(const tint::SymbolTable& symbols) const { +std::string Struct::Layout() const { utils::StringStream ss; - auto member_name_of = [&](const StructMember* sm) { return symbols.NameFor(sm->Name()); }; + auto member_name_of = [&](const StructMember* sm) { return sm->Name().Name(); }; if (Members().IsEmpty()) { return {}; @@ -128,7 +128,7 @@ std::string Struct::Layout(const tint::SymbolTable& symbols) const { << align << ") size(" << std::setw(size_w) << size << ") */ " << s << ";\n"; }; - print_struct_begin_line(Align(), Size(), UnwrapRef()->FriendlyName(symbols)); + print_struct_begin_line(Align(), Size(), UnwrapRef()->FriendlyName()); for (size_t i = 0; i < Members().Length(); ++i) { auto* const m = Members()[i]; @@ -147,7 +147,7 @@ std::string Struct::Layout(const tint::SymbolTable& symbols) const { // Output member std::string member_name = member_name_of(m); print_member_line(m->Offset(), m->Align(), m->Size(), - member_name + " : " + m->Type()->UnwrapRef()->FriendlyName(symbols)); + member_name + " : " + m->Type()->UnwrapRef()->FriendlyName()); } // Output struct size padding, if any @@ -163,7 +163,7 @@ std::string Struct::Layout(const tint::SymbolTable& symbols) const { } Struct* Struct::Clone(CloneContext& ctx) const { - auto sym = ctx.dst.st->Register(ctx.src.st->NameFor(name_)); + auto sym = ctx.dst.st->Register(name_.Name()); utils::Vector members; for (const auto& mem : members_) { @@ -192,7 +192,7 @@ StructMember::StructMember(tint::Source source, StructMember::~StructMember() = default; StructMember* StructMember::Clone(CloneContext& ctx) const { - auto sym = ctx.dst.st->Register(ctx.src.st->NameFor(name_)); + auto sym = ctx.dst.st->Register(name_.Name()); auto* ty = type_->Clone(ctx); return ctx.dst.mgr->Get(source_, sym, ty, index_, offset_, align_, size_, location_); diff --git a/src/tint/type/struct.h b/src/tint/type/struct.h index 013011134a..035ea7cc07 100644 --- a/src/tint/type/struct.h +++ b/src/tint/type/struct.h @@ -131,15 +131,13 @@ class Struct : public Castable { return pipeline_stage_uses_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; - /// @param symbols the program's symbol table /// @returns a multiline string that describes the layout of this struct, /// including size and alignment information. - std::string Layout(const tint::SymbolTable& symbols) const; + std::string Layout() const; /// @param concrete the conversion-rank ordered concrete versions of this abstract structure. void SetConcreteTypes(utils::VectorRef concrete) { concrete_types_ = concrete; } diff --git a/src/tint/type/struct_test.cc b/src/tint/type/struct_test.cc index 6434a24ad9..7bfb43770d 100644 --- a/src/tint/type/struct_test.cc +++ b/src/tint/type/struct_test.cc @@ -46,7 +46,7 @@ TEST_F(TypeStructTest, FriendlyName) { auto name = Sym("my_struct"); auto* s = create(Source{}, name, utils::Empty, 4u /* align */, 4u /* size */, 4u /* size_no_padding */); - EXPECT_EQ(s->FriendlyName(Symbols()), "my_struct"); + EXPECT_EQ(s->FriendlyName(), "my_struct"); } TEST_F(TypeStructTest, Layout) { @@ -70,7 +70,7 @@ TEST_F(TypeStructTest, Layout) { auto* sem_inner_st = p.Sem().Get(inner_st); auto* sem_outer_st = p.Sem().Get(outer_st); - EXPECT_EQ(sem_inner_st->Layout(p.Symbols()), + EXPECT_EQ(sem_inner_st->Layout(), R"(/* align(16) size(64) */ struct Inner { /* offset( 0) align( 4) size( 4) */ a : i32; /* offset( 4) align( 4) size( 4) */ b : u32; @@ -81,7 +81,7 @@ TEST_F(TypeStructTest, Layout) { /* offset(32) align( 8) size(32) */ e : mat4x2; /* */ };)"); - EXPECT_EQ(sem_outer_st->Layout(p.Symbols()), + EXPECT_EQ(sem_outer_st->Layout(), R"(/* align(16) size(80) */ struct Outer { /* offset( 0) align(16) size(64) */ inner : Inner; /* offset(64) align( 4) size( 4) */ a : i32; @@ -224,7 +224,7 @@ TEST_F(TypeStructTest, Clone) { auto* st = s->Clone(ctx); EXPECT_TRUE(new_st.Get("my_struct").IsValid()); - EXPECT_EQ(new_st.NameFor(st->Name()), "my_struct"); + EXPECT_EQ(st->Name().Name(), "my_struct"); EXPECT_EQ(st->Align(), 4u); EXPECT_EQ(st->Size(), 8u); @@ -233,14 +233,14 @@ TEST_F(TypeStructTest, Clone) { auto members = st->Members(); ASSERT_EQ(members.Length(), 2u); - EXPECT_EQ(new_st.NameFor(members[0]->Name()), "b"); + EXPECT_EQ(members[0]->Name().Name(), "b"); EXPECT_TRUE(members[0]->Type()->Is()); EXPECT_EQ(members[0]->Index(), 0u); EXPECT_EQ(members[0]->Offset(), 0u); EXPECT_EQ(members[0]->Align(), 16u); EXPECT_EQ(members[0]->Size(), 12u); - EXPECT_EQ(new_st.NameFor(members[1]->Name()), "a"); + EXPECT_EQ(members[1]->Name().Name(), "a"); EXPECT_TRUE(members[1]->Type()->Is()); EXPECT_EQ(members[1]->Index(), 1u); EXPECT_EQ(members[1]->Offset(), 16u); diff --git a/src/tint/type/type.h b/src/tint/type/type.h index a02c9ac90b..083934e761 100644 --- a/src/tint/type/type.h +++ b/src/tint/type/type.h @@ -52,10 +52,9 @@ class Type : public Castable { /// Destructor ~Type() override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - virtual std::string FriendlyName(const SymbolTable& symbols) const = 0; + virtual std::string FriendlyName() const = 0; /// @returns the inner most pointee type if this is a pointer, `this` /// otherwise diff --git a/src/tint/type/u32.cc b/src/tint/type/u32.cc index 249a47dda2..f1eaf66a87 100644 --- a/src/tint/type/u32.cc +++ b/src/tint/type/u32.cc @@ -34,7 +34,7 @@ bool U32::Equals(const UniqueNode& other) const { return other.Is(); } -std::string U32::FriendlyName(const SymbolTable&) const { +std::string U32::FriendlyName() const { return "u32"; } diff --git a/src/tint/type/u32.h b/src/tint/type/u32.h index 8d796423f9..456436ac32 100644 --- a/src/tint/type/u32.h +++ b/src/tint/type/u32.h @@ -34,10 +34,9 @@ class U32 final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the size in bytes of the type. uint32_t Size() const override; diff --git a/src/tint/type/u32_test.cc b/src/tint/type/u32_test.cc index 8f17e62bfe..9c64dcb7dd 100644 --- a/src/tint/type/u32_test.cc +++ b/src/tint/type/u32_test.cc @@ -41,7 +41,7 @@ TEST_F(U32Test, Equals) { TEST_F(U32Test, FriendlyName) { U32 u; - EXPECT_EQ(u.FriendlyName(Symbols()), "u32"); + EXPECT_EQ(u.FriendlyName(), "u32"); } TEST_F(U32Test, Clone) { diff --git a/src/tint/type/vector.cc b/src/tint/type/vector.cc index 9f1f415bf2..3ee68e91f7 100644 --- a/src/tint/type/vector.cc +++ b/src/tint/type/vector.cc @@ -47,12 +47,12 @@ bool Vector::Equals(const UniqueNode& other) const { return false; } -std::string Vector::FriendlyName(const SymbolTable& symbols) const { +std::string Vector::FriendlyName() const { utils::StringStream out; if (packed_) { out << "__packed_"; } - out << "vec" << width_ << "<" << subtype_->FriendlyName(symbols) << ">"; + out << "vec" << width_ << "<" << subtype_->FriendlyName() << ">"; return out.str(); } diff --git a/src/tint/type/vector.h b/src/tint/type/vector.h index e7fd881615..04e349ad5a 100644 --- a/src/tint/type/vector.h +++ b/src/tint/type/vector.h @@ -40,10 +40,9 @@ class Vector : public Castable { /// @returns the type of the vector elements const Type* type() const { return subtype_; } - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @returns the number of elements in the vector uint32_t Width() const { return width_; } diff --git a/src/tint/type/vector_test.cc b/src/tint/type/vector_test.cc index acc62ed8c5..7d40be4283 100644 --- a/src/tint/type/vector_test.cc +++ b/src/tint/type/vector_test.cc @@ -71,13 +71,13 @@ TEST_F(VectorTest, Equals) { TEST_F(VectorTest, FriendlyName) { auto* f32 = create(); auto* v = create(f32, 3u); - EXPECT_EQ(v->FriendlyName(Symbols()), "vec3"); + EXPECT_EQ(v->FriendlyName(), "vec3"); } TEST_F(VectorTest, FriendlyName_Packed) { auto* f32 = create(); auto* v = create(f32, 3u, true); - EXPECT_EQ(v->FriendlyName(Symbols()), "__packed_vec3"); + EXPECT_EQ(v->FriendlyName(), "__packed_vec3"); } TEST_F(VectorTest, Clone) { diff --git a/src/tint/type/void.cc b/src/tint/type/void.cc index bfe2baf89f..c562a5280e 100644 --- a/src/tint/type/void.cc +++ b/src/tint/type/void.cc @@ -28,7 +28,7 @@ bool Void::Equals(const UniqueNode& other) const { return other.Is(); } -std::string Void::FriendlyName(const SymbolTable&) const { +std::string Void::FriendlyName() const { return "void"; } diff --git a/src/tint/type/void.h b/src/tint/type/void.h index 02b2eee710..b24ea9fdff 100644 --- a/src/tint/type/void.h +++ b/src/tint/type/void.h @@ -34,10 +34,9 @@ class Void final : public Castable { /// @returns true if the this type is equal to @p other bool Equals(const UniqueNode& other) const override; - /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. - std::string FriendlyName(const SymbolTable& symbols) const override; + std::string FriendlyName() const override; /// @param ctx the clone context /// @returns a clone of this type diff --git a/src/tint/writer/append_vector_test.cc b/src/tint/writer/append_vector_test.cc index d2a77df396..ff58ba3c94 100644 --- a/src/tint/writer/append_vector_test.cc +++ b/src/tint/writer/append_vector_test.cc @@ -89,7 +89,7 @@ TEST_F(AppendVectorTest, Vec2i32_u32) { EXPECT_EQ(vec_123->args[1], scalar_2); auto* u32_to_i32 = vec_123->args[2]->As(); ASSERT_NE(u32_to_i32, nullptr); - ast::CheckIdentifier(Symbols(), u32_to_i32->target, "i32"); + ast::CheckIdentifier(u32_to_i32->target, "i32"); ASSERT_EQ(u32_to_i32->args.Length(), 1u); EXPECT_EQ(u32_to_i32->args[0], scalar_3); @@ -136,13 +136,13 @@ TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) { auto* v2u32_to_v2i32 = vec_123->args[0]->As(); ASSERT_NE(v2u32_to_v2i32, nullptr); - ast::CheckIdentifier(Symbols(), v2u32_to_v2i32->target, ast::Template("vec2", "i32")); + ast::CheckIdentifier(v2u32_to_v2i32->target, ast::Template("vec2", "i32")); EXPECT_EQ(v2u32_to_v2i32->args.Length(), 1u); EXPECT_EQ(v2u32_to_v2i32->args[0], uvec_12); auto* u32_to_i32 = vec_123->args[1]->As(); ASSERT_NE(u32_to_i32, nullptr); - ast::CheckIdentifier(Symbols(), u32_to_i32->target, "i32"); + ast::CheckIdentifier(u32_to_i32->target, "i32"); ASSERT_EQ(u32_to_i32->args.Length(), 1u); EXPECT_EQ(u32_to_i32->args[0], scalar_3); @@ -186,7 +186,7 @@ TEST_F(AppendVectorTest, Vec2i32_f32) { EXPECT_EQ(vec_123->args[1], scalar_2); auto* f32_to_i32 = vec_123->args[2]->As(); ASSERT_NE(f32_to_i32, nullptr); - ast::CheckIdentifier(Symbols(), f32_to_i32->target, "i32"); + ast::CheckIdentifier(f32_to_i32->target, "i32"); ASSERT_EQ(f32_to_i32->args.Length(), 1u); EXPECT_EQ(f32_to_i32->args[0], scalar_3); @@ -392,7 +392,7 @@ TEST_F(AppendVectorTest, Vec2i32Var_f32Var) { EXPECT_EQ(vec_123->args[0], vec_12); auto* f32_to_i32 = vec_123->args[1]->As(); ASSERT_NE(f32_to_i32, nullptr); - ast::CheckIdentifier(Symbols(), f32_to_i32->target, "i32"); + ast::CheckIdentifier(f32_to_i32->target, "i32"); ASSERT_EQ(f32_to_i32->args.Length(), 1u); EXPECT_EQ(f32_to_i32->args[0], scalar_3); diff --git a/src/tint/writer/glsl/generator.cc b/src/tint/writer/glsl/generator.cc index 41d2cdfd17..32f14aa486 100644 --- a/src/tint/writer/glsl/generator.cc +++ b/src/tint/writer/glsl/generator.cc @@ -52,7 +52,7 @@ Result Generate(const Program* program, const Options& options, const std::strin // Collect the list of entry points in the sanitized program. for (auto* func : sanitized_result.program.AST().Functions()) { if (func->IsEntryPoint()) { - auto name = sanitized_result.program.Symbols().NameFor(func->name->symbol); + auto name = func->name->symbol.Name(); result.entry_points.push_back({name, func->PipelineStage()}); } } diff --git a/src/tint/writer/glsl/generator_bench.cc b/src/tint/writer/glsl/generator_bench.cc index 5a8e2779bb..f591011518 100644 --- a/src/tint/writer/glsl/generator_bench.cc +++ b/src/tint/writer/glsl/generator_bench.cc @@ -31,7 +31,7 @@ void GenerateGLSL(benchmark::State& state, std::string input_name) { std::vector entry_points; for (auto& fn : program.AST().Functions()) { if (fn->IsEntryPoint()) { - entry_points.emplace_back(program.Symbols().NameFor(fn->name->symbol)); + entry_points.emplace_back(fn->name->symbol.Name()); } } diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index a666eaa4e4..4f46e662c8 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -375,9 +375,8 @@ bool GeneratorImpl::EmitBitcast(utils::StringStream& out, const ast::BitcastExpr auto* dst_type = TypeOf(expr)->UnwrapRef(); if (!dst_type->is_integer_scalar_or_vector() && !dst_type->is_float_scalar_or_vector()) { - diagnostics_.add_error( - diag::System::Writer, - "Unable to do bitcast to type " + dst_type->FriendlyName(builder_.Symbols())); + diagnostics_.add_error(diag::System::Writer, + "Unable to do bitcast to type " + dst_type->FriendlyName()); return false; } @@ -751,7 +750,7 @@ bool GeneratorImpl::EmitFunctionCall(utils::StringStream& out, const auto& args = call->Arguments(); auto* ident = fn->Declaration()->name; - out << builder_.Symbols().NameFor(ident->symbol); + out << ident->symbol.Name(); ScopedParen sp(out); bool first = true; @@ -1880,7 +1879,7 @@ bool GeneratorImpl::EmitExpression(utils::StringStream& out, const ast::Expressi bool GeneratorImpl::EmitIdentifier(utils::StringStream& out, const ast::IdentifierExpression* expr) { - out << builder_.Symbols().NameFor(expr->identifier->symbol); + out << expr->identifier->symbol.Name(); return true; } @@ -1925,7 +1924,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { { auto out = line(); - auto name = builder_.Symbols().NameFor(func->name->symbol); + auto name = func->name->symbol.Name(); if (!EmitType(out, sem->ReturnType(), builtin::AddressSpace::kUndefined, builtin::Access::kReadWrite, "")) { return false; @@ -1959,7 +1958,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { // correctly translate the parameter to a [RW]ByteAddressBuffer for // storage buffers and a uint4[N] for uniform buffers. if (!EmitTypeAndName(out, type, v->AddressSpace(), v->Access(), - builder_.Symbols().NameFor(v->Declaration()->name->symbol))) { + v->Declaration()->name->symbol.Name())) { return false; } } @@ -2039,7 +2038,7 @@ bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable out << ") uniform " << UniqueIdentifier(StructName(str) + "_ubo") << " {"; } EmitStructMembers(current_buffer_, str); - auto name = builder_.Symbols().NameFor(var->name->symbol); + auto name = var->name->symbol.Name(); line() << "} " << name << ";"; line(); @@ -2057,7 +2056,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable line() << "layout(binding = " << bp.binding << ", std430) buffer " << UniqueIdentifier(StructName(str) + "_ssbo") << " {"; EmitStructMembers(current_buffer_, str); - auto name = builder_.Symbols().NameFor(var->name->symbol); + auto name = var->name->symbol.Name(); line() << "} " << name << ";"; line(); @@ -2067,7 +2066,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable* sem) { auto out = line(); - auto name = builder_.Symbols().NameFor(var->name->symbol); + auto name = var->name->symbol.Name(); auto* type = sem->Type()->UnwrapRef(); if (type->Is()) { // GLSL ignores Sampler variables. @@ -2146,7 +2145,7 @@ bool GeneratorImpl::EmitPrivateVariable(const sem::Variable* var) { auto* decl = var->Declaration(); auto out = line(); - auto name = builder_.Symbols().NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); auto* type = var->Type()->UnwrapRef(); if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) { return false; @@ -2173,7 +2172,7 @@ bool GeneratorImpl::EmitWorkgroupVariable(const sem::Variable* var) { out << "shared "; - auto name = builder_.Symbols().NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); auto* type = var->Type()->UnwrapRef(); if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) { return false; @@ -2207,7 +2206,7 @@ bool GeneratorImpl::EmitIOVariable(const sem::GlobalVariable* var) { EmitAttributes(out, var, decl->attributes); EmitInterpolationQualifiers(out, decl->attributes); - auto name = builder_.Symbols().NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); auto* type = var->Type()->UnwrapRef(); if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) { return false; @@ -2315,8 +2314,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { { auto out = line(); if (!EmitTypeAndName(out, func_sem->ReturnType(), builtin::AddressSpace::kUndefined, - builtin::Access::kUndefined, - builder_.Symbols().NameFor(func->name->symbol))) { + builtin::Access::kUndefined, func->name->symbol.Name())) { return false; } out << "("; @@ -2339,7 +2337,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { first = false; if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), - builder_.Symbols().NameFor(var->name->symbol))) { + var->name->symbol.Name())) { return false; } } @@ -2598,8 +2596,8 @@ bool GeneratorImpl::EmitZeroValue(utils::StringStream& out, const type::Type* ty EmitZeroValue(out, arr->ElemType()); } } else { - diagnostics_.add_error(diag::System::Writer, "Invalid type for zero emission: " + - type->FriendlyName(builder_.Symbols())); + diagnostics_.add_error(diag::System::Writer, + "Invalid type for zero emission: " + type->FriendlyName()); return false; } return true; @@ -2804,11 +2802,11 @@ bool GeneratorImpl::EmitMemberAccessor(utils::StringStream& out, sem, [&](const sem::Swizzle*) { // Swizzles output the name directly - out << builder_.Symbols().NameFor(expr->member->symbol); + out << expr->member->symbol.Name(); return true; }, [&](const sem::StructMemberAccess* member_access) { - out << program_->Symbols().NameFor(member_access->Member()->Name()); + out << member_access->Member()->Name().Name(); return true; }, [&](Default) { @@ -3116,7 +3114,7 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) { bool GeneratorImpl::EmitStructMembers(TextBuffer* b, const sem::Struct* str) { ScopedIndent si(b); for (auto* mem : str->Members()) { - auto name = builder_.Symbols().NameFor(mem->Name()); + auto name = mem->Name().Name(); auto* ty = mem->Type(); @@ -3164,8 +3162,7 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) { auto* type = sem->Type()->UnwrapRef(); auto out = line(); - if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), - builder_.Symbols().NameFor(var->name->symbol))) { + if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), var->name->symbol.Name())) { return false; } @@ -3192,7 +3189,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); // TODO(senorblanco): handle const if (!EmitTypeAndName(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, - builder_.Symbols().NameFor(let->name->symbol))) { + let->name->symbol.Name())) { return false; } @@ -3214,7 +3211,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { auto out = line(); out << "const "; if (!EmitTypeAndName(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, - builder_.Symbols().NameFor(var->name->symbol))) { + var->name->symbol.Name())) { return false; } out << " = "; diff --git a/src/tint/writer/hlsl/generator.cc b/src/tint/writer/hlsl/generator.cc index cc3bc91df6..17437bf06c 100644 --- a/src/tint/writer/hlsl/generator.cc +++ b/src/tint/writer/hlsl/generator.cc @@ -51,7 +51,7 @@ Result Generate(const Program* program, const Options& options) { // Collect the list of entry points in the sanitized program. for (auto* func : sanitized_result.program.AST().Functions()) { if (func->IsEntryPoint()) { - auto name = sanitized_result.program.Symbols().NameFor(func->name->symbol); + auto name = func->name->symbol.Name(); result.entry_points.push_back({name, func->PipelineStage()}); } } diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index 5e4ae33f94..b37ebdca28 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -661,8 +661,8 @@ bool GeneratorImpl::EmitBitcast(utils::StringStream& out, const ast::BitcastExpr } if (!type->is_integer_scalar() && !type->is_float_scalar()) { - diagnostics_.add_error(diag::System::Writer, "Unable to do bitcast to type " + - type->FriendlyName(builder_.Symbols())); + diagnostics_.add_error(diag::System::Writer, + "Unable to do bitcast to type " + type->FriendlyName()); return false; } @@ -950,7 +950,7 @@ bool GeneratorImpl::EmitFunctionCall(utils::StringStream& out, } } - out << builder_.Symbols().NameFor(func->Declaration()->name->symbol) << "("; + out << func->Declaration()->name->symbol.Name() << "("; bool first = true; for (auto* arg : call->Arguments()) { @@ -1140,7 +1140,7 @@ bool GeneratorImpl::EmitUniformBufferAccess( utils::StringStream& out, const ast::CallExpression* expr, const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) { - auto const buffer = program_->Symbols().NameFor(intrinsic->Buffer()->identifier->symbol); + auto const buffer = intrinsic->Buffer()->identifier->symbol.Name(); auto* const offset = expr->args[0]; // offset in bytes @@ -1428,7 +1428,7 @@ bool GeneratorImpl::EmitStorageBufferAccess( utils::StringStream& out, const ast::CallExpression* expr, const transform::DecomposeMemoryAccess::Intrinsic* intrinsic) { - auto const buffer = program_->Symbols().NameFor(intrinsic->Buffer()->identifier->symbol); + auto const buffer = intrinsic->Buffer()->identifier->symbol.Name(); auto* const offset = expr->args[0]; auto* const value = expr->args[1]; @@ -1593,10 +1593,10 @@ bool GeneratorImpl::EmitStorageAtomicIntrinsic( const sem::Function* sem_func = builder_.Sem().Get(func); auto* result_ty = sem_func->ReturnType(); - const auto name = builder_.Symbols().NameFor(func->name->symbol); + const auto name = func->name->symbol.Name(); auto& buf = *current_buffer_; - auto const buffer = program_->Symbols().NameFor(intrinsic->Buffer()->identifier->symbol); + auto const buffer = intrinsic->Buffer()->identifier->symbol.Name(); auto rmw = [&](const char* hlsl) -> bool { { @@ -2847,7 +2847,7 @@ bool GeneratorImpl::EmitExpression(utils::StringStream& out, const ast::Expressi bool GeneratorImpl::EmitIdentifier(utils::StringStream& out, const ast::IdentifierExpression* expr) { - out << builder_.Symbols().NameFor(expr->identifier->symbol); + out << expr->identifier->symbol.Name(); return true; } @@ -2903,7 +2903,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { { auto out = line(); - auto name = builder_.Symbols().NameFor(func->name->symbol); + auto name = func->name->symbol.Name(); // If the function returns an array, then we need to declare a typedef for // this. if (sem->ReturnType()->Is()) { @@ -2962,7 +2962,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { // correctly translate the parameter to a [RW]ByteAddressBuffer for // storage buffers and a uint4[N] for uniform buffers. if (!EmitTypeAndName(out, type, address_space, access, - builder_.Symbols().NameFor(v->Declaration()->name->symbol))) { + v->Declaration()->name->symbol.Name())) { return false; } } @@ -3005,7 +3005,7 @@ bool GeneratorImpl::EmitFunctionBodyWithDiscard(const ast::Function* func) { line() << "}"; // Return an unused result that matches the type of the return value - auto name = builder_.Symbols().NameFor(builder_.Symbols().New("unused")); + auto name = builder_.Symbols().New("unused").Name(); { auto out = line(); if (!EmitTypeAndName(out, sem->ReturnType(), builtin::AddressSpace::kUndefined, @@ -3068,7 +3068,7 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) { bool GeneratorImpl::EmitUniformVariable(const ast::Var* var, const sem::Variable* sem) { auto binding_point = sem->As()->BindingPoint(); auto* type = sem->Type()->UnwrapRef(); - auto name = builder_.Symbols().NameFor(var->name->symbol); + auto name = var->name->symbol.Name(); line() << "cbuffer cbuffer_" << name << RegisterAndSpace('b', binding_point) << " {"; { @@ -3089,7 +3089,7 @@ bool GeneratorImpl::EmitStorageVariable(const ast::Var* var, const sem::Variable auto* type = sem->Type()->UnwrapRef(); auto out = line(); if (!EmitTypeAndName(out, type, builtin::AddressSpace::kStorage, sem->Access(), - builder_.Symbols().NameFor(var->name->symbol))) { + var->name->symbol.Name())) { return false; } @@ -3105,7 +3105,7 @@ bool GeneratorImpl::EmitHandleVariable(const ast::Var* var, const sem::Variable* auto* unwrapped_type = sem->Type()->UnwrapRef(); auto out = line(); - auto name = builder_.Symbols().NameFor(var->name->symbol); + auto name = var->name->symbol.Name(); auto* type = sem->Type()->UnwrapRef(); if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), name)) { return false; @@ -3145,7 +3145,7 @@ bool GeneratorImpl::EmitPrivateVariable(const sem::Variable* var) { out << "static "; - auto name = builder_.Symbols().NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); auto* type = var->Type()->UnwrapRef(); if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) { return false; @@ -3172,7 +3172,7 @@ bool GeneratorImpl::EmitWorkgroupVariable(const sem::Variable* var) { out << "groupshared "; - auto name = builder_.Symbols().NameFor(decl->name->symbol); + auto name = decl->name->symbol.Name(); auto* type = var->Type()->UnwrapRef(); if (!EmitTypeAndName(out, type, var->AddressSpace(), var->Access(), name)) { return false; @@ -3276,8 +3276,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { } if (!EmitTypeAndName(out, func_sem->ReturnType(), builtin::AddressSpace::kUndefined, - builtin::Access::kUndefined, - builder_.Symbols().NameFor(func->name->symbol))) { + builtin::Access::kUndefined, func->name->symbol.Name())) { return false; } out << "("; @@ -3300,7 +3299,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { first = false; if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), - builder_.Symbols().NameFor(var->name->symbol))) { + var->name->symbol.Name())) { return false; } } @@ -3594,9 +3593,8 @@ bool GeneratorImpl::EmitValue(utils::StringStream& out, const type::Type* type, builtin::Access::kUndefined, ""); }, [&](Default) { - diagnostics_.add_error( - diag::System::Writer, - "Invalid type for value emission: " + type->FriendlyName(builder_.Symbols())); + diagnostics_.add_error(diag::System::Writer, + "Invalid type for value emission: " + type->FriendlyName()); return false; }); } @@ -3803,11 +3801,11 @@ bool GeneratorImpl::EmitMemberAccessor(utils::StringStream& out, sem, [&](const sem::Swizzle*) { // Swizzles output the name directly - out << builder_.Symbols().NameFor(expr->member->symbol); + out << expr->member->symbol.Name(); return true; }, [&](const sem::StructMemberAccess* member_access) { - out << program_->Symbols().NameFor(member_access->Member()->Name()); + out << member_access->Member()->Name().Name(); return true; }, [&](Default) { @@ -4214,7 +4212,7 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) { { ScopedIndent si(b); for (auto* mem : str->Members()) { - auto mem_name = builder_.Symbols().NameFor(mem->Name()); + auto mem_name = mem->Name().Name(); auto* ty = mem->Type(); auto out = line(b); std::string pre, post; @@ -4331,8 +4329,7 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) { auto* type = sem->Type()->UnwrapRef(); auto out = line(); - if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), - builder_.Symbols().NameFor(var->name->symbol))) { + if (!EmitTypeAndName(out, type, sem->AddressSpace(), sem->Access(), var->name->symbol.Name())) { return false; } @@ -4359,7 +4356,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { auto out = line(); out << "const "; if (!EmitTypeAndName(out, type, builtin::AddressSpace::kUndefined, builtin::Access::kUndefined, - builder_.Symbols().NameFor(let->name->symbol))) { + let->name->symbol.Name())) { return false; } out << " = "; diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index ed459e6ca1..842f6cbb0d 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -368,8 +368,7 @@ bool GeneratorImpl::EmitTypeDecl(const type::Type* ty) { return false; } } else { - diagnostics_.add_error(diag::System::Writer, - "unknown alias type: " + ty->FriendlyName(builder_.Symbols())); + diagnostics_.add_error(diag::System::Writer, "unknown alias type: " + ty->FriendlyName()); return false; } @@ -661,7 +660,7 @@ bool GeneratorImpl::EmitCall(utils::StringStream& out, const ast::CallExpression bool GeneratorImpl::EmitFunctionCall(utils::StringStream& out, const sem::Call* call, const sem::Function* fn) { - out << program_->Symbols().NameFor(fn->Declaration()->name->symbol) << "("; + out << fn->Declaration()->name->symbol.Name() << "("; bool first = true; for (auto* arg : call->Arguments()) { @@ -852,7 +851,7 @@ bool GeneratorImpl::EmitTypeInitializer(utils::StringStream& out, if (auto* struct_ty = type->As()) { // Emit field designators for structures to account for padding members. auto* member = struct_ty->Members()[i]->Declaration(); - auto name = program_->Symbols().NameFor(member->name->symbol); + auto name = member->name->symbol.Name(); out << "." << name << "="; } @@ -1664,9 +1663,8 @@ bool GeneratorImpl::EmitZeroValue(utils::StringStream& out, const type::Type* ty return true; }, [&](Default) { - diagnostics_.add_error( - diag::System::Writer, - "Invalid type for zero emission: " + type->FriendlyName(builder_.Symbols())); + diagnostics_.add_error(diag::System::Writer, + "Invalid type for zero emission: " + type->FriendlyName()); return false; }); } @@ -1782,7 +1780,7 @@ bool GeneratorImpl::EmitConstant(utils::StringStream& out, const constant::Value if (i > 0) { out << ", "; } - out << "." << program_->Symbols().NameFor(members[i]->Name()) << "="; + out << "." << members[i]->Name().Name() << "="; if (!EmitConstant(out, constant->Index(i))) { return false; } @@ -1882,7 +1880,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { if (!EmitType(out, func_sem->ReturnType(), "")) { return false; } - out << " " << program_->Symbols().NameFor(func->name->symbol) << "("; + out << " " << func->name->symbol.Name() << "("; bool first = true; for (auto* v : func->params) { @@ -1893,13 +1891,13 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { auto* type = program_->Sem().Get(v)->Type(); - std::string param_name = "const " + program_->Symbols().NameFor(v->name->symbol); + std::string param_name = "const " + v->name->symbol.Name(); if (!EmitType(out, type, param_name)) { return false; } // Parameter name is output as part of the type for pointers. if (!type->Is()) { - out << " " << program_->Symbols().NameFor(v->name->symbol); + out << " " << v->name->symbol.Name(); } } @@ -1985,7 +1983,7 @@ std::string GeneratorImpl::interpolation_to_attribute( bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { auto* func_sem = builder_.Sem().Get(func); - auto func_name = program_->Symbols().NameFor(func->name->symbol); + auto func_name = func->name->symbol.Name(); // Returns the binding index of a variable, requiring that the group // attribute have a value of zero. @@ -2026,7 +2024,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { auto* type = program_->Sem().Get(param)->Type()->UnwrapRef(); - auto param_name = program_->Symbols().NameFor(param->name->symbol); + auto param_name = param->name->symbol.Name(); if (!EmitType(out, type, param_name)) { return false; } @@ -2136,7 +2134,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { bool GeneratorImpl::EmitIdentifier(utils::StringStream& out, const ast::IdentifierExpression* expr) { - out << program_->Symbols().NameFor(expr->identifier->symbol); + out << expr->identifier->symbol.Name(); return true; } @@ -2398,7 +2396,7 @@ bool GeneratorImpl::EmitMemberAccessor(utils::StringStream& out, if (!write_lhs()) { return false; } - out << "." << program_->Symbols().NameFor(expr->member->symbol); + out << "." << expr->member->symbol.Name(); } return true; }, @@ -2406,7 +2404,7 @@ bool GeneratorImpl::EmitMemberAccessor(utils::StringStream& out, if (!write_lhs()) { return false; } - out << "." << program_->Symbols().NameFor(member_access->Member()->Name()); + out << "." << member_access->Member()->Name().Name(); return true; }, [&](Default) { @@ -2570,7 +2568,7 @@ bool GeneratorImpl::EmitType(utils::StringStream& out, return true; } TINT_ICE(Writer, diagnostics_) - << "unhandled atomic type " << atomic->Type()->FriendlyName(builder_.Symbols()); + << "unhandled atomic type " << atomic->Type()->FriendlyName(); return false; }, [&](const type::Array* arr) { @@ -2751,9 +2749,8 @@ bool GeneratorImpl::EmitType(utils::StringStream& out, return true; }, [&](Default) { - diagnostics_.add_error( - diag::System::Writer, - "unknown type in EmitType: " + type->FriendlyName(builder_.Symbols())); + diagnostics_.add_error(diag::System::Writer, + "unknown type in EmitType: " + type->FriendlyName()); return false; }); } @@ -2827,7 +2824,7 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) { uint32_t msl_offset = 0; for (auto* mem : str->Members()) { auto out = line(b); - auto mem_name = program_->Symbols().NameFor(mem->Name()); + auto mem_name = mem->Name().Name(); auto wgsl_offset = mem->Offset(); if (is_host_shareable) { @@ -2946,8 +2943,7 @@ bool GeneratorImpl::EmitStructType(TextBuffer* b, const sem::Struct* str) { auto size_align = MslPackedTypeSizeAndAlign(ty); if (TINT_UNLIKELY(msl_offset % size_align.align)) { TINT_ICE(Writer, diagnostics_) - << "Misaligned MSL structure member " << ty->FriendlyName(program_->Symbols()) - << " " << mem_name; + << "Misaligned MSL structure member " << ty->FriendlyName() << " " << mem_name; return false; } msl_offset += size_align.size; @@ -3058,7 +3054,7 @@ bool GeneratorImpl::EmitVar(const ast::Var* var) { return false; } - std::string name = program_->Symbols().NameFor(var->name->symbol); + std::string name = var->name->symbol.Name(); if (!EmitType(out, type, name)) { return false; } @@ -3107,7 +3103,7 @@ bool GeneratorImpl::EmitLet(const ast::Let* let) { return false; } - std::string name = "const " + program_->Symbols().NameFor(let->name->symbol); + std::string name = "const " + let->name->symbol.Name(); if (!EmitType(out, type, name)) { return false; } diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index ae14acde0b..0a3009c7ab 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -309,8 +309,7 @@ void Builder::RegisterVariable(const sem::Variable* var, uint32_t id) { uint32_t Builder::LookupVariableID(const sem::Variable* var) { auto it = var_to_id_.find(var); if (it == var_to_id_.end()) { - error_ = "unable to find ID for variable: " + - builder_.Symbols().NameFor(var->Declaration()->name->symbol); + error_ = "unable to find ID for variable: " + var->Declaration()->name->symbol.Name(); return 0; } return it->second; @@ -498,8 +497,7 @@ bool Builder::GenerateEntryPoint(const ast::Function* func, uint32_t id) { return false; } - OperandList operands = {Operand(stage), Operand(id), - Operand(builder_.Symbols().NameFor(func->name->symbol))}; + OperandList operands = {Operand(stage), Operand(id), Operand(func->name->symbol.Name())}; auto* func_sem = builder_.Sem().Get(func); for (const auto* var : func_sem->TransitivelyReferencedGlobals()) { @@ -512,8 +510,8 @@ bool Builder::GenerateEntryPoint(const ast::Function* func, uint32_t id) { uint32_t var_id = LookupVariableID(var); if (var_id == 0) { - error_ = "unable to find ID for global variable: " + - builder_.Symbols().NameFor(var->Declaration()->name->symbol); + error_ = + "unable to find ID for global variable: " + var->Declaration()->name->symbol.Name(); return false; } @@ -601,8 +599,7 @@ bool Builder::GenerateFunction(const ast::Function* func_ast) { auto func_op = result_op(); auto func_id = std::get(func_op); - push_debug(spv::Op::OpName, - {Operand(func_id), Operand(builder_.Symbols().NameFor(func_ast->name->symbol))}); + push_debug(spv::Op::OpName, {Operand(func_id), Operand(func_ast->name->symbol.Name())}); auto ret_id = GenerateTypeIfNeeded(func->ReturnType()); if (ret_id == 0) { @@ -627,8 +624,7 @@ bool Builder::GenerateFunction(const ast::Function* func_ast) { } push_debug(spv::Op::OpName, - {Operand(param_id), - Operand(builder_.Symbols().NameFor(param->Declaration()->name->symbol))}); + {Operand(param_id), Operand(param->Declaration()->name->symbol.Name())}); params.push_back( Instruction{spv::Op::OpFunctionParameter, {Operand(param_type_id), param_op}}); @@ -725,8 +721,7 @@ bool Builder::GenerateFunctionVariable(const ast::Variable* v) { return false; } - push_debug(spv::Op::OpName, - {Operand(var_id), Operand(builder_.Symbols().NameFor(v->name->symbol))}); + push_debug(spv::Op::OpName, {Operand(var_id), Operand(v->name->symbol.Name())}); // TODO(dsinclair) We could detect if the initializer is fully const and emit // an initializer value for the variable instead of doing the OpLoad. @@ -787,8 +782,7 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* v) { return false; } - push_debug(spv::Op::OpName, - {Operand(var_id), Operand(builder_.Symbols().NameFor(v->name->symbol))}); + push_debug(spv::Op::OpName, {Operand(var_id), Operand(v->name->symbol.Name())}); OperandList ops = {Operand(type_id), result, U32Operand(ConvertAddressSpace(sc))}; @@ -1163,8 +1157,7 @@ uint32_t Builder::GenerateIdentifierExpression(const ast::IdentifierExpression* return LookupVariableID(user->Variable()); } } - error_ = "identifier '" + builder_.Symbols().NameFor(expr->identifier->symbol) + - "' does not resolve to a variable"; + error_ = "identifier '" + expr->identifier->symbol.Name() + "' does not resolve to a variable"; return 0; } @@ -1597,9 +1590,9 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const type::Type* to_type, } if (op == spv::Op::OpNop) { - error_ = "unable to determine conversion type for cast, from: " + - from_type->FriendlyName(builder_.Symbols()) + - " to: " + to_type->FriendlyName(builder_.Symbols()); + error_ = + "unable to determine conversion type for cast, from: " + from_type->FriendlyName() + + " to: " + to_type->FriendlyName(); return 0; } @@ -2274,7 +2267,7 @@ uint32_t Builder::GenerateFunctionCall(const sem::Call* call, const sem::Functio auto func_id = func_symbol_to_id_[ident->symbol]; if (func_id == 0) { - error_ = "unable to find called function: " + builder_.Symbols().NameFor(ident->symbol); + error_ = "unable to find called function: " + ident->symbol.Name(); return 0; } ops.push_back(Operand(func_id)); @@ -2399,8 +2392,7 @@ uint32_t Builder::GenerateBuiltinCall(const sem::Call* call, const sem::Builtin* auto* type = TypeOf(accessor->object)->UnwrapRef(); if (!type->Is()) { - error_ = "invalid type (" + type->FriendlyName(builder_.Symbols()) + - ") for runtime array length"; + error_ = "invalid type (" + type->FriendlyName() + ") for runtime array length"; return 0; } // Runtime array must be the last member in the structure @@ -3756,7 +3748,7 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { return true; }, [&](Default) { - error_ = "unable to convert type: " + type->FriendlyName(builder_.Symbols()); + error_ = "unable to convert type: " + type->FriendlyName(); return false; }); @@ -3926,8 +3918,7 @@ bool Builder::GenerateStructType(const sem::Struct* struct_type, const Operand& auto struct_id = std::get(result); if (struct_type->Name().IsValid()) { - push_debug(spv::Op::OpName, - {Operand(struct_id), Operand(builder_.Symbols().NameFor(struct_type->Name()))}); + push_debug(spv::Op::OpName, {Operand(struct_id), Operand(struct_type->Name().Name())}); } OperandList ops; @@ -3954,8 +3945,8 @@ bool Builder::GenerateStructType(const sem::Struct* struct_type, const Operand& uint32_t Builder::GenerateStructMember(uint32_t struct_id, uint32_t idx, const sem::StructMember* member) { - push_debug(spv::Op::OpMemberName, {Operand(struct_id), Operand(idx), - Operand(builder_.Symbols().NameFor(member->Name()))}); + push_debug(spv::Op::OpMemberName, + {Operand(struct_id), Operand(idx), Operand(member->Name().Name())}); // Note: This will generate layout annotations for *all* structs, whether or // not they are used in host-shareable variables. This is officially ok in diff --git a/src/tint/writer/syntax_tree/generator_impl.cc b/src/tint/writer/syntax_tree/generator_impl.cc index 4d5f9be451..be30289dac 100644 --- a/src/tint/writer/syntax_tree/generator_impl.cc +++ b/src/tint/writer/syntax_tree/generator_impl.cc @@ -66,7 +66,7 @@ void GeneratorImpl::Generate() { void GeneratorImpl::EmitDiagnosticControl(const ast::DiagnosticControl& diagnostic) { line() << "DiagnosticControl [severity: " << diagnostic.severity - << ", rule: " << program_->Symbols().NameFor(diagnostic.rule_name->symbol) << "]"; + << ", rule: " << diagnostic.rule_name->symbol.Name() << "]"; } void GeneratorImpl::EmitEnable(const ast::Enable* enable) { @@ -89,7 +89,7 @@ void GeneratorImpl::EmitTypeDecl(const ast::TypeDecl* ty) { { ScopedIndent ai(this); - line() << "name: " << program_->Symbols().NameFor(alias->name->symbol); + line() << "name: " << alias->name->symbol.Name(); line() << "expr: "; { ScopedIndent ex(this); @@ -149,7 +149,7 @@ void GeneratorImpl::EmitMemberAccessor(const ast::MemberAccessorExpression* expr ScopedIndent obj(this); EmitExpression(expr->object); } - line() << "member: " << program_->Symbols().NameFor(expr->member->symbol); + line() << "member: " << expr->member->symbol.Name(); } line() << "]"; } @@ -252,7 +252,7 @@ void GeneratorImpl::EmitIdentifier(const ast::Identifier* ident) { } line() << "]"; } - line() << "name: " << program_->Symbols().NameFor(ident->symbol); + line() << "name: " << ident->symbol.Name(); if (!tmpl_ident->arguments.IsEmpty()) { line() << "args: ["; { @@ -266,7 +266,7 @@ void GeneratorImpl::EmitIdentifier(const ast::Identifier* ident) { } line() << "]"; } else { - line() << program_->Symbols().NameFor(ident->symbol); + line() << ident->symbol.Name(); } } line() << "]"; @@ -285,7 +285,7 @@ void GeneratorImpl::EmitFunction(const ast::Function* func) { } line() << "]"; } - line() << "name: " << program_->Symbols().NameFor(func->name->symbol); + line() << "name: " << func->name->symbol.Name(); if (!func->params.IsEmpty()) { line() << "params: ["; @@ -295,7 +295,7 @@ void GeneratorImpl::EmitFunction(const ast::Function* func) { line() << "param: ["; { ScopedIndent param(this); - line() << "name: " << program_->Symbols().NameFor(v->name->symbol); + line() << "name: " << v->name->symbol.Name(); if (!v->attributes.IsEmpty()) { line() << "attrs: ["; { @@ -372,7 +372,7 @@ void GeneratorImpl::EmitStructType(const ast::Struct* str) { } line() << "]"; } - line() << "name: " << program_->Symbols().NameFor(str->name->symbol); + line() << "name: " << str->name->symbol.Name(); line() << "members: ["; { ScopedIndent membs(this); @@ -390,7 +390,7 @@ void GeneratorImpl::EmitStructType(const ast::Struct* str) { line() << "]"; } - line() << "name: " << program_->Symbols().NameFor(mem->name->symbol); + line() << "name: " << mem->name->symbol.Name(); line() << "type: ["; { ScopedIndent ty(this); @@ -453,7 +453,7 @@ void GeneratorImpl::EmitVariable(const ast::Variable* v) { TINT_ICE(Writer, diagnostics_) << "unhandled variable type " << v->TypeInfo().name; }); - line() << "name: " << program_->Symbols().NameFor(v->name->symbol); + line() << "name: " << v->name->symbol.Name(); if (auto ty = v->type) { line() << "type: ["; diff --git a/src/tint/writer/text_generator.cc b/src/tint/writer/text_generator.cc index 20c5fe764f..8d18b9a8a1 100644 --- a/src/tint/writer/text_generator.cc +++ b/src/tint/writer/text_generator.cc @@ -27,11 +27,11 @@ TextGenerator::TextGenerator(const Program* program) TextGenerator::~TextGenerator() = default; std::string TextGenerator::UniqueIdentifier(const std::string& prefix) { - return builder_.Symbols().NameFor(builder_.Symbols().New(prefix)); + return builder_.Symbols().New(prefix).Name(); } std::string TextGenerator::StructName(const sem::Struct* s) { - auto name = builder_.Symbols().NameFor(s->Name()); + auto name = s->Name().Name(); if (name.size() > 1 && name[0] == '_' && name[1] == '_') { name = utils::GetOrCreate(builtin_struct_names_, s, [&] { return UniqueIdentifier(name.substr(2)); }); diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc index 744bbd2606..2a2f0e733d 100644 --- a/src/tint/writer/wgsl/generator_impl.cc +++ b/src/tint/writer/wgsl/generator_impl.cc @@ -82,8 +82,8 @@ void GeneratorImpl::Generate() { void GeneratorImpl::EmitDiagnosticControl(utils::StringStream& out, const ast::DiagnosticControl& diagnostic) { - out << "diagnostic(" << diagnostic.severity << ", " - << program_->Symbols().NameFor(diagnostic.rule_name->symbol) << ")"; + out << "diagnostic(" << diagnostic.severity << ", " << diagnostic.rule_name->symbol.Name() + << ")"; } void GeneratorImpl::EmitEnable(const ast::Enable* enable) { @@ -103,7 +103,7 @@ void GeneratorImpl::EmitTypeDecl(const ast::TypeDecl* ty) { ty, // [&](const ast::Alias* alias) { auto out = line(); - out << "alias " << program_->Symbols().NameFor(alias->name->symbol) << " = "; + out << "alias " << alias->name->symbol.Name() << " = "; EmitExpression(out, alias->type); out << ";"; }, @@ -160,7 +160,7 @@ void GeneratorImpl::EmitMemberAccessor(utils::StringStream& out, out << ")"; } - out << "." << program_->Symbols().NameFor(expr->member->symbol); + out << "." << expr->member->symbol.Name(); } void GeneratorImpl::EmitBitcast(utils::StringStream& out, const ast::BitcastExpression* expr) { @@ -219,7 +219,7 @@ void GeneratorImpl::EmitIdentifier(utils::StringStream& out, const ast::Identifi EmitAttributes(out, tmpl_ident->attributes); out << " "; } - out << program_->Symbols().NameFor(ident->symbol) << "<"; + out << ident->symbol.Name() << "<"; TINT_DEFER(out << ">"); for (auto* expr : tmpl_ident->arguments) { if (expr != tmpl_ident->arguments.Front()) { @@ -228,7 +228,7 @@ void GeneratorImpl::EmitIdentifier(utils::StringStream& out, const ast::Identifi EmitExpression(out, expr); } } else { - out << program_->Symbols().NameFor(ident->symbol); + out << ident->symbol.Name(); } } @@ -238,7 +238,7 @@ void GeneratorImpl::EmitFunction(const ast::Function* func) { } { auto out = line(); - out << "fn " << program_->Symbols().NameFor(func->name->symbol) << "("; + out << "fn " << func->name->symbol.Name() << "("; bool first = true; for (auto* v : func->params) { @@ -252,7 +252,7 @@ void GeneratorImpl::EmitFunction(const ast::Function* func) { out << " "; } - out << program_->Symbols().NameFor(v->name->symbol) << " : "; + out << v->name->symbol.Name() << " : "; EmitExpression(out, v->type); } @@ -297,7 +297,7 @@ void GeneratorImpl::EmitStructType(const ast::Struct* str) { if (str->attributes.Length()) { EmitAttributes(line(), str->attributes); } - line() << "struct " << program_->Symbols().NameFor(str->name->symbol) << " {"; + line() << "struct " << str->name->symbol.Name() << " {"; auto add_padding = [&](uint32_t size) { line() << "@size(" << size << ")"; @@ -342,7 +342,7 @@ void GeneratorImpl::EmitStructType(const ast::Struct* str) { } auto out = line(); - out << program_->Symbols().NameFor(mem->name->symbol) << " : "; + out << mem->name->symbol.Name() << " : "; EmitExpression(out, mem->type); out << ","; } @@ -377,7 +377,7 @@ void GeneratorImpl::EmitVariable(utils::StringStream& out, const ast::Variable* TINT_ICE(Writer, diagnostics_) << "unhandled variable type " << v->TypeInfo().name; }); - out << " " << program_->Symbols().NameFor(v->name->symbol); + out << " " << v->name->symbol.Name(); if (auto ty = v->type) { out << " : ";