From a838bb718b59648db52662c75758210fd42f2036 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 9 Nov 2021 09:35:00 +0000 Subject: [PATCH] ast: Rename ArrayAccessorExpression to IndexAccessorExpression The object is not always an array. The index can be applied to vectors too. Change-Id: Ifb63d1862090d28cb48d692870e9dd01ddbce5df Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68841 Kokoro: Kokoro Reviewed-by: James Price --- .../mutations/replace_identifier_test.cc | 40 ++++++++--------- src/BUILD.gn | 4 +- src/CMakeLists.txt | 6 +-- ...ession.cc => index_accessor_expression.cc} | 14 +++--- ...pression.h => index_accessor_expression.h} | 18 ++++---- ...t.cc => index_accessor_expression_test.cc} | 33 +++++++------- src/ast/traverse_expressions.h | 22 +++++----- src/ast/traverse_expressions_test.cc | 2 +- src/program_builder.h | 14 +++--- src/reader/spirv/function.cc | 20 ++++----- src/reader/spirv/parser_impl.cc | 2 +- src/reader/wgsl/parser_impl.cc | 2 +- .../wgsl/parser_impl_assignment_stmt_test.cc | 4 +- .../parser_impl_singular_expression_test.cc | 14 +++--- .../wgsl/parser_impl_unary_expression_test.cc | 4 +- src/resolver/array_accessor_test.cc | 44 +++++++++---------- src/resolver/entry_point_validation_test.cc | 29 ++++++------ src/resolver/ptr_ref_validation_test.cc | 2 +- src/resolver/resolver.cc | 10 ++--- src/resolver/resolver.h | 4 +- src/resolver/resolver_test.cc | 2 +- src/sem/variable.cc | 1 - src/transform/decompose_memory_access.cc | 2 +- src/transform/decompose_strided_matrix.cc | 4 +- src/transform/inline_pointer_lets.cc | 2 +- src/transform/pad_array_elements.cc | 2 +- src/transform/renamer_test.cc | 2 +- src/transform/robustness.cc | 6 +-- src/transform/robustness.h | 2 +- src/transform/wrap_arrays_in_structs.cc | 4 +- src/utils/unique_vector.h | 2 +- src/writer/float_to_string.cc | 2 +- src/writer/glsl/generator_impl.cc | 8 ++-- src/writer/glsl/generator_impl.h | 4 +- .../generator_impl_array_accessor_test.cc | 2 +- .../generator_impl_member_accessor_test.cc | 4 +- src/writer/hlsl/generator_impl.cc | 12 ++--- src/writer/hlsl/generator_impl.h | 4 +- .../generator_impl_array_accessor_test.cc | 2 +- .../generator_impl_member_accessor_test.cc | 4 +- src/writer/msl/generator_impl.cc | 14 +++--- src/writer/msl/generator_impl.h | 6 +-- .../msl/generator_impl_array_accessor_test.cc | 4 +- src/writer/spirv/builder.cc | 12 ++--- src/writer/spirv/builder.h | 2 +- .../spirv/builder_accessor_expression_test.cc | 26 +++++------ src/writer/text_generator.h | 2 +- src/writer/wgsl/generator_impl.cc | 12 ++--- src/writer/wgsl/generator_impl.h | 6 +-- .../generator_impl_array_accessor_test.cc | 4 +- test/BUILD.gn | 2 +- 51 files changed, 223 insertions(+), 226 deletions(-) rename src/ast/{array_accessor_expression.cc => index_accessor_expression.cc} (76%) rename src/ast/{array_accessor_expression.h => index_accessor_expression.h} (76%) rename src/ast/{array_accessor_expression_test.cc => index_accessor_expression_test.cc} (60%) diff --git a/fuzzers/tint_ast_fuzzer/mutations/replace_identifier_test.cc b/fuzzers/tint_ast_fuzzer/mutations/replace_identifier_test.cc index d3a125fb89..b52918e608 100644 --- a/fuzzers/tint_ast_fuzzer/mutations/replace_identifier_test.cc +++ b/fuzzers/tint_ast_fuzzer/mutations/replace_identifier_test.cc @@ -487,7 +487,7 @@ fn f() { .Functions()[0] ->body->statements[2] ->As() - ->lhs->As() + ->lhs->As() ->array->As() ->expr->As() ->expr); @@ -537,7 +537,7 @@ fn f(b: ptr>) { .Functions()[0] ->body->statements[2] ->As() - ->lhs->As() + ->lhs->As() ->array->As() ->expr); ASSERT_NE(use_id, 0); @@ -584,7 +584,7 @@ fn f() { .Functions()[0] ->body->statements[1] ->As() - ->lhs->As() + ->lhs->As() ->array->As() ->expr->As() ->expr); @@ -613,15 +613,15 @@ fn f() { NodeIdMap node_id_map(program); - auto use_id = node_id_map.GetId( - program.AST() - .Functions()[0] - ->body->statements[1] - ->As() - ->variable->constructor->As() - ->array->As() - ->expr->As() - ->expr); + auto use_id = + node_id_map.GetId(program.AST() + .Functions()[0] + ->body->statements[1] + ->As() + ->variable->constructor->As() + ->array->As() + ->expr->As() + ->expr); ASSERT_NE(use_id, 0); auto replacement_id = node_id_map.GetId(program.AST().GlobalVariables()[0]); @@ -649,14 +649,14 @@ fn f() { NodeIdMap node_id_map(program); - auto use_id = node_id_map.GetId( - program.AST() - .Functions()[0] - ->body->statements[3] - ->As() - ->variable->constructor->As() - ->array->As() - ->expr); + auto use_id = + node_id_map.GetId(program.AST() + .Functions()[0] + ->body->statements[3] + ->As() + ->variable->constructor->As() + ->array->As() + ->expr); ASSERT_NE(use_id, 0); auto replacement_id = node_id_map.GetId(program.AST() diff --git a/src/BUILD.gn b/src/BUILD.gn index 86fa2baa98..2dc31b8abf 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -179,8 +179,6 @@ libtint_source_set("libtint_core_all_src") { "ast/alias.h", "ast/array.cc", "ast/array.h", - "ast/array_accessor_expression.cc", - "ast/array_accessor_expression.h", "ast/assignment_statement.cc", "ast/assignment_statement.h", "ast/ast_type.cc", # TODO(bclayton) - rename to type.cc @@ -248,6 +246,8 @@ libtint_source_set("libtint_core_all_src") { "ast/identifier_expression.h", "ast/if_statement.cc", "ast/if_statement.h", + "ast/index_accessor_expression.cc", + "ast/index_accessor_expression.h", "ast/int_literal_expression.cc", "ast/int_literal_expression.h", "ast/internal_decoration.cc", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dec0ab010f..50090cdb08 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,8 +42,8 @@ set(TINT_LIB_SRCS ast/access.h ast/alias.cc ast/alias.h - ast/array_accessor_expression.cc - ast/array_accessor_expression.h + ast/index_accessor_expression.cc + ast/index_accessor_expression.h ast/array.cc ast/array.h ast/assignment_statement.cc @@ -581,7 +581,6 @@ endif() if(${TINT_BUILD_TESTS}) set(TINT_TEST_SRCS ast/alias_test.cc - ast/array_accessor_expression_test.cc ast/array_test.cc ast/assignment_statement_test.cc ast/atomic_test.cc @@ -611,6 +610,7 @@ if(${TINT_BUILD_TESTS}) ast/i32_test.cc ast/identifier_expression_test.cc ast/if_statement_test.cc + ast/index_accessor_expression_test.cc ast/int_literal_expression_test.cc ast/interpolate_decoration_test.cc ast/intrinsic_texture_helper_test.cc diff --git a/src/ast/array_accessor_expression.cc b/src/ast/index_accessor_expression.cc similarity index 76% rename from src/ast/array_accessor_expression.cc rename to src/ast/index_accessor_expression.cc index cf2fb7b625..446f782727 100644 --- a/src/ast/array_accessor_expression.cc +++ b/src/ast/index_accessor_expression.cc @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/ast/array_accessor_expression.h" +#include "src/ast/index_accessor_expression.h" #include "src/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::ast::ArrayAccessorExpression); +TINT_INSTANTIATE_TYPEINFO(tint::ast::IndexAccessorExpression); namespace tint { namespace ast { -ArrayAccessorExpression::ArrayAccessorExpression(ProgramID pid, +IndexAccessorExpression::IndexAccessorExpression(ProgramID pid, const Source& src, const Expression* arr, const Expression* idx) @@ -32,18 +32,18 @@ ArrayAccessorExpression::ArrayAccessorExpression(ProgramID pid, TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, idx, program_id); } -ArrayAccessorExpression::ArrayAccessorExpression(ArrayAccessorExpression&&) = +IndexAccessorExpression::IndexAccessorExpression(IndexAccessorExpression&&) = default; -ArrayAccessorExpression::~ArrayAccessorExpression() = default; +IndexAccessorExpression::~IndexAccessorExpression() = default; -const ArrayAccessorExpression* ArrayAccessorExpression::Clone( +const IndexAccessorExpression* IndexAccessorExpression::Clone( CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); auto* arr = ctx->Clone(array); auto* idx = ctx->Clone(index); - return ctx->dst->create(src, arr, idx); + return ctx->dst->create(src, arr, idx); } } // namespace ast diff --git a/src/ast/array_accessor_expression.h b/src/ast/index_accessor_expression.h similarity index 76% rename from src/ast/array_accessor_expression.h rename to src/ast/index_accessor_expression.h index 0cb1e47766..ffe38cbfac 100644 --- a/src/ast/array_accessor_expression.h +++ b/src/ast/index_accessor_expression.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_AST_ARRAY_ACCESSOR_EXPRESSION_H_ -#define SRC_AST_ARRAY_ACCESSOR_EXPRESSION_H_ +#ifndef SRC_AST_INDEX_ACCESSOR_EXPRESSION_H_ +#define SRC_AST_INDEX_ACCESSOR_EXPRESSION_H_ #include "src/ast/expression.h" @@ -21,27 +21,27 @@ namespace tint { namespace ast { /// An array accessor expression -class ArrayAccessorExpression - : public Castable { +class IndexAccessorExpression + : public Castable { public: /// Constructor /// @param program_id the identifier of the program that owns this node /// @param source the array accessor source /// @param arr the array /// @param idx the index expression - ArrayAccessorExpression(ProgramID program_id, + IndexAccessorExpression(ProgramID program_id, const Source& source, const Expression* arr, const Expression* idx); /// Move constructor - ArrayAccessorExpression(ArrayAccessorExpression&&); - ~ArrayAccessorExpression() override; + IndexAccessorExpression(IndexAccessorExpression&&); + ~IndexAccessorExpression() override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. /// @param ctx the clone context /// @return the newly cloned node - const ArrayAccessorExpression* Clone(CloneContext* ctx) const override; + const IndexAccessorExpression* Clone(CloneContext* ctx) const override; /// the array const Expression* const array; @@ -53,4 +53,4 @@ class ArrayAccessorExpression } // namespace ast } // namespace tint -#endif // SRC_AST_ARRAY_ACCESSOR_EXPRESSION_H_ +#endif // SRC_AST_INDEX_ACCESSOR_EXPRESSION_H_ diff --git a/src/ast/array_accessor_expression_test.cc b/src/ast/index_accessor_expression_test.cc similarity index 60% rename from src/ast/array_accessor_expression_test.cc rename to src/ast/index_accessor_expression_test.cc index 93f374aea8..f7fb5040ee 100644 --- a/src/ast/array_accessor_expression_test.cc +++ b/src/ast/index_accessor_expression_test.cc @@ -19,70 +19,69 @@ namespace tint { namespace ast { namespace { -using ArrayAccessorExpressionTest = TestHelper; +using IndexAccessorExpressionTest = TestHelper; -TEST_F(ArrayAccessorExpressionTest, Create) { +TEST_F(IndexAccessorExpressionTest, Create) { auto* ary = Expr("ary"); auto* idx = Expr("idx"); - auto* exp = create(ary, idx); + auto* exp = IndexAccessor(ary, idx); ASSERT_EQ(exp->array, ary); ASSERT_EQ(exp->index, idx); } -TEST_F(ArrayAccessorExpressionTest, CreateWithSource) { +TEST_F(IndexAccessorExpressionTest, CreateWithSource) { auto* ary = Expr("ary"); auto* idx = Expr("idx"); - auto* exp = create(Source{Source::Location{20, 2}}, - ary, idx); + auto* exp = IndexAccessor(Source{{20, 2}}, ary, idx); auto src = exp->source; EXPECT_EQ(src.range.begin.line, 20u); EXPECT_EQ(src.range.begin.column, 2u); } -TEST_F(ArrayAccessorExpressionTest, IsArrayAccessor) { +TEST_F(IndexAccessorExpressionTest, IsIndexAccessor) { auto* ary = Expr("ary"); auto* idx = Expr("idx"); - auto* exp = create(ary, idx); - EXPECT_TRUE(exp->Is()); + auto* exp = IndexAccessor(ary, idx); + EXPECT_TRUE(exp->Is()); } -TEST_F(ArrayAccessorExpressionTest, Assert_Null_Array) { +TEST_F(IndexAccessorExpressionTest, Assert_Null_Array) { EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.create(nullptr, b.Expr("idx")); + b.IndexAccessor(nullptr, b.Expr("idx")); }, "internal compiler error"); } -TEST_F(ArrayAccessorExpressionTest, Assert_Null_Index) { +TEST_F(IndexAccessorExpressionTest, Assert_Null_Index) { EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.create(b.Expr("arr"), nullptr); + b.IndexAccessor(b.Expr("arr"), nullptr); }, "internal compiler error"); } -TEST_F(ArrayAccessorExpressionTest, Assert_DifferentProgramID_Array) { +TEST_F(IndexAccessorExpressionTest, Assert_DifferentProgramID_Array) { EXPECT_FATAL_FAILURE( { ProgramBuilder b1; ProgramBuilder b2; - b1.create(b2.Expr("arr"), b1.Expr("idx")); + b1.IndexAccessor(b2.Expr("arr"), b1.Expr("idx")); }, "internal compiler error"); } -TEST_F(ArrayAccessorExpressionTest, Assert_DifferentProgramID_Index) { +TEST_F(IndexAccessorExpressionTest, Assert_DifferentProgramID_Index) { EXPECT_FATAL_FAILURE( { ProgramBuilder b1; ProgramBuilder b2; - b1.create(b1.Expr("arr"), b2.Expr("idx")); + b1.IndexAccessor(b1.Expr("arr"), b2.Expr("idx")); }, "internal compiler error"); } diff --git a/src/ast/traverse_expressions.h b/src/ast/traverse_expressions.h index c1697750f4..9ee03c53db 100644 --- a/src/ast/traverse_expressions.h +++ b/src/ast/traverse_expressions.h @@ -17,10 +17,10 @@ #include -#include "src/ast/array_accessor_expression.h" #include "src/ast/binary_expression.h" #include "src/ast/bitcast_expression.h" #include "src/ast/call_expression.h" +#include "src/ast/index_accessor_expression.h" #include "src/ast/literal_expression.h" #include "src/ast/member_accessor_expression.h" #include "src/ast/phony_expression.h" @@ -102,28 +102,28 @@ bool TraverseExpressions(const ast::Expression* root, } } - if (auto* array = expr->As()) { - push_pair(array->array, array->index); - } else if (auto* bin_op = expr->As()) { + if (auto* idx = expr->As()) { + push_pair(idx->array, idx->index); + } else if (auto* bin_op = expr->As()) { push_pair(bin_op->lhs, bin_op->rhs); - } else if (auto* bitcast = expr->As()) { + } else if (auto* bitcast = expr->As()) { to_visit.push_back(bitcast->expr); - } else if (auto* call = expr->As()) { + } else if (auto* call = expr->As()) { // TODO(crbug.com/tint/1257): Resolver breaks if we actually include the // function name in the traversal. // to_visit.push_back(call->func); push_list(call->args); - } else if (auto* type_ctor = expr->As()) { + } else if (auto* type_ctor = expr->As()) { push_list(type_ctor->values); - } else if (auto* member = expr->As()) { + } else if (auto* member = expr->As()) { // TODO(crbug.com/tint/1257): Resolver breaks if we actually include the // member name in the traversal. // push_pair(member->structure, member->member); to_visit.push_back(member->structure); - } else if (auto* unary = expr->As()) { + } else if (auto* unary = expr->As()) { to_visit.push_back(unary->expr); - } else if (expr->IsAnyOf()) { + } else if (expr->IsAnyOf()) { // Leaf expression } else { TINT_ICE(AST, diags) << "unhandled expression type: " diff --git a/src/ast/traverse_expressions_test.cc b/src/ast/traverse_expressions_test.cc index d1b2673c0e..ecf94160ea 100644 --- a/src/ast/traverse_expressions_test.cc +++ b/src/ast/traverse_expressions_test.cc @@ -24,7 +24,7 @@ using ::testing::ElementsAre; using TraverseExpressionsTest = TestHelper; -TEST_F(TraverseExpressionsTest, DescendArrayAccessorExpression) { +TEST_F(TraverseExpressionsTest, DescendIndexAccessor) { std::vector e = {Expr(1), Expr(1), Expr(1), Expr(1)}; std::vector i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; diff --git a/src/program_builder.h b/src/program_builder.h index 11f0276638..97ef17fdaf 100644 --- a/src/program_builder.h +++ b/src/program_builder.h @@ -21,7 +21,6 @@ #include "src/ast/alias.h" #include "src/ast/array.h" -#include "src/ast/array_accessor_expression.h" #include "src/ast/assignment_statement.h" #include "src/ast/atomic.h" #include "src/ast/binary_expression.h" @@ -42,6 +41,7 @@ #include "src/ast/for_loop_statement.h" #include "src/ast/i32.h" #include "src/ast/if_statement.h" +#include "src/ast/index_accessor_expression.h" #include "src/ast/interpolate_decoration.h" #include "src/ast/invariant_decoration.h" #include "src/ast/loop_statement.h" @@ -1740,21 +1740,21 @@ class ProgramBuilder { /// @param source the source information /// @param arr the array argument for the array accessor expression /// @param idx the index argument for the array accessor expression - /// @returns a `ast::ArrayAccessorExpression` that indexes `arr` with `idx` + /// @returns a `ast::IndexAccessorExpression` that indexes `arr` with `idx` template - const ast::ArrayAccessorExpression* IndexAccessor(const Source& source, + const ast::IndexAccessorExpression* IndexAccessor(const Source& source, ARR&& arr, IDX&& idx) { - return create( + return create( source, Expr(std::forward(arr)), Expr(std::forward(idx))); } /// @param arr the array argument for the array accessor expression /// @param idx the index argument for the array accessor expression - /// @returns a `ast::ArrayAccessorExpression` that indexes `arr` with `idx` + /// @returns a `ast::IndexAccessorExpression` that indexes `arr` with `idx` template - const ast::ArrayAccessorExpression* IndexAccessor(ARR&& arr, IDX&& idx) { - return create(Expr(std::forward(arr)), + const ast::IndexAccessorExpression* IndexAccessor(ARR&& arr, IDX&& idx) { + return create(Expr(std::forward(arr)), Expr(std::forward(idx))); } diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index 21e51aee3a..8c3166725f 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -3622,7 +3622,7 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { // The private variable is an array whose element type is already of // the same type as the value being stored into it. Form the // reference into the first element. - lhs.expr = create( + lhs.expr = create( Source{}, lhs.expr, parser_impl_.MakeNullValue(ty_.I32())); if (auto* ref = lhs.type->As()) { lhs.type = ref->type; @@ -3672,7 +3672,7 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { Source{}, builder_.Symbols().Register(name)); // SampleMask is an array in Vulkan SPIR-V. Always access the first // element. - id_expr = create( + id_expr = create( Source{}, id_expr, parser_impl_.MakeNullValue(ty_.I32())); auto* loaded_type = parser_impl_.ConvertType(inst.type_id()); @@ -3972,7 +3972,7 @@ TypedExpression FunctionEmitter::MaybeEmitCombinatorialValue( } if (opcode == SpvOpVectorExtractDynamic) { - return {ast_type, create( + return {ast_type, create( Source{}, MakeOperand(inst, 0).expr, MakeOperand(inst, 1).expr)}; } @@ -4362,7 +4362,7 @@ TypedExpression FunctionEmitter::MakeAccessChain( Source{}, current_expr.expr, Swizzle(uint32_t(index_const_val))); } else { // Non-constant index. Use array syntax - next_expr = create( + next_expr = create( Source{}, current_expr.expr, MakeOperand(inst, index).expr); } // All vector components are the same type. @@ -4372,18 +4372,18 @@ TypedExpression FunctionEmitter::MakeAccessChain( break; case SpvOpTypeMatrix: // Use array syntax. - next_expr = create( + next_expr = create( Source{}, current_expr.expr, MakeOperand(inst, index).expr); // All matrix components are the same type. pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0); break; case SpvOpTypeArray: - next_expr = create( + next_expr = create( Source{}, current_expr.expr, MakeOperand(inst, index).expr); pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0); break; case SpvOpTypeRuntimeArray: - next_expr = create( + next_expr = create( Source{}, current_expr.expr, MakeOperand(inst, index).expr); pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0); break; @@ -4543,7 +4543,7 @@ TypedExpression FunctionEmitter::MakeCompositeValueDecomposition( << " is too big. Max handled index is " << kMaxVectorLen - 1; } // Use array syntax. - next_expr = create( + next_expr = create( Source{}, current_expr.expr, make_index(index_val)); // All matrix components are the same type. current_type_id = current_type_inst->GetSingleWordInOperand(0); @@ -4553,7 +4553,7 @@ TypedExpression FunctionEmitter::MakeCompositeValueDecomposition( // The array size could be a spec constant, and so it's not always // statically checkable. Instead, rely on a runtime index clamp // or runtime check to keep this safe. - next_expr = create( + next_expr = create( Source{}, current_expr.expr, make_index(index_val)); current_type_id = current_type_inst->GetSingleWordInOperand(0); break; @@ -5946,7 +5946,7 @@ bool FunctionEmitter::MakeVectorInsertDynamic( AddStatement(builder_.Decl({}, temp_var)); } - auto* lhs = create( + auto* lhs = create( Source{}, builder_.Expr(var_name), index.expr); if (!lhs) { return false; diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index 6ad62fd88d..0ace622378 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -603,7 +603,7 @@ Source ParserImpl::GetSourceForInst( if (where == inst_source_.end()) { return {}; } - return Source{where->second}; + return Source{where->second }; } bool ParserImpl::ParseInternalModuleExceptFunctions() { diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 8e904bf52d..f818f271fa 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -2270,7 +2270,7 @@ Maybe ParserImpl::postfix_expression( return Failure::kErrored; } - return create(source, prefix, + return create(source, prefix, param.value); }); diff --git a/src/reader/wgsl/parser_impl_assignment_stmt_test.cc b/src/reader/wgsl/parser_impl_assignment_stmt_test.cc index 38cdc7c1c3..251b504f5f 100644 --- a/src/reader/wgsl/parser_impl_assignment_stmt_test.cc +++ b/src/reader/wgsl/parser_impl_assignment_stmt_test.cc @@ -63,8 +63,8 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { auto* ident = mem->member->As(); EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("d")); - ASSERT_TRUE(mem->structure->Is()); - auto* ary = mem->structure->As(); + ASSERT_TRUE(mem->structure->Is()); + auto* ary = mem->structure->As(); ASSERT_NE(ary->index, nullptr); ASSERT_TRUE(ary->index->Is()); diff --git a/src/reader/wgsl/parser_impl_singular_expression_test.cc b/src/reader/wgsl/parser_impl_singular_expression_test.cc index 10c0e13a59..02bffc3f85 100644 --- a/src/reader/wgsl/parser_impl_singular_expression_test.cc +++ b/src/reader/wgsl/parser_impl_singular_expression_test.cc @@ -27,8 +27,8 @@ TEST_F(ParserImplTest, SingularExpression_Array_ConstantIndex) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); - ASSERT_TRUE(e->Is()); - auto* ary = e->As(); + ASSERT_TRUE(e->Is()); + auto* ary = e->As(); ASSERT_TRUE(ary->array->Is()); auto* ident = ary->array->As(); @@ -46,8 +46,8 @@ TEST_F(ParserImplTest, SingularExpression_Array_ExpressionIndex) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); - ASSERT_TRUE(e->Is()); - auto* ary = e->As(); + ASSERT_TRUE(e->Is()); + auto* ary = e->As(); ASSERT_TRUE(ary->array->Is()); auto* ident = ary->array->As(); @@ -202,7 +202,7 @@ TEST_F(ParserImplTest, SingularExpression_NonMatch_returnLHS) { ASSERT_TRUE(e->Is()); } -TEST_F(ParserImplTest, SingularExpression_Array_NestedArrayAccessor) { +TEST_F(ParserImplTest, SingularExpression_Array_NestedIndexAccessor) { auto p = parser("a[b[c]]"); auto e = p->singular_expression(); EXPECT_TRUE(e.matched); @@ -210,7 +210,7 @@ TEST_F(ParserImplTest, SingularExpression_Array_NestedArrayAccessor) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); - const auto* outer_accessor = e->As(); + const auto* outer_accessor = e->As(); ASSERT_TRUE(outer_accessor); const auto* outer_array = @@ -219,7 +219,7 @@ TEST_F(ParserImplTest, SingularExpression_Array_NestedArrayAccessor) { EXPECT_EQ(outer_array->symbol, p->builder().Symbols().Get("a")); const auto* inner_accessor = - outer_accessor->index->As(); + outer_accessor->index->As(); ASSERT_TRUE(inner_accessor); const auto* inner_array = diff --git a/src/reader/wgsl/parser_impl_unary_expression_test.cc b/src/reader/wgsl/parser_impl_unary_expression_test.cc index 177a97addb..43132fd9ae 100644 --- a/src/reader/wgsl/parser_impl_unary_expression_test.cc +++ b/src/reader/wgsl/parser_impl_unary_expression_test.cc @@ -28,8 +28,8 @@ TEST_F(ParserImplTest, UnaryExpression_Postix) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); - ASSERT_TRUE(e->Is()); - auto* ary = e->As(); + ASSERT_TRUE(e->Is()); + auto* ary = e->As(); ASSERT_TRUE(ary->array->Is()); auto* ident = ary->array->As(); EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); diff --git a/src/resolver/array_accessor_test.cc b/src/resolver/array_accessor_test.cc index 728c119cc0..9edd6859ca 100644 --- a/src/resolver/array_accessor_test.cc +++ b/src/resolver/array_accessor_test.cc @@ -22,9 +22,9 @@ namespace tint { namespace resolver { namespace { -using ResolverArrayAccessorTest = ResolverTest; +using ResolverIndexAccessorTest = ResolverTest; -TEST_F(ResolverArrayAccessorTest, Matrix_Dynamic_F32) { +TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) { Global("my_var", ty.mat2x3(), ast::StorageClass::kPrivate); auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1.0f)); WrapInFunction(acc); @@ -34,7 +34,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix_Dynamic_F32) { "12:34 error: index must be of type 'i32' or 'u32', found: 'f32'"); } -TEST_F(ResolverArrayAccessorTest, Matrix_Dynamic_Ref) { +TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_Ref) { Global("my_var", ty.mat2x3(), ast::StorageClass::kPrivate); auto* idx = Var("idx", ty.i32(), Construct(ty.i32())); auto* acc = IndexAccessor("my_var", idx); @@ -43,7 +43,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix_Dynamic_Ref) { EXPECT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverArrayAccessorTest, Matrix_BothDimensions_Dynamic_Ref) { +TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions_Dynamic_Ref) { Global("my_var", ty.mat4x4(), ast::StorageClass::kPrivate); auto* idx = Var("idx", ty.u32(), Expr(3u)); auto* idy = Var("idy", ty.u32(), Expr(2u)); @@ -53,7 +53,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix_BothDimensions_Dynamic_Ref) { EXPECT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverArrayAccessorTest, Matrix_Dynamic) { +TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic) { GlobalConst("my_const", ty.mat2x3(), Construct(ty.mat2x3())); auto* idx = Var("idx", ty.i32(), Construct(ty.i32())); auto* acc = IndexAccessor("my_const", Expr(Source{{12, 34}}, idx)); @@ -64,7 +64,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix_Dynamic) { "12:34 error: index must be signed or unsigned integer literal"); } -TEST_F(ResolverArrayAccessorTest, Matrix_XDimension_Dynamic) { +TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) { GlobalConst("my_var", ty.mat4x4(), Construct(ty.mat4x4())); auto* idx = Var("idx", ty.u32(), Expr(3u)); auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx)); @@ -75,7 +75,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix_XDimension_Dynamic) { "12:34 error: index must be signed or unsigned integer literal"); } -TEST_F(ResolverArrayAccessorTest, Matrix_BothDimension_Dynamic) { +TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) { GlobalConst("my_var", ty.mat4x4(), Construct(ty.mat4x4())); auto* idx = Var("idy", ty.u32(), Expr(2u)); auto* acc = @@ -87,7 +87,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix_BothDimension_Dynamic) { "12:34 error: index must be signed or unsigned integer literal"); } -TEST_F(ResolverArrayAccessorTest, Matrix) { +TEST_F(ResolverIndexAccessorTest, Matrix) { Global("my_var", ty.mat2x3(), ast::StorageClass::kPrivate); auto* acc = IndexAccessor("my_var", 2); @@ -103,7 +103,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix) { EXPECT_EQ(ref->StoreType()->As()->Width(), 3u); } -TEST_F(ResolverArrayAccessorTest, Matrix_BothDimensions) { +TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) { Global("my_var", ty.mat2x3(), ast::StorageClass::kPrivate); auto* acc = IndexAccessor(IndexAccessor("my_var", 2), 1); @@ -118,7 +118,7 @@ TEST_F(ResolverArrayAccessorTest, Matrix_BothDimensions) { EXPECT_TRUE(ref->StoreType()->Is()); } -TEST_F(ResolverArrayAccessorTest, Vector_F32) { +TEST_F(ResolverIndexAccessorTest, Vector_F32) { Global("my_var", ty.vec3(), ast::StorageClass::kPrivate); auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2.0f)); WrapInFunction(acc); @@ -128,7 +128,7 @@ TEST_F(ResolverArrayAccessorTest, Vector_F32) { "12:34 error: index must be of type 'i32' or 'u32', found: 'f32'"); } -TEST_F(ResolverArrayAccessorTest, Vector_Dynamic_Ref) { +TEST_F(ResolverIndexAccessorTest, Vector_Dynamic_Ref) { Global("my_var", ty.vec3(), ast::StorageClass::kPrivate); auto* idx = Var("idx", ty.i32(), Expr(2)); auto* acc = IndexAccessor("my_var", idx); @@ -137,7 +137,7 @@ TEST_F(ResolverArrayAccessorTest, Vector_Dynamic_Ref) { EXPECT_TRUE(r()->Resolve()); } -TEST_F(ResolverArrayAccessorTest, Vector_Dynamic) { +TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) { GlobalConst("my_var", ty.vec3(), Construct(ty.vec3())); auto* idx = Var("idx", ty.i32(), Expr(2)); auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx)); @@ -146,7 +146,7 @@ TEST_F(ResolverArrayAccessorTest, Vector_Dynamic) { EXPECT_TRUE(r()->Resolve()); } -TEST_F(ResolverArrayAccessorTest, Vector) { +TEST_F(ResolverIndexAccessorTest, Vector) { Global("my_var", ty.vec3(), ast::StorageClass::kPrivate); auto* acc = IndexAccessor("my_var", 2); @@ -161,7 +161,7 @@ TEST_F(ResolverArrayAccessorTest, Vector) { EXPECT_TRUE(ref->StoreType()->Is()); } -TEST_F(ResolverArrayAccessorTest, Array) { +TEST_F(ResolverIndexAccessorTest, Array) { auto* idx = Expr(2); Global("my_var", ty.array(), ast::StorageClass::kPrivate); @@ -177,7 +177,7 @@ TEST_F(ResolverArrayAccessorTest, Array) { EXPECT_TRUE(ref->StoreType()->Is()); } -TEST_F(ResolverArrayAccessorTest, Alias_Array) { +TEST_F(ResolverIndexAccessorTest, Alias_Array) { auto* aary = Alias("myarrty", ty.array()); Global("my_var", ty.Of(aary), ast::StorageClass::kPrivate); @@ -194,7 +194,7 @@ TEST_F(ResolverArrayAccessorTest, Alias_Array) { EXPECT_TRUE(ref->StoreType()->Is()); } -TEST_F(ResolverArrayAccessorTest, Array_Constant) { +TEST_F(ResolverIndexAccessorTest, Array_Constant) { GlobalConst("my_var", ty.array(), array()); auto* acc = IndexAccessor("my_var", 2); @@ -206,7 +206,7 @@ TEST_F(ResolverArrayAccessorTest, Array_Constant) { EXPECT_TRUE(TypeOf(acc)->Is()) << TypeOf(acc)->type_name(); } -TEST_F(ResolverArrayAccessorTest, Array_Dynamic_I32) { +TEST_F(ResolverIndexAccessorTest, Array_Dynamic_I32) { // let a : array = 0; // var idx : i32 = 0; // var f : f32 = a[idx]; @@ -226,7 +226,7 @@ TEST_F(ResolverArrayAccessorTest, Array_Dynamic_I32) { "12:34 error: index must be signed or unsigned integer literal"); } -TEST_F(ResolverArrayAccessorTest, Array_Literal_F32) { +TEST_F(ResolverIndexAccessorTest, Array_Literal_F32) { // let a : array; // var f : f32 = a[2.0f]; auto* a = Const("a", ty.array(), array()); @@ -243,7 +243,7 @@ TEST_F(ResolverArrayAccessorTest, Array_Literal_F32) { "12:34 error: index must be of type 'i32' or 'u32', found: 'f32'"); } -TEST_F(ResolverArrayAccessorTest, Array_Literal_I32) { +TEST_F(ResolverIndexAccessorTest, Array_Literal_I32) { // let a : array; // var f : f32 = a[2]; auto* a = Const("a", ty.array(), array()); @@ -257,7 +257,7 @@ TEST_F(ResolverArrayAccessorTest, Array_Literal_I32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverArrayAccessorTest, EXpr_Deref_FuncGoodParent) { +TEST_F(ResolverIndexAccessorTest, EXpr_Deref_FuncGoodParent) { // fn func(p: ptr>) -> f32 { // let idx: u32 = u32(); // let x: f32 = (*p)[idx]; @@ -274,7 +274,7 @@ TEST_F(ResolverArrayAccessorTest, EXpr_Deref_FuncGoodParent) { EXPECT_TRUE(r()->Resolve()) << r()->error(); } -TEST_F(ResolverArrayAccessorTest, EXpr_Deref_FuncBadParent) { +TEST_F(ResolverIndexAccessorTest, EXpr_Deref_FuncBadParent) { // fn func(p: ptr>) -> f32 { // let idx: u32 = u32(); // let x: f32 = *p[idx]; @@ -294,7 +294,7 @@ TEST_F(ResolverArrayAccessorTest, EXpr_Deref_FuncBadParent) { "12:34 error: cannot index type 'ptr, read_write>'"); } -TEST_F(ResolverArrayAccessorTest, Exr_Deref_BadParent) { +TEST_F(ResolverIndexAccessorTest, Exr_Deref_BadParent) { // var param: vec4 // let x: f32 = *(¶m)[0]; auto* param = Var("param", ty.vec4()); diff --git a/src/resolver/entry_point_validation_test.cc b/src/resolver/entry_point_validation_test.cc index 0ac3b81a35..0fc620b54c 100644 --- a/src/resolver/entry_point_validation_test.cc +++ b/src/resolver/entry_point_validation_test.cc @@ -166,7 +166,6 @@ TEST_F(ResolverEntryPointValidationTest, 12:34 note: while analysing entry point 'main')"); } - TEST_F(ResolverEntryPointValidationTest, ReturnType_Struct_DuplicateBuiltins) { // struct Output { // [[builtin(frag_depth)]] a : f32; @@ -354,20 +353,20 @@ constexpr Params ParamsFor(bool is_valid) { using TypeValidationTest = resolver::ResolverTestWithParam; static constexpr Params cases[] = { - ParamsFor(true), // - ParamsFor(true), // - ParamsFor(true), // - ParamsFor(false), // - ParamsFor>(true), // - ParamsFor>(true), // - ParamsFor>(true), // - ParamsFor>(false), // - ParamsFor>(false), // - ParamsFor>(false), // - ParamsFor>(true), // - ParamsFor>(true), // - ParamsFor>(true), // - ParamsFor>(false), // + ParamsFor(true), // + ParamsFor(true), // + ParamsFor(true), // + ParamsFor(false), // + ParamsFor>(true), // + ParamsFor>(true), // + ParamsFor>(true), // + ParamsFor>(false), // + ParamsFor>(false), // + ParamsFor>(false), // + ParamsFor>(true), // + ParamsFor>(true), // + ParamsFor>(true), // + ParamsFor>(false), // }; TEST_P(TypeValidationTest, BareInputs) { diff --git a/src/resolver/ptr_ref_validation_test.cc b/src/resolver/ptr_ref_validation_test.cc index 87886bb8fa..57aea322be 100644 --- a/src/resolver/ptr_ref_validation_test.cc +++ b/src/resolver/ptr_ref_validation_test.cc @@ -80,7 +80,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_MemberAccessor) { "12:34 error: cannot take the address of a vector component"); } -TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_ArrayAccessor) { +TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_IndexAccessor) { // var v : vec4; // &v[2] auto* v = Var("v", ty.vec4()); diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 9dea45fe70..69433543d2 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -2354,8 +2354,8 @@ sem::Expression* Resolver::Expression(const ast::Expression* root) { for (auto* expr : utils::Reverse(sorted)) { sem::Expression* sem_expr = nullptr; - if (auto* array = expr->As()) { - sem_expr = ArrayAccessor(array); + if (auto* array = expr->As()) { + sem_expr = IndexAccessor(array); } else if (auto* bin_op = expr->As()) { sem_expr = Binary(bin_op); } else if (auto* bitcast = expr->As()) { @@ -2394,8 +2394,8 @@ sem::Expression* Resolver::Expression(const ast::Expression* root) { return nullptr; } -sem::Expression* Resolver::ArrayAccessor( - const ast::ArrayAccessorExpression* expr) { +sem::Expression* Resolver::IndexAccessor( + const ast::IndexAccessorExpression* expr) { auto* idx = expr->index; auto* parent_raw_ty = TypeOf(expr->array); auto* parent_ty = parent_raw_ty->UnwrapRef(); @@ -3455,7 +3455,7 @@ sem::Expression* Resolver::UnaryOp(const ast::UnaryOpExpression* unary) { return nullptr; } - auto* array = unary->expr->As(); + auto* array = unary->expr->As(); auto* member = unary->expr->As(); if ((array && TypeOf(array->array)->UnwrapRef()->Is()) || (member && diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h index b75532eba4..c19dfeec59 100644 --- a/src/resolver/resolver.h +++ b/src/resolver/resolver.h @@ -37,7 +37,7 @@ namespace tint { // Forward declarations namespace ast { -class ArrayAccessorExpression; +class IndexAccessorExpression; class BinaryExpression; class BitcastExpression; class CallExpression; @@ -167,7 +167,7 @@ class Resolver { // Expression resolving methods // Returns the semantic node pointer on success, nullptr on failure. - sem::Expression* ArrayAccessor(const ast::ArrayAccessorExpression*); + sem::Expression* IndexAccessor(const ast::IndexAccessorExpression*); sem::Expression* Binary(const ast::BinaryExpression*); sem::Expression* Bitcast(const ast::BitcastExpression*); sem::Expression* Call(const ast::CallExpression*); diff --git a/src/resolver/resolver_test.cc b/src/resolver/resolver_test.cc index cf1a91f42c..45afc802b2 100644 --- a/src/resolver/resolver_test.cc +++ b/src/resolver/resolver_test.cc @@ -667,7 +667,7 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) { EXPECT_EQ(VarOf(my_var_a)->Declaration(), var); } -TEST_F(ResolverTest, ArrayAccessor_Dynamic_Ref_F32) { +TEST_F(ResolverTest, IndexAccessor_Dynamic_Ref_F32) { // var a : array = 0; // var idx : f32 = f32(); // var f : f32 = a[idx]; diff --git a/src/sem/variable.cc b/src/sem/variable.cc index 5eac5b839a..dd242be8ae 100644 --- a/src/sem/variable.cc +++ b/src/sem/variable.cc @@ -64,7 +64,6 @@ GlobalVariable::GlobalVariable(const ast::Variable* declaration, binding_point_(binding_point), is_pipeline_constant_(false) {} - GlobalVariable::~GlobalVariable() = default; Parameter::Parameter(const ast::Variable* declaration, diff --git a/src/transform/decompose_memory_access.cc b/src/transform/decompose_memory_access.cc index 32ff132e97..806948922a 100644 --- a/src/transform/decompose_memory_access.cc +++ b/src/transform/decompose_memory_access.cc @@ -851,7 +851,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) { continue; } - if (auto* accessor = node->As()) { + if (auto* accessor = node->As()) { if (auto access = state.TakeAccess(accessor->array)) { // X[Y] if (auto* arr = access.type->As()) { diff --git a/src/transform/decompose_strided_matrix.cc b/src/transform/decompose_strided_matrix.cc index 2d21a5bb28..3142b25365 100644 --- a/src/transform/decompose_strided_matrix.cc +++ b/src/transform/decompose_strided_matrix.cc @@ -144,8 +144,8 @@ void DecomposeStridedMatrix::Run(CloneContext& ctx, const DataMap&, DataMap&) { // preserve these without calling conversion functions. // Example: // ssbo.mat[2] -> ssbo.mat[2] - ctx.ReplaceAll([&](const ast::ArrayAccessorExpression* expr) - -> const ast::ArrayAccessorExpression* { + ctx.ReplaceAll([&](const ast::IndexAccessorExpression* expr) + -> const ast::IndexAccessorExpression* { if (auto* access = ctx.src->Sem().Get(expr->array)) { auto it = decomposed.find(access->Member()->Declaration()); diff --git a/src/transform/inline_pointer_lets.cc b/src/transform/inline_pointer_lets.cc index ea61615da0..aa97b926b0 100644 --- a/src/transform/inline_pointer_lets.cc +++ b/src/transform/inline_pointer_lets.cc @@ -43,7 +43,7 @@ template void CollectSavedArrayIndices(const Program* program, const ast::Expression* expr, F&& cb) { - if (auto* a = expr->As()) { + if (auto* a = expr->As()) { CollectSavedArrayIndices(program, a->array, cb); if (!a->index->Is()) { diff --git a/src/transform/pad_array_elements.cc b/src/transform/pad_array_elements.cc index 58f6836313..254ae6d792 100644 --- a/src/transform/pad_array_elements.cc +++ b/src/transform/pad_array_elements.cc @@ -115,7 +115,7 @@ void PadArrayElements::Run(CloneContext& ctx, const DataMap&, DataMap&) { }); // Fix up array accessors so `a[1]` becomes `a[1].el` - ctx.ReplaceAll([&](const ast::ArrayAccessorExpression* accessor) + ctx.ReplaceAll([&](const ast::IndexAccessorExpression* accessor) -> const ast::Expression* { if (auto* array = tint::As( sem.Get(accessor->array)->Type()->UnwrapRef())) { diff --git a/src/transform/renamer_test.cc b/src/transform/renamer_test.cc index 457f59e265..d32c9f3c5c 100644 --- a/src/transform/renamer_test.cc +++ b/src/transform/renamer_test.cc @@ -1300,7 +1300,7 @@ INSTANTIATE_TEST_SUITE_P( "long2", "long3", "long4", - "main", // No functions called main + "main", // No functions called main "matrix", "metal", // The namespace "packed_bool2", diff --git a/src/transform/robustness.cc b/src/transform/robustness.cc index b4465a3afa..4578e34099 100644 --- a/src/transform/robustness.cc +++ b/src/transform/robustness.cc @@ -41,7 +41,7 @@ struct Robustness::State { /// Applies the transformation state to `ctx`. void Transform() { - ctx.ReplaceAll([&](const ast::ArrayAccessorExpression* expr) { + ctx.ReplaceAll([&](const ast::IndexAccessorExpression* expr) { return Transform(expr); }); ctx.ReplaceAll( @@ -52,8 +52,8 @@ struct Robustness::State { /// @param expr the array, vector or matrix index expression /// @return the clamped replacement expression, or nullptr if `expr` should be /// cloned without changes. - const ast::ArrayAccessorExpression* Transform( - const ast::ArrayAccessorExpression* expr) { + const ast::IndexAccessorExpression* Transform( + const ast::IndexAccessorExpression* expr) { auto* ret_type = ctx.src->Sem().Get(expr->array)->Type(); auto* ref = ret_type->As(); diff --git a/src/transform/robustness.h b/src/transform/robustness.h index 1333e5c8e2..0447340009 100644 --- a/src/transform/robustness.h +++ b/src/transform/robustness.h @@ -22,7 +22,7 @@ // Forward declarations namespace tint { namespace ast { -class ArrayAccessorExpression; +class IndexAccessorExpression; class CallExpression; } // namespace ast } // namespace tint diff --git a/src/transform/wrap_arrays_in_structs.cc b/src/transform/wrap_arrays_in_structs.cc index 782004f8d4..181c737387 100644 --- a/src/transform/wrap_arrays_in_structs.cc +++ b/src/transform/wrap_arrays_in_structs.cc @@ -57,8 +57,8 @@ void WrapArraysInStructs::Run(CloneContext& ctx, const DataMap&, DataMap&) { }); // Fix up array accessors so `a[1]` becomes `a.arr[1]` - ctx.ReplaceAll([&](const ast::ArrayAccessorExpression* accessor) - -> const ast::ArrayAccessorExpression* { + ctx.ReplaceAll([&](const ast::IndexAccessorExpression* accessor) + -> const ast::IndexAccessorExpression* { if (auto* array = ::tint::As( sem.Get(accessor->array)->Type()->UnwrapRef())) { if (wrapper(array)) { diff --git a/src/utils/unique_vector.h b/src/utils/unique_vector.h index 8d92bea40a..c0a8e3f9c7 100644 --- a/src/utils/unique_vector.h +++ b/src/utils/unique_vector.h @@ -72,7 +72,7 @@ struct UniqueVector { ConstIterator end() const { return vector.end(); } /// @returns a const reference to the internal vector - operator const std::vector &() const { return vector; } + operator const std::vector&() const { return vector; } private: std::vector vector; diff --git a/src/writer/float_to_string.cc b/src/writer/float_to_string.cc index 900599dd09..d140b348be 100644 --- a/src/writer/float_to_string.cc +++ b/src/writer/float_to_string.cc @@ -16,10 +16,10 @@ #include #include +#include #include #include #include -#include #include "src/debug.h" diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc index 16cbf30d95..1d0213a19e 100644 --- a/src/writer/glsl/generator_impl.cc +++ b/src/writer/glsl/generator_impl.cc @@ -164,9 +164,9 @@ bool GeneratorImpl::Generate() { return true; } -bool GeneratorImpl::EmitArrayAccessor( +bool GeneratorImpl::EmitIndexAccessor( std::ostream& out, - const ast::ArrayAccessorExpression* expr) { + const ast::IndexAccessorExpression* expr) { if (!EmitExpression(out, expr->array)) { return false; } @@ -1459,8 +1459,8 @@ bool GeneratorImpl::EmitDiscard(const ast::DiscardStatement*) { bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* expr) { - if (auto* a = expr->As()) { - return EmitArrayAccessor(out, a); + if (auto* a = expr->As()) { + return EmitIndexAccessor(out, a); } if (auto* b = expr->As()) { return EmitBinary(out, b); diff --git a/src/writer/glsl/generator_impl.h b/src/writer/glsl/generator_impl.h index 9258cae6e3..c478d3b32d 100644 --- a/src/writer/glsl/generator_impl.h +++ b/src/writer/glsl/generator_impl.h @@ -63,8 +63,8 @@ class GeneratorImpl : public TextGenerator { /// @param out the output of the expression stream /// @param expr the expression to emit /// @returns true if the array accessor was emitted - bool EmitArrayAccessor(std::ostream& out, - const ast::ArrayAccessorExpression* expr); + bool EmitIndexAccessor(std::ostream& out, + const ast::IndexAccessorExpression* expr); /// Handles an assignment statement /// @param stmt the statement to emit /// @returns true if the statement was emitted successfully diff --git a/src/writer/glsl/generator_impl_array_accessor_test.cc b/src/writer/glsl/generator_impl_array_accessor_test.cc index 1ba07b6e3c..7460f7628a 100644 --- a/src/writer/glsl/generator_impl_array_accessor_test.cc +++ b/src/writer/glsl/generator_impl_array_accessor_test.cc @@ -21,7 +21,7 @@ namespace { using GlslGeneratorImplTest_Expression = TestHelper; -TEST_F(GlslGeneratorImplTest_Expression, ArrayAccessor) { +TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) { Global("ary", ty.array(), ast::StorageClass::kPrivate); auto* expr = IndexAccessor("ary", 5); WrapInFunction(expr); diff --git a/src/writer/glsl/generator_impl_member_accessor_test.cc b/src/writer/glsl/generator_impl_member_accessor_test.cc index cf5b9b7f6f..d1df07acd3 100644 --- a/src/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/writer/glsl/generator_impl_member_accessor_test.cc @@ -362,7 +362,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_MemberAccessor, - EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray) { + EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray) { // struct Data { // a : [[stride(4)]] array; // }; @@ -406,7 +406,7 @@ void main() { } TEST_F(GlslGeneratorImplTest_MemberAccessor, - EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) { + EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) { // struct Data { // a : [[stride(4)]] array; // }; diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index f01ce15c25..8a2d114058 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -291,7 +291,7 @@ bool GeneratorImpl::EmitDynamicVectorAssignment( return false; } - auto* ast_access_expr = stmt->lhs->As(); + auto* ast_access_expr = stmt->lhs->As(); auto out = line(); out << name << "("; @@ -311,9 +311,9 @@ bool GeneratorImpl::EmitDynamicVectorAssignment( return true; } -bool GeneratorImpl::EmitArrayAccessor( +bool GeneratorImpl::EmitIndexAccessor( std::ostream& out, - const ast::ArrayAccessorExpression* expr) { + const ast::IndexAccessorExpression* expr) { if (!EmitExpression(out, expr->array)) { return false; } @@ -354,7 +354,7 @@ bool GeneratorImpl::EmitBitcast(std::ostream& out, } bool GeneratorImpl::EmitAssign(const ast::AssignmentStatement* stmt) { - if (auto* idx = stmt->lhs->As()) { + if (auto* idx = stmt->lhs->As()) { if (auto* vec = TypeOf(idx->array)->UnwrapRef()->As()) { auto* rhs_sem = builder_.Sem().Get(idx->index); if (!rhs_sem->ConstantValue().IsValid()) { @@ -2191,8 +2191,8 @@ bool GeneratorImpl::EmitDiscard(const ast::DiscardStatement*) { bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* expr) { - if (auto* a = expr->As()) { - return EmitArrayAccessor(out, a); + if (auto* a = expr->As()) { + return EmitIndexAccessor(out, a); } if (auto* b = expr->As()) { return EmitBinary(out, b); diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h index 67a4da51a3..1aadf4aac1 100644 --- a/src/writer/hlsl/generator_impl.h +++ b/src/writer/hlsl/generator_impl.h @@ -79,8 +79,8 @@ class GeneratorImpl : public TextGenerator { /// @param out the output of the expression stream /// @param expr the expression to emit /// @returns true if the array accessor was emitted - bool EmitArrayAccessor(std::ostream& out, - const ast::ArrayAccessorExpression* expr); + bool EmitIndexAccessor(std::ostream& out, + const ast::IndexAccessorExpression* expr); /// Handles an assignment statement /// @param stmt the statement to emit /// @returns true if the statement was emitted successfully diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc index b2fb021117..00c75e4487 100644 --- a/src/writer/hlsl/generator_impl_array_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc @@ -21,7 +21,7 @@ namespace { using HlslGeneratorImplTest_Expression = TestHelper; -TEST_F(HlslGeneratorImplTest_Expression, ArrayAccessor) { +TEST_F(HlslGeneratorImplTest_Expression, IndexAccessor) { Global("ary", ty.array(), ast::StorageClass::kPrivate); auto* expr = IndexAccessor("ary", 5); WrapInFunction(expr); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index ccefe547e2..195a16022f 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -391,7 +391,7 @@ void main() { } TEST_F(HlslGeneratorImplTest_MemberAccessor, - EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray) { + EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray) { // struct Data { // a : [[stride(4)]] array; // }; @@ -423,7 +423,7 @@ void main() { } TEST_F(HlslGeneratorImplTest_MemberAccessor, - EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) { + EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) { // struct Data { // a : [[stride(4)]] array; // }; diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index eccfa3abd2..f733b2707e 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -238,12 +238,12 @@ bool GeneratorImpl::EmitTypeDecl(const sem::Type* ty) { return true; } -bool GeneratorImpl::EmitArrayAccessor( +bool GeneratorImpl::EmitIndexAccessor( std::ostream& out, - const ast::ArrayAccessorExpression* expr) { + const ast::IndexAccessorExpression* expr) { bool paren_lhs = !expr->array - ->IsAnyOfIsAnyOf(); @@ -763,7 +763,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, auto texture_expr = [&]() { bool paren_lhs = !texture - ->IsAnyOfIsAnyOf(); if (paren_lhs) { @@ -1418,8 +1418,8 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, const ast::Literal* lit) { bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* expr) { - if (auto* a = expr->As()) { - return EmitArrayAccessor(out, a); + if (auto* a = expr->As()) { + return EmitIndexAccessor(out, a); } if (auto* b = expr->As()) { return EmitBinary(out, b); @@ -1905,7 +1905,7 @@ bool GeneratorImpl::EmitMemberAccessor( auto write_lhs = [&] { bool paren_lhs = !expr->structure - ->IsAnyOfIsAnyOf(); if (paren_lhs) { diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h index 5c593260f9..557c9414f7 100644 --- a/src/writer/msl/generator_impl.h +++ b/src/writer/msl/generator_impl.h @@ -19,7 +19,6 @@ #include #include -#include "src/ast/array_accessor_expression.h" #include "src/ast/assignment_statement.h" #include "src/ast/binary_expression.h" #include "src/ast/bitcast_expression.h" @@ -28,6 +27,7 @@ #include "src/ast/discard_statement.h" #include "src/ast/expression.h" #include "src/ast/if_statement.h" +#include "src/ast/index_accessor_expression.h" #include "src/ast/interpolate_decoration.h" #include "src/ast/loop_statement.h" #include "src/ast/member_accessor_expression.h" @@ -99,8 +99,8 @@ class GeneratorImpl : public TextGenerator { /// @param out the output of the expression stream /// @param expr the expression to emit /// @returns true if the array accessor was emitted - bool EmitArrayAccessor(std::ostream& out, - const ast::ArrayAccessorExpression* expr); + bool EmitIndexAccessor(std::ostream& out, + const ast::IndexAccessorExpression* expr); /// Handles an assignment statement /// @param stmt the statement to emit /// @returns true if the statement was emitted successfully diff --git a/src/writer/msl/generator_impl_array_accessor_test.cc b/src/writer/msl/generator_impl_array_accessor_test.cc index dc2f0dcccc..3dd881f93b 100644 --- a/src/writer/msl/generator_impl_array_accessor_test.cc +++ b/src/writer/msl/generator_impl_array_accessor_test.cc @@ -21,7 +21,7 @@ namespace { using MslGeneratorImplTest = TestHelper; -TEST_F(MslGeneratorImplTest, ArrayAccessor) { +TEST_F(MslGeneratorImplTest, IndexAccessor) { auto* ary = Var("ary", ty.array()); auto* expr = IndexAccessor("ary", 5); WrapInFunction(ary, expr); @@ -33,7 +33,7 @@ TEST_F(MslGeneratorImplTest, ArrayAccessor) { EXPECT_EQ(out.str(), "ary[5]"); } -TEST_F(MslGeneratorImplTest, ArrayAccessor_OfDref) { +TEST_F(MslGeneratorImplTest, IndexAccessor_OfDref) { Global("ary", ty.array(), ast::StorageClass::kPrivate); auto* p = Const("p", nullptr, AddressOf("ary")); diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index a56e636d59..75d4d0d770 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -565,7 +565,7 @@ bool Builder::GenerateExecutionModes(const ast::Function* func, uint32_t id) { } uint32_t Builder::GenerateExpression(const ast::Expression* expr) { - if (auto* a = expr->As()) { + if (auto* a = expr->As()) { return GenerateAccessorExpression(a); } if (auto* b = expr->As()) { @@ -900,7 +900,7 @@ bool Builder::GenerateGlobalVariable(const ast::Variable* var) { return true; } -bool Builder::GenerateArrayAccessor(const ast::ArrayAccessorExpression* expr, +bool Builder::GenerateIndexAccessor(const ast::IndexAccessorExpression* expr, AccessorInfo* info) { auto idx_id = GenerateExpression(expr->index); if (idx_id == 0) { @@ -1089,7 +1089,7 @@ bool Builder::GenerateMemberAccessor(const ast::MemberAccessorExpression* expr, } uint32_t Builder::GenerateAccessorExpression(const ast::Expression* expr) { - if (!expr->IsAnyOfIsAnyOf()) { TINT_ICE(Writer, builder_.Diagnostics()) << "expression is not an accessor"; return 0; @@ -1101,7 +1101,7 @@ uint32_t Builder::GenerateAccessorExpression(const ast::Expression* expr) { std::vector accessors; const ast::Expression* source = expr; while (true) { - if (auto* array = source->As()) { + if (auto* array = source->As()) { accessors.insert(accessors.begin(), source); source = array->array; } else if (auto* member = source->As()) { @@ -1120,8 +1120,8 @@ uint32_t Builder::GenerateAccessorExpression(const ast::Expression* expr) { info.source_type = TypeOf(source); for (auto* accessor : accessors) { - if (auto* array = accessor->As()) { - if (!GenerateArrayAccessor(array, &info)) { + if (auto* array = accessor->As()) { + if (!GenerateIndexAccessor(array, &info)) { return 0; } } else if (auto* member = accessor->As()) { diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h index 4ceefa2df9..a93e577ce2 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -311,7 +311,7 @@ class Builder { /// @param expr the accessor to generate /// @param info the current accessor information /// @returns true if the accessor was generated successfully - bool GenerateArrayAccessor(const ast::ArrayAccessorExpression* expr, + bool GenerateIndexAccessor(const ast::IndexAccessorExpression* expr, AccessorInfo* info); /// Generates a member accessor /// @param expr the accessor to generate diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index 266ed49bf1..2e154fb521 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -22,7 +22,7 @@ namespace { using BuilderTest = TestHelper; -TEST_F(BuilderTest, ArrayAccessor_VectorRef_Literal) { +TEST_F(BuilderTest, IndexAccessor_VectorRef_Literal) { // var ary : vec3; // ary[1] -> ref @@ -57,7 +57,7 @@ TEST_F(BuilderTest, ArrayAccessor_VectorRef_Literal) { )"); } -TEST_F(BuilderTest, ArrayAccessor_VectorRef_Dynamic) { +TEST_F(BuilderTest, IndexAccessor_VectorRef_Dynamic) { // var ary : vec3; // var idx : i32; // ary[idx] -> ref @@ -98,7 +98,7 @@ TEST_F(BuilderTest, ArrayAccessor_VectorRef_Dynamic) { )"); } -TEST_F(BuilderTest, ArrayAccessor_VectorRef_Dynamic2) { +TEST_F(BuilderTest, IndexAccessor_VectorRef_Dynamic2) { // var ary : vec3; // ary[1 + 2] -> ref @@ -134,7 +134,7 @@ TEST_F(BuilderTest, ArrayAccessor_VectorRef_Dynamic2) { )"); } -TEST_F(BuilderTest, ArrayAccessor_ArrayRef_MultiLevel) { +TEST_F(BuilderTest, IndexAccessor_ArrayRef_MultiLevel) { auto* ary4 = ty.array(ty.vec3(), 4); // var ary : array, 4> @@ -172,7 +172,7 @@ TEST_F(BuilderTest, ArrayAccessor_ArrayRef_MultiLevel) { )"); } -TEST_F(BuilderTest, ArrayAccessor_ArrayRef_ArrayWithSwizzle) { +TEST_F(BuilderTest, IndexAccessor_ArrayRef_ArrayWithSwizzle) { auto* ary4 = ty.array(ty.vec3(), 4); // var a : array, 4>; @@ -682,7 +682,7 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { )"); } -TEST_F(BuilderTest, ArrayAccessor_Mixed_ArrayAndMember) { +TEST_F(BuilderTest, IndexAccessor_Mixed_ArrayAndMember) { // type C = struct { // baz : vec3 // } @@ -749,7 +749,7 @@ TEST_F(BuilderTest, ArrayAccessor_Mixed_ArrayAndMember) { )"); } -TEST_F(BuilderTest, ArrayAccessor_Of_Vec) { +TEST_F(BuilderTest, IndexAccessor_Of_Vec) { // let pos : array, 3> = array, 3>( // vec2(0.0, 0.5), // vec2(-0.5, -0.5), @@ -792,7 +792,7 @@ TEST_F(BuilderTest, ArrayAccessor_Of_Vec) { Validate(b); } -TEST_F(BuilderTest, ArrayAccessor_Of_Array_Of_f32) { +TEST_F(BuilderTest, IndexAccessor_Of_Array_Of_f32) { // let pos : array, 3> = array, 3>( // array(0.0, 0.5), // array(-0.5, -0.5), @@ -837,7 +837,7 @@ TEST_F(BuilderTest, ArrayAccessor_Of_Array_Of_f32) { Validate(b); } -TEST_F(BuilderTest, ArrayAccessor_Vec_Literal) { +TEST_F(BuilderTest, IndexAccessor_Vec_Literal) { // let pos : vec2 = vec2(0.0, 0.5); // pos[1] @@ -866,7 +866,7 @@ TEST_F(BuilderTest, ArrayAccessor_Vec_Literal) { )"); } -TEST_F(BuilderTest, ArrayAccessor_Vec_Dynamic) { +TEST_F(BuilderTest, IndexAccessor_Vec_Dynamic) { // let pos : vec2 = vec2(0.0, 0.5); // idx : i32 // pos[idx] @@ -902,7 +902,7 @@ TEST_F(BuilderTest, ArrayAccessor_Vec_Dynamic) { )"); } -TEST_F(BuilderTest, ArrayAccessor_Array_Literal) { +TEST_F(BuilderTest, IndexAccessor_Array_Literal) { // let a : array; // a[2] @@ -936,7 +936,7 @@ TEST_F(BuilderTest, ArrayAccessor_Array_Literal) { Validate(b); } -TEST_F(BuilderTest, ArrayAccessor_Array_Dynamic) { +TEST_F(BuilderTest, IndexAccessor_Array_Dynamic) { // var a : array; // idx : i32 // a[idx] @@ -984,7 +984,7 @@ TEST_F(BuilderTest, ArrayAccessor_Array_Dynamic) { Validate(b); } -TEST_F(BuilderTest, ArrayAccessor_Matrix_Dynamic) { +TEST_F(BuilderTest, IndexAccessor_Matrix_Dynamic) { // var a : mat2x2(vec2(1., 2.), vec2(3., 4.)); // idx : i32 // a[idx] diff --git a/src/writer/text_generator.h b/src/writer/text_generator.h index 3bd204961a..60084dda0d 100644 --- a/src/writer/text_generator.h +++ b/src/writer/text_generator.h @@ -141,7 +141,7 @@ class TextGenerator { ~LineWriter(); /// @returns the ostringstream - operator std::ostream &() { return os; } + operator std::ostream&() { return os; } /// @param rhs the value to write to the line /// @returns the ostream so calls can be chained diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 00fca10902..97ff2ffcb4 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -116,8 +116,8 @@ bool GeneratorImpl::EmitTypeDecl(const ast::TypeDecl* ty) { bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* expr) { - if (auto* a = expr->As()) { - return EmitArrayAccessor(out, a); + if (auto* a = expr->As()) { + return EmitIndexAccessor(out, a); } if (auto* b = expr->As()) { return EmitBinary(out, b); @@ -152,12 +152,12 @@ bool GeneratorImpl::EmitExpression(std::ostream& out, return false; } -bool GeneratorImpl::EmitArrayAccessor( +bool GeneratorImpl::EmitIndexAccessor( std::ostream& out, - const ast::ArrayAccessorExpression* expr) { + const ast::IndexAccessorExpression* expr) { bool paren_lhs = !expr->array - ->IsAnyOfIsAnyOf(); if (paren_lhs) { @@ -184,7 +184,7 @@ bool GeneratorImpl::EmitMemberAccessor( const ast::MemberAccessorExpression* expr) { bool paren_lhs = !expr->structure - ->IsAnyOfIsAnyOf(); if (paren_lhs) { diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h index ca6a182039..5a8559e120 100644 --- a/src/writer/wgsl/generator_impl.h +++ b/src/writer/wgsl/generator_impl.h @@ -17,7 +17,6 @@ #include -#include "src/ast/array_accessor_expression.h" #include "src/ast/assignment_statement.h" #include "src/ast/binary_expression.h" #include "src/ast/bitcast_expression.h" @@ -27,6 +26,7 @@ #include "src/ast/fallthrough_statement.h" #include "src/ast/for_loop_statement.h" #include "src/ast/if_statement.h" +#include "src/ast/index_accessor_expression.h" #include "src/ast/loop_statement.h" #include "src/ast/member_accessor_expression.h" #include "src/ast/return_statement.h" @@ -62,8 +62,8 @@ class GeneratorImpl : public TextGenerator { /// @param out the output of the expression stream /// @param expr the expression to emit /// @returns true if the array accessor was emitted - bool EmitArrayAccessor(std::ostream& out, - const ast::ArrayAccessorExpression* expr); + bool EmitIndexAccessor(std::ostream& out, + const ast::IndexAccessorExpression* expr); /// Handles an assignment statement /// @param stmt the statement to emit /// @returns true if the statement was emitted successfully diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc index 4eff51a529..e6d5af30b7 100644 --- a/src/writer/wgsl/generator_impl_array_accessor_test.cc +++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc @@ -21,7 +21,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; -TEST_F(WgslGeneratorImplTest, ArrayAccessor) { +TEST_F(WgslGeneratorImplTest, IndexAccessor) { Global("ary", ty.array(), ast::StorageClass::kPrivate); auto* expr = IndexAccessor("ary", 5); WrapInFunction(expr); @@ -33,7 +33,7 @@ TEST_F(WgslGeneratorImplTest, ArrayAccessor) { EXPECT_EQ(out.str(), "ary[5]"); } -TEST_F(WgslGeneratorImplTest, ArrayAccessor_OfDref) { +TEST_F(WgslGeneratorImplTest, IndexAccessor_OfDref) { Global("ary", ty.array(), ast::StorageClass::kPrivate); auto* p = Const("p", nullptr, AddressOf("ary")); diff --git a/test/BUILD.gn b/test/BUILD.gn index a8a6cd120b..fa6e2a7767 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -146,7 +146,6 @@ tint_unittests_source_set("tint_unittests_core_sem_src") { tint_unittests_source_set("tint_unittests_core_src") { sources = [ "../src/ast/alias_test.cc", - "../src/ast/array_accessor_expression_test.cc", "../src/ast/array_test.cc", "../src/ast/assignment_statement_test.cc", "../src/ast/atomic_test.cc", @@ -174,6 +173,7 @@ tint_unittests_source_set("tint_unittests_core_src") { "../src/ast/function_test.cc", "../src/ast/group_decoration_test.cc", "../src/ast/i32_test.cc", + "../src/ast/index_accessor_expression_test.cc", "../src/ast/identifier_expression_test.cc", "../src/ast/if_statement_test.cc", "../src/ast/int_literal_expression_test.cc",