blob: 022a34cafe4446038c93ad3c3ee90befd401f634 [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_STRUCT_MEMBER_H_
16#define SRC_TINT_AST_STRUCT_MEMBER_H_
17
18#include <utility>
19#include <vector>
20
21#include "src/tint/ast/attribute.h"
22
Ben Claytona7230f02022-04-11 14:37:21 +000023// Forward declarations
dan sinclair34323ac2022-04-07 18:39:35 +000024namespace tint::ast {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000025class Type;
Ben Claytona7230f02022-04-11 14:37:21 +000026} // namespace tint::ast
27
28namespace tint::ast {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000029
30/// A struct member statement.
Ben Clayton41f8d2a2022-03-07 18:37:46 +000031class StructMember final : public Castable<StructMember, Node> {
dan sinclair41e4d9a2022-05-01 14:40:55 +000032 public:
33 /// Create a new struct member statement
34 /// @param pid the identifier of the program that owns this node
35 /// @param src the source of this node for the struct member statement
36 /// @param sym The struct member symbol
37 /// @param type The struct member type
38 /// @param attributes The struct member attributes
39 StructMember(ProgramID pid,
40 const Source& src,
41 const Symbol& sym,
42 const ast::Type* type,
43 AttributeList attributes);
44 /// Move constructor
45 StructMember(StructMember&&);
Ryan Harrisondbc13af2022-02-21 15:19:07 +000046
dan sinclair41e4d9a2022-05-01 14:40:55 +000047 ~StructMember() override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000048
dan sinclair41e4d9a2022-05-01 14:40:55 +000049 /// Clones this node and all transitive child nodes using the `CloneContext`
50 /// `ctx`.
51 /// @param ctx the clone context
52 /// @return the newly cloned node
53 const StructMember* Clone(CloneContext* ctx) const override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000054
dan sinclair41e4d9a2022-05-01 14:40:55 +000055 /// The symbol
56 const Symbol symbol;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000057
dan sinclair41e4d9a2022-05-01 14:40:55 +000058 /// The type
59 const ast::Type* const type;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000060
dan sinclair41e4d9a2022-05-01 14:40:55 +000061 /// The attributes
62 const AttributeList attributes;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000063};
64
65/// A list of struct members
66using StructMemberList = std::vector<const StructMember*>;
67
dan sinclair34323ac2022-04-07 18:39:35 +000068} // namespace tint::ast
Ryan Harrisondbc13af2022-02-21 15:19:07 +000069
70#endif // SRC_TINT_AST_STRUCT_MEMBER_H_