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 <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/fuzzers/tint_ast_fuzzer/mutations/replace_identifier_test.cc b/fuzzers/tint_ast_fuzzer/mutations/replace_identifier_test.cc
index d3a125f..b52918e 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 @@
.Functions()[0]
->body->statements[2]
->As<ast::AssignmentStatement>()
- ->lhs->As<ast::ArrayAccessorExpression>()
+ ->lhs->As<ast::IndexAccessorExpression>()
->array->As<ast::UnaryOpExpression>()
->expr->As<ast::UnaryOpExpression>()
->expr);
@@ -537,7 +537,7 @@
.Functions()[0]
->body->statements[2]
->As<ast::AssignmentStatement>()
- ->lhs->As<ast::ArrayAccessorExpression>()
+ ->lhs->As<ast::IndexAccessorExpression>()
->array->As<ast::UnaryOpExpression>()
->expr);
ASSERT_NE(use_id, 0);
@@ -584,7 +584,7 @@
.Functions()[0]
->body->statements[1]
->As<ast::AssignmentStatement>()
- ->lhs->As<ast::ArrayAccessorExpression>()
+ ->lhs->As<ast::IndexAccessorExpression>()
->array->As<ast::UnaryOpExpression>()
->expr->As<ast::UnaryOpExpression>()
->expr);
@@ -613,15 +613,15 @@
NodeIdMap node_id_map(program);
- auto use_id = node_id_map.GetId(
- program.AST()
- .Functions()[0]
- ->body->statements[1]
- ->As<ast::VariableDeclStatement>()
- ->variable->constructor->As<ast::ArrayAccessorExpression>()
- ->array->As<ast::UnaryOpExpression>()
- ->expr->As<ast::UnaryOpExpression>()
- ->expr);
+ auto use_id =
+ node_id_map.GetId(program.AST()
+ .Functions()[0]
+ ->body->statements[1]
+ ->As<ast::VariableDeclStatement>()
+ ->variable->constructor->As<ast::IndexAccessorExpression>()
+ ->array->As<ast::UnaryOpExpression>()
+ ->expr->As<ast::UnaryOpExpression>()
+ ->expr);
ASSERT_NE(use_id, 0);
auto replacement_id = node_id_map.GetId(program.AST().GlobalVariables()[0]);
@@ -649,14 +649,14 @@
NodeIdMap node_id_map(program);
- auto use_id = node_id_map.GetId(
- program.AST()
- .Functions()[0]
- ->body->statements[3]
- ->As<ast::VariableDeclStatement>()
- ->variable->constructor->As<ast::ArrayAccessorExpression>()
- ->array->As<ast::UnaryOpExpression>()
- ->expr);
+ auto use_id =
+ node_id_map.GetId(program.AST()
+ .Functions()[0]
+ ->body->statements[3]
+ ->As<ast::VariableDeclStatement>()
+ ->variable->constructor->As<ast::IndexAccessorExpression>()
+ ->array->As<ast::UnaryOpExpression>()
+ ->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 86fa2ba..2dc31b8 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -179,8 +179,6 @@
"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 @@
"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 dec0ab0..50090cd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,8 +42,8 @@
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 @@
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 @@
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 cf2fb7b..446f782 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 @@
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<ArrayAccessorExpression>(src, arr, idx);
+ return ctx->dst->create<IndexAccessorExpression>(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 0cb1e47..ffe38cb 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 ast {
/// An array accessor expression
-class ArrayAccessorExpression
- : public Castable<ArrayAccessorExpression, Expression> {
+class IndexAccessorExpression
+ : public Castable<IndexAccessorExpression, Expression> {
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 @@
} // 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 93f374a..f7fb504 100644
--- a/src/ast/array_accessor_expression_test.cc
+++ b/src/ast/index_accessor_expression_test.cc
@@ -19,70 +19,69 @@
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<ArrayAccessorExpression>(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<ArrayAccessorExpression>(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<ArrayAccessorExpression>(ary, idx);
- EXPECT_TRUE(exp->Is<ArrayAccessorExpression>());
+ auto* exp = IndexAccessor(ary, idx);
+ EXPECT_TRUE(exp->Is<IndexAccessorExpression>());
}
-TEST_F(ArrayAccessorExpressionTest, Assert_Null_Array) {
+TEST_F(IndexAccessorExpressionTest, Assert_Null_Array) {
EXPECT_FATAL_FAILURE(
{
ProgramBuilder b;
- b.create<ArrayAccessorExpression>(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<ArrayAccessorExpression>(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<ArrayAccessorExpression>(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<ArrayAccessorExpression>(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 c169775..9ee03c5 100644
--- a/src/ast/traverse_expressions.h
+++ b/src/ast/traverse_expressions.h
@@ -17,10 +17,10 @@
#include <vector>
-#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 @@
}
}
- if (auto* array = expr->As<ast::ArrayAccessorExpression>()) {
- push_pair(array->array, array->index);
- } else if (auto* bin_op = expr->As<ast::BinaryExpression>()) {
+ if (auto* idx = expr->As<IndexAccessorExpression>()) {
+ push_pair(idx->array, idx->index);
+ } else if (auto* bin_op = expr->As<BinaryExpression>()) {
push_pair(bin_op->lhs, bin_op->rhs);
- } else if (auto* bitcast = expr->As<ast::BitcastExpression>()) {
+ } else if (auto* bitcast = expr->As<BitcastExpression>()) {
to_visit.push_back(bitcast->expr);
- } else if (auto* call = expr->As<ast::CallExpression>()) {
+ } else if (auto* call = expr->As<CallExpression>()) {
// 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<ast::TypeConstructorExpression>()) {
+ } else if (auto* type_ctor = expr->As<TypeConstructorExpression>()) {
push_list(type_ctor->values);
- } else if (auto* member = expr->As<ast::MemberAccessorExpression>()) {
+ } else if (auto* member = expr->As<MemberAccessorExpression>()) {
// 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<ast::UnaryOpExpression>()) {
+ } else if (auto* unary = expr->As<UnaryOpExpression>()) {
to_visit.push_back(unary->expr);
- } else if (expr->IsAnyOf<ast::Literal, ast::IdentifierExpression,
- ast::PhonyExpression>()) {
+ } else if (expr->IsAnyOf<Literal, IdentifierExpression,
+ PhonyExpression>()) {
// 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 d1b2673..ecf9416 100644
--- a/src/ast/traverse_expressions_test.cc
+++ b/src/ast/traverse_expressions_test.cc
@@ -24,7 +24,7 @@
using TraverseExpressionsTest = TestHelper;
-TEST_F(TraverseExpressionsTest, DescendArrayAccessorExpression) {
+TEST_F(TraverseExpressionsTest, DescendIndexAccessor) {
std::vector<const ast::Expression*> e = {Expr(1), Expr(1), Expr(1), Expr(1)};
std::vector<const ast::Expression*> i = {IndexAccessor(e[0], e[1]),
IndexAccessor(e[2], e[3])};
diff --git a/src/program_builder.h b/src/program_builder.h
index 11f0276..97ef17f 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 @@
/// @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 <typename ARR, typename IDX>
- const ast::ArrayAccessorExpression* IndexAccessor(const Source& source,
+ const ast::IndexAccessorExpression* IndexAccessor(const Source& source,
ARR&& arr,
IDX&& idx) {
- return create<ast::ArrayAccessorExpression>(
+ return create<ast::IndexAccessorExpression>(
source, Expr(std::forward<ARR>(arr)), Expr(std::forward<IDX>(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 <typename ARR, typename IDX>
- const ast::ArrayAccessorExpression* IndexAccessor(ARR&& arr, IDX&& idx) {
- return create<ast::ArrayAccessorExpression>(Expr(std::forward<ARR>(arr)),
+ const ast::IndexAccessorExpression* IndexAccessor(ARR&& arr, IDX&& idx) {
+ return create<ast::IndexAccessorExpression>(Expr(std::forward<ARR>(arr)),
Expr(std::forward<IDX>(idx)));
}
diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc
index 21e51ae..8c31667 100644
--- a/src/reader/spirv/function.cc
+++ b/src/reader/spirv/function.cc
@@ -3622,7 +3622,7 @@
// 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<ast::ArrayAccessorExpression>(
+ lhs.expr = create<ast::IndexAccessorExpression>(
Source{}, lhs.expr, parser_impl_.MakeNullValue(ty_.I32()));
if (auto* ref = lhs.type->As<Reference>()) {
lhs.type = ref->type;
@@ -3672,7 +3672,7 @@
Source{}, builder_.Symbols().Register(name));
// SampleMask is an array in Vulkan SPIR-V. Always access the first
// element.
- id_expr = create<ast::ArrayAccessorExpression>(
+ id_expr = create<ast::IndexAccessorExpression>(
Source{}, id_expr, parser_impl_.MakeNullValue(ty_.I32()));
auto* loaded_type = parser_impl_.ConvertType(inst.type_id());
@@ -3972,7 +3972,7 @@
}
if (opcode == SpvOpVectorExtractDynamic) {
- return {ast_type, create<ast::ArrayAccessorExpression>(
+ return {ast_type, create<ast::IndexAccessorExpression>(
Source{}, MakeOperand(inst, 0).expr,
MakeOperand(inst, 1).expr)};
}
@@ -4362,7 +4362,7 @@
Source{}, current_expr.expr, Swizzle(uint32_t(index_const_val)));
} else {
// Non-constant index. Use array syntax
- next_expr = create<ast::ArrayAccessorExpression>(
+ next_expr = create<ast::IndexAccessorExpression>(
Source{}, current_expr.expr, MakeOperand(inst, index).expr);
}
// All vector components are the same type.
@@ -4372,18 +4372,18 @@
break;
case SpvOpTypeMatrix:
// Use array syntax.
- next_expr = create<ast::ArrayAccessorExpression>(
+ next_expr = create<ast::IndexAccessorExpression>(
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<ast::ArrayAccessorExpression>(
+ next_expr = create<ast::IndexAccessorExpression>(
Source{}, current_expr.expr, MakeOperand(inst, index).expr);
pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0);
break;
case SpvOpTypeRuntimeArray:
- next_expr = create<ast::ArrayAccessorExpression>(
+ next_expr = create<ast::IndexAccessorExpression>(
Source{}, current_expr.expr, MakeOperand(inst, index).expr);
pointee_type_id = pointee_type_inst->GetSingleWordInOperand(0);
break;
@@ -4543,7 +4543,7 @@
<< " is too big. Max handled index is " << kMaxVectorLen - 1;
}
// Use array syntax.
- next_expr = create<ast::ArrayAccessorExpression>(
+ next_expr = create<ast::IndexAccessorExpression>(
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 @@
// 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<ast::ArrayAccessorExpression>(
+ next_expr = create<ast::IndexAccessorExpression>(
Source{}, current_expr.expr, make_index(index_val));
current_type_id = current_type_inst->GetSingleWordInOperand(0);
break;
@@ -5946,7 +5946,7 @@
AddStatement(builder_.Decl({}, temp_var));
}
- auto* lhs = create<ast::ArrayAccessorExpression>(
+ auto* lhs = create<ast::IndexAccessorExpression>(
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 6ad62fd..0ace622 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -603,7 +603,7 @@
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 8e904bf..f818f27 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -2270,7 +2270,7 @@
return Failure::kErrored;
}
- return create<ast::ArrayAccessorExpression>(source, prefix,
+ return create<ast::IndexAccessorExpression>(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 38cdc7c..251b504 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 @@
auto* ident = mem->member->As<ast::IdentifierExpression>();
EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("d"));
- ASSERT_TRUE(mem->structure->Is<ast::ArrayAccessorExpression>());
- auto* ary = mem->structure->As<ast::ArrayAccessorExpression>();
+ ASSERT_TRUE(mem->structure->Is<ast::IndexAccessorExpression>());
+ auto* ary = mem->structure->As<ast::IndexAccessorExpression>();
ASSERT_NE(ary->index, nullptr);
ASSERT_TRUE(ary->index->Is<ast::SintLiteral>());
diff --git a/src/reader/wgsl/parser_impl_singular_expression_test.cc b/src/reader/wgsl/parser_impl_singular_expression_test.cc
index 10c0e13..02bffc3 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 @@
EXPECT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e.value, nullptr);
- ASSERT_TRUE(e->Is<ast::ArrayAccessorExpression>());
- auto* ary = e->As<ast::ArrayAccessorExpression>();
+ ASSERT_TRUE(e->Is<ast::IndexAccessorExpression>());
+ auto* ary = e->As<ast::IndexAccessorExpression>();
ASSERT_TRUE(ary->array->Is<ast::IdentifierExpression>());
auto* ident = ary->array->As<ast::IdentifierExpression>();
@@ -46,8 +46,8 @@
EXPECT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e.value, nullptr);
- ASSERT_TRUE(e->Is<ast::ArrayAccessorExpression>());
- auto* ary = e->As<ast::ArrayAccessorExpression>();
+ ASSERT_TRUE(e->Is<ast::IndexAccessorExpression>());
+ auto* ary = e->As<ast::IndexAccessorExpression>();
ASSERT_TRUE(ary->array->Is<ast::IdentifierExpression>());
auto* ident = ary->array->As<ast::IdentifierExpression>();
@@ -202,7 +202,7 @@
ASSERT_TRUE(e->Is<ast::IdentifierExpression>());
}
-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 @@
EXPECT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e.value, nullptr);
- const auto* outer_accessor = e->As<ast::ArrayAccessorExpression>();
+ const auto* outer_accessor = e->As<ast::IndexAccessorExpression>();
ASSERT_TRUE(outer_accessor);
const auto* outer_array =
@@ -219,7 +219,7 @@
EXPECT_EQ(outer_array->symbol, p->builder().Symbols().Get("a"));
const auto* inner_accessor =
- outer_accessor->index->As<ast::ArrayAccessorExpression>();
+ outer_accessor->index->As<ast::IndexAccessorExpression>();
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 177a97a..43132fd 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 @@
EXPECT_FALSE(p->has_error()) << p->error();
ASSERT_NE(e.value, nullptr);
- ASSERT_TRUE(e->Is<ast::ArrayAccessorExpression>());
- auto* ary = e->As<ast::ArrayAccessorExpression>();
+ ASSERT_TRUE(e->Is<ast::IndexAccessorExpression>());
+ auto* ary = e->As<ast::IndexAccessorExpression>();
ASSERT_TRUE(ary->array->Is<ast::IdentifierExpression>());
auto* ident = ary->array->As<ast::IdentifierExpression>();
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 728c119..9edd685 100644
--- a/src/resolver/array_accessor_test.cc
+++ b/src/resolver/array_accessor_test.cc
@@ -22,9 +22,9 @@
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<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1.0f));
WrapInFunction(acc);
@@ -34,7 +34,7 @@
"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<f32>(), ast::StorageClass::kPrivate);
auto* idx = Var("idx", ty.i32(), Construct(ty.i32()));
auto* acc = IndexAccessor("my_var", idx);
@@ -43,7 +43,7 @@
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<f32>(), ast::StorageClass::kPrivate);
auto* idx = Var("idx", ty.u32(), Expr(3u));
auto* idy = Var("idy", ty.u32(), Expr(2u));
@@ -53,7 +53,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
-TEST_F(ResolverArrayAccessorTest, Matrix_Dynamic) {
+TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic) {
GlobalConst("my_const", ty.mat2x3<f32>(), Construct(ty.mat2x3<f32>()));
auto* idx = Var("idx", ty.i32(), Construct(ty.i32()));
auto* acc = IndexAccessor("my_const", Expr(Source{{12, 34}}, idx));
@@ -64,7 +64,7 @@
"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<f32>(), Construct(ty.mat4x4<f32>()));
auto* idx = Var("idx", ty.u32(), Expr(3u));
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx));
@@ -75,7 +75,7 @@
"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<f32>(), Construct(ty.mat4x4<f32>()));
auto* idx = Var("idy", ty.u32(), Expr(2u));
auto* acc =
@@ -87,7 +87,7 @@
"12:34 error: index must be signed or unsigned integer literal");
}
-TEST_F(ResolverArrayAccessorTest, Matrix) {
+TEST_F(ResolverIndexAccessorTest, Matrix) {
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2);
@@ -103,7 +103,7 @@
EXPECT_EQ(ref->StoreType()->As<sem::Vector>()->Width(), 3u);
}
-TEST_F(ResolverArrayAccessorTest, Matrix_BothDimensions) {
+TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) {
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor(IndexAccessor("my_var", 2), 1);
@@ -118,7 +118,7 @@
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
}
-TEST_F(ResolverArrayAccessorTest, Vector_F32) {
+TEST_F(ResolverIndexAccessorTest, Vector_F32) {
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2.0f));
WrapInFunction(acc);
@@ -128,7 +128,7 @@
"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<f32>(), ast::StorageClass::kPrivate);
auto* idx = Var("idx", ty.i32(), Expr(2));
auto* acc = IndexAccessor("my_var", idx);
@@ -137,7 +137,7 @@
EXPECT_TRUE(r()->Resolve());
}
-TEST_F(ResolverArrayAccessorTest, Vector_Dynamic) {
+TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) {
GlobalConst("my_var", ty.vec3<f32>(), Construct(ty.vec3<f32>()));
auto* idx = Var("idx", ty.i32(), Expr(2));
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx));
@@ -146,7 +146,7 @@
EXPECT_TRUE(r()->Resolve());
}
-TEST_F(ResolverArrayAccessorTest, Vector) {
+TEST_F(ResolverIndexAccessorTest, Vector) {
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2);
@@ -161,7 +161,7 @@
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
}
-TEST_F(ResolverArrayAccessorTest, Array) {
+TEST_F(ResolverIndexAccessorTest, Array) {
auto* idx = Expr(2);
Global("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
@@ -177,7 +177,7 @@
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
}
-TEST_F(ResolverArrayAccessorTest, Alias_Array) {
+TEST_F(ResolverIndexAccessorTest, Alias_Array) {
auto* aary = Alias("myarrty", ty.array<f32, 3>());
Global("my_var", ty.Of(aary), ast::StorageClass::kPrivate);
@@ -194,7 +194,7 @@
EXPECT_TRUE(ref->StoreType()->Is<sem::F32>());
}
-TEST_F(ResolverArrayAccessorTest, Array_Constant) {
+TEST_F(ResolverIndexAccessorTest, Array_Constant) {
GlobalConst("my_var", ty.array<f32, 3>(), array<f32, 3>());
auto* acc = IndexAccessor("my_var", 2);
@@ -206,7 +206,7 @@
EXPECT_TRUE(TypeOf(acc)->Is<sem::F32>()) << TypeOf(acc)->type_name();
}
-TEST_F(ResolverArrayAccessorTest, Array_Dynamic_I32) {
+TEST_F(ResolverIndexAccessorTest, Array_Dynamic_I32) {
// let a : array<f32, 3> = 0;
// var idx : i32 = 0;
// var f : f32 = a[idx];
@@ -226,7 +226,7 @@
"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<f32, 3>;
// var f : f32 = a[2.0f];
auto* a = Const("a", ty.array<f32, 3>(), array<f32, 3>());
@@ -243,7 +243,7 @@
"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<f32, 3>;
// var f : f32 = a[2];
auto* a = Const("a", ty.array<f32, 3>(), array<f32, 3>());
@@ -257,7 +257,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
-TEST_F(ResolverArrayAccessorTest, EXpr_Deref_FuncGoodParent) {
+TEST_F(ResolverIndexAccessorTest, EXpr_Deref_FuncGoodParent) {
// fn func(p: ptr<function, vec4<f32>>) -> f32 {
// let idx: u32 = u32();
// let x: f32 = (*p)[idx];
@@ -274,7 +274,7 @@
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
-TEST_F(ResolverArrayAccessorTest, EXpr_Deref_FuncBadParent) {
+TEST_F(ResolverIndexAccessorTest, EXpr_Deref_FuncBadParent) {
// fn func(p: ptr<function, vec4<f32>>) -> f32 {
// let idx: u32 = u32();
// let x: f32 = *p[idx];
@@ -294,7 +294,7 @@
"12:34 error: cannot index type 'ptr<function, vec4<f32>, read_write>'");
}
-TEST_F(ResolverArrayAccessorTest, Exr_Deref_BadParent) {
+TEST_F(ResolverIndexAccessorTest, Exr_Deref_BadParent) {
// var param: vec4<f32>
// let x: f32 = *(¶m)[0];
auto* param = Var("param", ty.vec4<f32>());
diff --git a/src/resolver/entry_point_validation_test.cc b/src/resolver/entry_point_validation_test.cc
index 0ac3b81..0fc620b 100644
--- a/src/resolver/entry_point_validation_test.cc
+++ b/src/resolver/entry_point_validation_test.cc
@@ -166,7 +166,6 @@
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 @@
using TypeValidationTest = resolver::ResolverTestWithParam<Params>;
static constexpr Params cases[] = {
- ParamsFor<f32>(true), //
- ParamsFor<i32>(true), //
- ParamsFor<u32>(true), //
- ParamsFor<bool>(false), //
- ParamsFor<vec2<f32>>(true), //
- ParamsFor<vec3<f32>>(true), //
- ParamsFor<vec4<f32>>(true), //
- ParamsFor<mat2x2<f32>>(false), //
- ParamsFor<mat3x3<f32>>(false), //
- ParamsFor<mat4x4<f32>>(false), //
- ParamsFor<alias<f32>>(true), //
- ParamsFor<alias<i32>>(true), //
- ParamsFor<alias<u32>>(true), //
- ParamsFor<alias<bool>>(false), //
+ ParamsFor<f32>(true), //
+ ParamsFor<i32>(true), //
+ ParamsFor<u32>(true), //
+ ParamsFor<bool>(false), //
+ ParamsFor<vec2<f32>>(true), //
+ ParamsFor<vec3<f32>>(true), //
+ ParamsFor<vec4<f32>>(true), //
+ ParamsFor<mat2x2<f32>>(false), //
+ ParamsFor<mat3x3<f32>>(false), //
+ ParamsFor<mat4x4<f32>>(false), //
+ ParamsFor<alias<f32>>(true), //
+ ParamsFor<alias<i32>>(true), //
+ ParamsFor<alias<u32>>(true), //
+ ParamsFor<alias<bool>>(false), //
};
TEST_P(TypeValidationTest, BareInputs) {
diff --git a/src/resolver/ptr_ref_validation_test.cc b/src/resolver/ptr_ref_validation_test.cc
index 87886bb..57aea32 100644
--- a/src/resolver/ptr_ref_validation_test.cc
+++ b/src/resolver/ptr_ref_validation_test.cc
@@ -80,7 +80,7 @@
"12:34 error: cannot take the address of a vector component");
}
-TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_ArrayAccessor) {
+TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_IndexAccessor) {
// var v : vec4<i32>;
// &v[2]
auto* v = Var("v", ty.vec4<i32>());
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index 9dea45f..6943354 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -2354,8 +2354,8 @@
for (auto* expr : utils::Reverse(sorted)) {
sem::Expression* sem_expr = nullptr;
- if (auto* array = expr->As<ast::ArrayAccessorExpression>()) {
- sem_expr = ArrayAccessor(array);
+ if (auto* array = expr->As<ast::IndexAccessorExpression>()) {
+ sem_expr = IndexAccessor(array);
} else if (auto* bin_op = expr->As<ast::BinaryExpression>()) {
sem_expr = Binary(bin_op);
} else if (auto* bitcast = expr->As<ast::BitcastExpression>()) {
@@ -2394,8 +2394,8 @@
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 @@
return nullptr;
}
- auto* array = unary->expr->As<ast::ArrayAccessorExpression>();
+ auto* array = unary->expr->As<ast::IndexAccessorExpression>();
auto* member = unary->expr->As<ast::MemberAccessorExpression>();
if ((array && TypeOf(array->array)->UnwrapRef()->Is<sem::Vector>()) ||
(member &&
diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h
index b75532e..c19dfee 100644
--- a/src/resolver/resolver.h
+++ b/src/resolver/resolver.h
@@ -37,7 +37,7 @@
// Forward declarations
namespace ast {
-class ArrayAccessorExpression;
+class IndexAccessorExpression;
class BinaryExpression;
class BitcastExpression;
class CallExpression;
@@ -167,7 +167,7 @@
// 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 cf1a91f..45afc80 100644
--- a/src/resolver/resolver_test.cc
+++ b/src/resolver/resolver_test.cc
@@ -667,7 +667,7 @@
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<bool, 10> = 0;
// var idx : f32 = f32();
// var f : f32 = a[idx];
diff --git a/src/sem/variable.cc b/src/sem/variable.cc
index 5eac5b8..dd242be 100644
--- a/src/sem/variable.cc
+++ b/src/sem/variable.cc
@@ -64,7 +64,6 @@
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 32ff132..8069489 100644
--- a/src/transform/decompose_memory_access.cc
+++ b/src/transform/decompose_memory_access.cc
@@ -851,7 +851,7 @@
continue;
}
- if (auto* accessor = node->As<ast::ArrayAccessorExpression>()) {
+ if (auto* accessor = node->As<ast::IndexAccessorExpression>()) {
if (auto access = state.TakeAccess(accessor->array)) {
// X[Y]
if (auto* arr = access.type->As<sem::Array>()) {
diff --git a/src/transform/decompose_strided_matrix.cc b/src/transform/decompose_strided_matrix.cc
index 2d21a5b..3142b25 100644
--- a/src/transform/decompose_strided_matrix.cc
+++ b/src/transform/decompose_strided_matrix.cc
@@ -144,8 +144,8 @@
// 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<sem::StructMemberAccess>(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 ea61615..aa97b92 100644
--- a/src/transform/inline_pointer_lets.cc
+++ b/src/transform/inline_pointer_lets.cc
@@ -43,7 +43,7 @@
void CollectSavedArrayIndices(const Program* program,
const ast::Expression* expr,
F&& cb) {
- if (auto* a = expr->As<ast::ArrayAccessorExpression>()) {
+ if (auto* a = expr->As<ast::IndexAccessorExpression>()) {
CollectSavedArrayIndices(program, a->array, cb);
if (!a->index->Is<ast::Literal>()) {
diff --git a/src/transform/pad_array_elements.cc b/src/transform/pad_array_elements.cc
index 58f6836..254ae6d 100644
--- a/src/transform/pad_array_elements.cc
+++ b/src/transform/pad_array_elements.cc
@@ -115,7 +115,7 @@
});
// 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::Array>(
sem.Get(accessor->array)->Type()->UnwrapRef())) {
diff --git a/src/transform/renamer_test.cc b/src/transform/renamer_test.cc
index 457f59e..d32c9f3 100644
--- a/src/transform/renamer_test.cc
+++ b/src/transform/renamer_test.cc
@@ -1300,7 +1300,7 @@
"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 b4465a3..4578e34 100644
--- a/src/transform/robustness.cc
+++ b/src/transform/robustness.cc
@@ -41,7 +41,7 @@
/// 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 @@
/// @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<sem::Reference>();
diff --git a/src/transform/robustness.h b/src/transform/robustness.h
index 1333e5c..0447340 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 782004f..181c737 100644
--- a/src/transform/wrap_arrays_in_structs.cc
+++ b/src/transform/wrap_arrays_in_structs.cc
@@ -57,8 +57,8 @@
});
// 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::Array>(
sem.Get(accessor->array)->Type()->UnwrapRef())) {
if (wrapper(array)) {
diff --git a/src/utils/unique_vector.h b/src/utils/unique_vector.h
index 8d92bea..c0a8e3f 100644
--- a/src/utils/unique_vector.h
+++ b/src/utils/unique_vector.h
@@ -72,7 +72,7 @@
ConstIterator end() const { return vector.end(); }
/// @returns a const reference to the internal vector
- operator const std::vector<T> &() const { return vector; }
+ operator const std::vector<T>&() const { return vector; }
private:
std::vector<T> vector;
diff --git a/src/writer/float_to_string.cc b/src/writer/float_to_string.cc
index 900599d..d140b34 100644
--- a/src/writer/float_to_string.cc
+++ b/src/writer/float_to_string.cc
@@ -16,10 +16,10 @@
#include <cmath>
#include <cstring>
+#include <functional>
#include <iomanip>
#include <limits>
#include <sstream>
-#include <functional>
#include "src/debug.h"
diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc
index 16cbf30..1d0213a 100644
--- a/src/writer/glsl/generator_impl.cc
+++ b/src/writer/glsl/generator_impl.cc
@@ -164,9 +164,9 @@
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::EmitExpression(std::ostream& out,
const ast::Expression* expr) {
- if (auto* a = expr->As<ast::ArrayAccessorExpression>()) {
- return EmitArrayAccessor(out, a);
+ if (auto* a = expr->As<ast::IndexAccessorExpression>()) {
+ return EmitIndexAccessor(out, a);
}
if (auto* b = expr->As<ast::BinaryExpression>()) {
return EmitBinary(out, b);
diff --git a/src/writer/glsl/generator_impl.h b/src/writer/glsl/generator_impl.h
index 9258cae..c478d3b 100644
--- a/src/writer/glsl/generator_impl.h
+++ b/src/writer/glsl/generator_impl.h
@@ -63,8 +63,8 @@
/// @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 1ba07b6..7460f76 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 @@
using GlslGeneratorImplTest_Expression = TestHelper;
-TEST_F(GlslGeneratorImplTest_Expression, ArrayAccessor) {
+TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) {
Global("ary", ty.array<i32, 10>(), 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 cf5b9b7..d1df07a 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 @@
}
TEST_F(GlslGeneratorImplTest_MemberAccessor,
- EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray) {
+ EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray) {
// struct Data {
// a : [[stride(4)]] array<i32, 5>;
// };
@@ -406,7 +406,7 @@
}
TEST_F(GlslGeneratorImplTest_MemberAccessor,
- EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
+ EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
// struct Data {
// a : [[stride(4)]] array<i32, 5>;
// };
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index f01ce15..8a2d114 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -291,7 +291,7 @@
return false;
}
- auto* ast_access_expr = stmt->lhs->As<ast::ArrayAccessorExpression>();
+ auto* ast_access_expr = stmt->lhs->As<ast::IndexAccessorExpression>();
auto out = line();
out << name << "(";
@@ -311,9 +311,9 @@
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::EmitAssign(const ast::AssignmentStatement* stmt) {
- if (auto* idx = stmt->lhs->As<ast::ArrayAccessorExpression>()) {
+ if (auto* idx = stmt->lhs->As<ast::IndexAccessorExpression>()) {
if (auto* vec = TypeOf(idx->array)->UnwrapRef()->As<sem::Vector>()) {
auto* rhs_sem = builder_.Sem().Get(idx->index);
if (!rhs_sem->ConstantValue().IsValid()) {
@@ -2191,8 +2191,8 @@
bool GeneratorImpl::EmitExpression(std::ostream& out,
const ast::Expression* expr) {
- if (auto* a = expr->As<ast::ArrayAccessorExpression>()) {
- return EmitArrayAccessor(out, a);
+ if (auto* a = expr->As<ast::IndexAccessorExpression>()) {
+ return EmitIndexAccessor(out, a);
}
if (auto* b = expr->As<ast::BinaryExpression>()) {
return EmitBinary(out, b);
diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h
index 67a4da5..1aadf4a 100644
--- a/src/writer/hlsl/generator_impl.h
+++ b/src/writer/hlsl/generator_impl.h
@@ -79,8 +79,8 @@
/// @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 b2fb021..00c75e4 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 @@
using HlslGeneratorImplTest_Expression = TestHelper;
-TEST_F(HlslGeneratorImplTest_Expression, ArrayAccessor) {
+TEST_F(HlslGeneratorImplTest_Expression, IndexAccessor) {
Global("ary", ty.array<i32, 10>(), 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 ccefe54..195a160 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 @@
}
TEST_F(HlslGeneratorImplTest_MemberAccessor,
- EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray) {
+ EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray) {
// struct Data {
// a : [[stride(4)]] array<i32, 5>;
// };
@@ -423,7 +423,7 @@
}
TEST_F(HlslGeneratorImplTest_MemberAccessor,
- EmitExpression_ArrayAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
+ EmitExpression_IndexAccessor_StorageBuffer_Load_Int_FromArray_ExprIdx) {
// struct Data {
// a : [[stride(4)]] array<i32, 5>;
// };
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index eccfa3a..f733b27 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -238,12 +238,12 @@
return true;
}
-bool GeneratorImpl::EmitArrayAccessor(
+bool GeneratorImpl::EmitIndexAccessor(
std::ostream& out,
- const ast::ArrayAccessorExpression* expr) {
+ const ast::IndexAccessorExpression* expr) {
bool paren_lhs =
!expr->array
- ->IsAnyOf<ast::ArrayAccessorExpression, ast::CallExpression,
+ ->IsAnyOf<ast::IndexAccessorExpression, ast::CallExpression,
ast::IdentifierExpression, ast::MemberAccessorExpression,
ast::TypeConstructorExpression>();
@@ -763,7 +763,7 @@
auto texture_expr = [&]() {
bool paren_lhs =
!texture
- ->IsAnyOf<ast::ArrayAccessorExpression, ast::CallExpression,
+ ->IsAnyOf<ast::IndexAccessorExpression, ast::CallExpression,
ast::IdentifierExpression, ast::MemberAccessorExpression,
ast::TypeConstructorExpression>();
if (paren_lhs) {
@@ -1418,8 +1418,8 @@
bool GeneratorImpl::EmitExpression(std::ostream& out,
const ast::Expression* expr) {
- if (auto* a = expr->As<ast::ArrayAccessorExpression>()) {
- return EmitArrayAccessor(out, a);
+ if (auto* a = expr->As<ast::IndexAccessorExpression>()) {
+ return EmitIndexAccessor(out, a);
}
if (auto* b = expr->As<ast::BinaryExpression>()) {
return EmitBinary(out, b);
@@ -1905,7 +1905,7 @@
auto write_lhs = [&] {
bool paren_lhs =
!expr->structure
- ->IsAnyOf<ast::ArrayAccessorExpression, ast::CallExpression,
+ ->IsAnyOf<ast::IndexAccessorExpression, ast::CallExpression,
ast::IdentifierExpression, ast::MemberAccessorExpression,
ast::TypeConstructorExpression>();
if (paren_lhs) {
diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h
index 5c59326..557c941 100644
--- a/src/writer/msl/generator_impl.h
+++ b/src/writer/msl/generator_impl.h
@@ -19,7 +19,6 @@
#include <unordered_map>
#include <vector>
-#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 @@
/// @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 dc2f0dc..3dd881f 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 @@
using MslGeneratorImplTest = TestHelper;
-TEST_F(MslGeneratorImplTest, ArrayAccessor) {
+TEST_F(MslGeneratorImplTest, IndexAccessor) {
auto* ary = Var("ary", ty.array<i32, 10>());
auto* expr = IndexAccessor("ary", 5);
WrapInFunction(ary, expr);
@@ -33,7 +33,7 @@
EXPECT_EQ(out.str(), "ary[5]");
}
-TEST_F(MslGeneratorImplTest, ArrayAccessor_OfDref) {
+TEST_F(MslGeneratorImplTest, IndexAccessor_OfDref) {
Global("ary", ty.array<i32, 10>(), 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 a56e636..75d4d0d 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -565,7 +565,7 @@
}
uint32_t Builder::GenerateExpression(const ast::Expression* expr) {
- if (auto* a = expr->As<ast::ArrayAccessorExpression>()) {
+ if (auto* a = expr->As<ast::IndexAccessorExpression>()) {
return GenerateAccessorExpression(a);
}
if (auto* b = expr->As<ast::BinaryExpression>()) {
@@ -900,7 +900,7 @@
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 @@
}
uint32_t Builder::GenerateAccessorExpression(const ast::Expression* expr) {
- if (!expr->IsAnyOf<ast::ArrayAccessorExpression,
+ if (!expr->IsAnyOf<ast::IndexAccessorExpression,
ast::MemberAccessorExpression>()) {
TINT_ICE(Writer, builder_.Diagnostics()) << "expression is not an accessor";
return 0;
@@ -1101,7 +1101,7 @@
std::vector<const ast::Expression*> accessors;
const ast::Expression* source = expr;
while (true) {
- if (auto* array = source->As<ast::ArrayAccessorExpression>()) {
+ if (auto* array = source->As<ast::IndexAccessorExpression>()) {
accessors.insert(accessors.begin(), source);
source = array->array;
} else if (auto* member = source->As<ast::MemberAccessorExpression>()) {
@@ -1120,8 +1120,8 @@
info.source_type = TypeOf(source);
for (auto* accessor : accessors) {
- if (auto* array = accessor->As<ast::ArrayAccessorExpression>()) {
- if (!GenerateArrayAccessor(array, &info)) {
+ if (auto* array = accessor->As<ast::IndexAccessorExpression>()) {
+ if (!GenerateIndexAccessor(array, &info)) {
return 0;
}
} else if (auto* member = accessor->As<ast::MemberAccessorExpression>()) {
diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h
index 4ceefa2..a93e577 100644
--- a/src/writer/spirv/builder.h
+++ b/src/writer/spirv/builder.h
@@ -311,7 +311,7 @@
/// @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 266ed49..2e154fb 100644
--- a/src/writer/spirv/builder_accessor_expression_test.cc
+++ b/src/writer/spirv/builder_accessor_expression_test.cc
@@ -22,7 +22,7 @@
using BuilderTest = TestHelper;
-TEST_F(BuilderTest, ArrayAccessor_VectorRef_Literal) {
+TEST_F(BuilderTest, IndexAccessor_VectorRef_Literal) {
// var ary : vec3<f32>;
// ary[1] -> ref<f32>
@@ -57,7 +57,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_VectorRef_Dynamic) {
+TEST_F(BuilderTest, IndexAccessor_VectorRef_Dynamic) {
// var ary : vec3<f32>;
// var idx : i32;
// ary[idx] -> ref<f32>
@@ -98,7 +98,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_VectorRef_Dynamic2) {
+TEST_F(BuilderTest, IndexAccessor_VectorRef_Dynamic2) {
// var ary : vec3<f32>;
// ary[1 + 2] -> ref<f32>
@@ -134,7 +134,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_ArrayRef_MultiLevel) {
+TEST_F(BuilderTest, IndexAccessor_ArrayRef_MultiLevel) {
auto* ary4 = ty.array(ty.vec3<f32>(), 4);
// var ary : array<vec3<f32>, 4>
@@ -172,7 +172,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_ArrayRef_ArrayWithSwizzle) {
+TEST_F(BuilderTest, IndexAccessor_ArrayRef_ArrayWithSwizzle) {
auto* ary4 = ty.array(ty.vec3<f32>(), 4);
// var a : array<vec3<f32>, 4>;
@@ -682,7 +682,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_Mixed_ArrayAndMember) {
+TEST_F(BuilderTest, IndexAccessor_Mixed_ArrayAndMember) {
// type C = struct {
// baz : vec3<f32>
// }
@@ -749,7 +749,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_Of_Vec) {
+TEST_F(BuilderTest, IndexAccessor_Of_Vec) {
// let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
// vec2<f32>(0.0, 0.5),
// vec2<f32>(-0.5, -0.5),
@@ -792,7 +792,7 @@
Validate(b);
}
-TEST_F(BuilderTest, ArrayAccessor_Of_Array_Of_f32) {
+TEST_F(BuilderTest, IndexAccessor_Of_Array_Of_f32) {
// let pos : array<array<f32, 2>, 3> = array<vec2<f32, 2>, 3>(
// array<f32, 2>(0.0, 0.5),
// array<f32, 2>(-0.5, -0.5),
@@ -837,7 +837,7 @@
Validate(b);
}
-TEST_F(BuilderTest, ArrayAccessor_Vec_Literal) {
+TEST_F(BuilderTest, IndexAccessor_Vec_Literal) {
// let pos : vec2<f32> = vec2<f32>(0.0, 0.5);
// pos[1]
@@ -866,7 +866,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_Vec_Dynamic) {
+TEST_F(BuilderTest, IndexAccessor_Vec_Dynamic) {
// let pos : vec2<f32> = vec2<f32>(0.0, 0.5);
// idx : i32
// pos[idx]
@@ -902,7 +902,7 @@
)");
}
-TEST_F(BuilderTest, ArrayAccessor_Array_Literal) {
+TEST_F(BuilderTest, IndexAccessor_Array_Literal) {
// let a : array<f32, 3>;
// a[2]
@@ -936,7 +936,7 @@
Validate(b);
}
-TEST_F(BuilderTest, ArrayAccessor_Array_Dynamic) {
+TEST_F(BuilderTest, IndexAccessor_Array_Dynamic) {
// var a : array<f32, 3>;
// idx : i32
// a[idx]
@@ -984,7 +984,7 @@
Validate(b);
}
-TEST_F(BuilderTest, ArrayAccessor_Matrix_Dynamic) {
+TEST_F(BuilderTest, IndexAccessor_Matrix_Dynamic) {
// var a : mat2x2<f32>(vec2<f32>(1., 2.), vec2<f32>(3., 4.));
// idx : i32
// a[idx]
diff --git a/src/writer/text_generator.h b/src/writer/text_generator.h
index 3bd2049..60084dd 100644
--- a/src/writer/text_generator.h
+++ b/src/writer/text_generator.h
@@ -141,7 +141,7 @@
~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 00fca10..97ff2ff 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -116,8 +116,8 @@
bool GeneratorImpl::EmitExpression(std::ostream& out,
const ast::Expression* expr) {
- if (auto* a = expr->As<ast::ArrayAccessorExpression>()) {
- return EmitArrayAccessor(out, a);
+ if (auto* a = expr->As<ast::IndexAccessorExpression>()) {
+ return EmitIndexAccessor(out, a);
}
if (auto* b = expr->As<ast::BinaryExpression>()) {
return EmitBinary(out, b);
@@ -152,12 +152,12 @@
return false;
}
-bool GeneratorImpl::EmitArrayAccessor(
+bool GeneratorImpl::EmitIndexAccessor(
std::ostream& out,
- const ast::ArrayAccessorExpression* expr) {
+ const ast::IndexAccessorExpression* expr) {
bool paren_lhs =
!expr->array
- ->IsAnyOf<ast::ArrayAccessorExpression, ast::CallExpression,
+ ->IsAnyOf<ast::IndexAccessorExpression, ast::CallExpression,
ast::IdentifierExpression, ast::MemberAccessorExpression,
ast::TypeConstructorExpression>();
if (paren_lhs) {
@@ -184,7 +184,7 @@
const ast::MemberAccessorExpression* expr) {
bool paren_lhs =
!expr->structure
- ->IsAnyOf<ast::ArrayAccessorExpression, ast::CallExpression,
+ ->IsAnyOf<ast::IndexAccessorExpression, ast::CallExpression,
ast::IdentifierExpression, ast::MemberAccessorExpression,
ast::TypeConstructorExpression>();
if (paren_lhs) {
diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h
index ca6a182..5a8559e 100644
--- a/src/writer/wgsl/generator_impl.h
+++ b/src/writer/wgsl/generator_impl.h
@@ -17,7 +17,6 @@
#include <string>
-#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 @@
/// @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 4eff51a..e6d5af3 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 @@
using WgslGeneratorImplTest = TestHelper;
-TEST_F(WgslGeneratorImplTest, ArrayAccessor) {
+TEST_F(WgslGeneratorImplTest, IndexAccessor) {
Global("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
auto* expr = IndexAccessor("ary", 5);
WrapInFunction(expr);
@@ -33,7 +33,7 @@
EXPECT_EQ(out.str(), "ary[5]");
}
-TEST_F(WgslGeneratorImplTest, ArrayAccessor_OfDref) {
+TEST_F(WgslGeneratorImplTest, IndexAccessor_OfDref) {
Global("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
auto* p = Const("p", nullptr, AddressOf("ary"));
diff --git a/test/BUILD.gn b/test/BUILD.gn
index a8a6cd1..fa6e2a7 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -146,7 +146,6 @@
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 @@
"../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",