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>
This commit is contained in:
Ben Clayton
2021-11-09 09:35:00 +00:00
committed by Ben Clayton
parent 30848b6594
commit a838bb718b
51 changed files with 223 additions and 226 deletions

View File

@@ -851,7 +851,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) {
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>()) {

View File

@@ -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<sem::StructMemberAccess>(expr->array)) {
auto it = decomposed.find(access->Member()->Declaration());

View File

@@ -43,7 +43,7 @@ template <typename F>
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>()) {

View File

@@ -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::Array>(
sem.Get(accessor->array)->Type()->UnwrapRef())) {

View File

@@ -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",

View File

@@ -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<sem::Reference>();

View File

@@ -22,7 +22,7 @@
// Forward declarations
namespace tint {
namespace ast {
class ArrayAccessorExpression;
class IndexAccessorExpression;
class CallExpression;
} // namespace ast
} // namespace tint

View File

@@ -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::Array>(
sem.Get(accessor->array)->Type()->UnwrapRef())) {
if (wrapper(array)) {