blob: 58f93d0bd3ba9d94e25b88caa8348d39397876bf [file] [log] [blame]
Dan Sinclair6e581892020-03-02 15:47:43 -05001// 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_AST_MEMBER_ACCESSOR_EXPRESSION_H_
16#define SRC_AST_MEMBER_ACCESSOR_EXPRESSION_H_
17
Dan Sinclair6e581892020-03-02 15:47:43 -050018#include "src/ast/identifier_expression.h"
Dan Sinclair6e581892020-03-02 15:47:43 -050019
20namespace tint {
21namespace ast {
22
23/// A member accessor expression
Ben Claytone319d7f2020-11-30 23:30:58 +000024class MemberAccessorExpression
25 : public Castable<MemberAccessorExpression, Expression> {
Dan Sinclair6e581892020-03-02 15:47:43 -050026 public:
27 /// Constructor
Ben Claytone6995de2021-04-13 23:27:27 +000028 /// @param program_id the identifier of the program that owns this node
dan sinclaira322f5d2020-03-30 22:46:06 +000029 /// @param source the member accessor expression source
Dan Sinclair6e581892020-03-02 15:47:43 -050030 /// @param structure the structure
31 /// @param member the member
Ben Claytone6995de2021-04-13 23:27:27 +000032 MemberAccessorExpression(ProgramID program_id,
33 const Source& source,
Ben Clayton86481202021-10-19 18:38:54 +000034 const Expression* structure,
35 const IdentifierExpression* member);
Dan Sinclair6e581892020-03-02 15:47:43 -050036 /// Move constructor
Ryan Harrison4d32be42020-04-09 18:52:06 +000037 MemberAccessorExpression(MemberAccessorExpression&&);
Dan Sinclair6e581892020-03-02 15:47:43 -050038 ~MemberAccessorExpression() override;
39
Ben Claytoned2b9782020-12-01 18:04:17 +000040 /// Clones this node and all transitive child nodes using the `CloneContext`
41 /// `ctx`.
Ben Claytoned2b9782020-12-01 18:04:17 +000042 /// @param ctx the clone context
43 /// @return the newly cloned node
Ben Clayton86481202021-10-19 18:38:54 +000044 const MemberAccessorExpression* Clone(CloneContext* ctx) const override;
Ben Claytoned2b9782020-12-01 18:04:17 +000045
Ben Clayton4f3ff572021-10-15 17:33:10 +000046 /// The structure
Ben Clayton86481202021-10-19 18:38:54 +000047 const Expression* const structure;
Ben Clayton4f3ff572021-10-15 17:33:10 +000048
49 /// The member expression
Ben Clayton86481202021-10-19 18:38:54 +000050 const IdentifierExpression* const member;
Dan Sinclair6e581892020-03-02 15:47:43 -050051};
52
53} // namespace ast
54} // namespace tint
55
56#endif // SRC_AST_MEMBER_ACCESSOR_EXPRESSION_H_