tint/sem: Add Declaration() override for IndexAccessorExpression

Convenience overload to return ast::IndexAccessorExpression instead of ast::Expression

Change-Id: Ib239fd6d5742425a629fc76e1b564a3c7781ca2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122342
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
Ben Clayton 2023-03-02 18:29:38 +00:00 committed by Dawn LUCI CQ
parent 1edc272904
commit d7ee9c1510
1 changed files with 6 additions and 5 deletions

View File

@ -17,13 +17,9 @@
#include <vector> #include <vector>
#include "src/tint/ast/index_accessor_expression.h"
#include "src/tint/sem/value_expression.h" #include "src/tint/sem/value_expression.h"
// Forward declarations
namespace tint::ast {
class IndexAccessorExpression;
} // namespace tint::ast
namespace tint::sem { namespace tint::sem {
/// IndexAccessorExpression holds the semantic information for a ast::IndexAccessorExpression node. /// IndexAccessorExpression holds the semantic information for a ast::IndexAccessorExpression node.
@ -52,6 +48,11 @@ class IndexAccessorExpression final : public Castable<IndexAccessorExpression, V
/// Destructor /// Destructor
~IndexAccessorExpression() override; ~IndexAccessorExpression() override;
/// @returns the AST node
const ast::IndexAccessorExpression* Declaration() const {
return static_cast<const ast::IndexAccessorExpression*>(declaration_);
}
/// @returns the object expression that is being indexed /// @returns the object expression that is being indexed
ValueExpression const* Object() const { return object_; } ValueExpression const* Object() const { return object_; }