blob: 5ae36b172d368db7b6a4a836f163d2eced9d1ec8 [file] [log] [blame]
Ryan Harrisondbc13af2022-02-21 15:19:07 +00001// Copyright 2020 The Tint Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef SRC_TINT_AST_MEMBER_ACCESSOR_EXPRESSION_H_
16#define SRC_TINT_AST_MEMBER_ACCESSOR_EXPRESSION_H_
17
Ben Claytonad315652023-02-05 12:36:50 +000018#include "src/tint/ast/accessor_expression.h"
Ryan Harrisondbc13af2022-02-21 15:19:07 +000019#include "src/tint/ast/identifier_expression.h"
20
dan sinclair34323ac2022-04-07 18:39:35 +000021namespace tint::ast {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000022
23/// A member accessor expression
Ben Claytonad315652023-02-05 12:36:50 +000024class MemberAccessorExpression final
dan sinclair12fa3032023-04-19 23:52:33 +000025 : public utils::Castable<MemberAccessorExpression, AccessorExpression> {
dan sinclair41e4d9a2022-05-01 14:40:55 +000026 public:
27 /// Constructor
Ben Clayton4a92a3c2022-07-18 20:50:02 +000028 /// @param pid the identifier of the program that owns this node
29 /// @param nid the unique node identifier
dan sinclair41e4d9a2022-05-01 14:40:55 +000030 /// @param source the member accessor expression source
Ben Claytonad315652023-02-05 12:36:50 +000031 /// @param object the object
dan sinclair41e4d9a2022-05-01 14:40:55 +000032 /// @param member the member
Ben Clayton4a92a3c2022-07-18 20:50:02 +000033 MemberAccessorExpression(ProgramID pid,
34 NodeID nid,
dan sinclair41e4d9a2022-05-01 14:40:55 +000035 const Source& source,
Ben Claytonad315652023-02-05 12:36:50 +000036 const Expression* object,
Ben Claytona4117ca2023-02-02 20:44:53 +000037 const Identifier* member);
Ben Clayton9a56b252023-03-15 14:09:40 +000038
39 /// Destructor
dan sinclair41e4d9a2022-05-01 14:40:55 +000040 ~MemberAccessorExpression() override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000041
dan sinclair41e4d9a2022-05-01 14:40:55 +000042 /// Clones this node and all transitive child nodes using the `CloneContext`
43 /// `ctx`.
44 /// @param ctx the clone context
45 /// @return the newly cloned node
46 const MemberAccessorExpression* Clone(CloneContext* ctx) const override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000047
dan sinclair41e4d9a2022-05-01 14:40:55 +000048 /// The member expression
Ben Claytona4117ca2023-02-02 20:44:53 +000049 const Identifier* const member;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000050};
51
dan sinclair34323ac2022-04-07 18:39:35 +000052} // namespace tint::ast
Ryan Harrisondbc13af2022-02-21 15:19:07 +000053
54#endif // SRC_TINT_AST_MEMBER_ACCESSOR_EXPRESSION_H_