Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 1 | // 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 Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 18 | #include "src/ast/identifier_expression.h" |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 19 | |
| 20 | namespace tint { |
| 21 | namespace ast { |
| 22 | |
| 23 | /// A member accessor expression |
Ben Clayton | e319d7f | 2020-11-30 23:30:58 +0000 | [diff] [blame] | 24 | class MemberAccessorExpression |
| 25 | : public Castable<MemberAccessorExpression, Expression> { |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 26 | public: |
| 27 | /// Constructor |
Ben Clayton | e6995de | 2021-04-13 23:27:27 +0000 | [diff] [blame] | 28 | /// @param program_id the identifier of the program that owns this node |
dan sinclair | a322f5d | 2020-03-30 22:46:06 +0000 | [diff] [blame] | 29 | /// @param source the member accessor expression source |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 30 | /// @param structure the structure |
| 31 | /// @param member the member |
Ben Clayton | e6995de | 2021-04-13 23:27:27 +0000 | [diff] [blame] | 32 | MemberAccessorExpression(ProgramID program_id, |
| 33 | const Source& source, |
Ben Clayton | 8648120 | 2021-10-19 18:38:54 +0000 | [diff] [blame] | 34 | const Expression* structure, |
| 35 | const IdentifierExpression* member); |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 36 | /// Move constructor |
Ryan Harrison | 4d32be4 | 2020-04-09 18:52:06 +0000 | [diff] [blame] | 37 | MemberAccessorExpression(MemberAccessorExpression&&); |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 38 | ~MemberAccessorExpression() override; |
| 39 | |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 40 | /// Clones this node and all transitive child nodes using the `CloneContext` |
| 41 | /// `ctx`. |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 42 | /// @param ctx the clone context |
| 43 | /// @return the newly cloned node |
Ben Clayton | 8648120 | 2021-10-19 18:38:54 +0000 | [diff] [blame] | 44 | const MemberAccessorExpression* Clone(CloneContext* ctx) const override; |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 45 | |
Ben Clayton | 4f3ff57 | 2021-10-15 17:33:10 +0000 | [diff] [blame] | 46 | /// The structure |
Ben Clayton | 8648120 | 2021-10-19 18:38:54 +0000 | [diff] [blame] | 47 | const Expression* const structure; |
Ben Clayton | 4f3ff57 | 2021-10-15 17:33:10 +0000 | [diff] [blame] | 48 | |
| 49 | /// The member expression |
Ben Clayton | 8648120 | 2021-10-19 18:38:54 +0000 | [diff] [blame] | 50 | const IdentifierExpression* const member; |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | } // namespace ast |
| 54 | } // namespace tint |
| 55 | |
| 56 | #endif // SRC_AST_MEMBER_ACCESSOR_EXPRESSION_H_ |