blob: fc616d74c4e8ba1513043133ef534ca4bfd66dda [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>
Ryan Harrisondbc13af2022-02-21 15:19:07 +000019
20#include "src/tint/ast/attribute.h"
21
Ben Claytona7230f02022-04-11 14:37:21 +000022// Forward declarations
dan sinclair34323ac2022-04-07 18:39:35 +000023namespace tint::ast {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000024class Type;
Ben Claytona7230f02022-04-11 14:37:21 +000025} // namespace tint::ast
26
27namespace tint::ast {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000028
29/// A struct member statement.
Ben Clayton41f8d2a2022-03-07 18:37:46 +000030class StructMember final : public Castable<StructMember, Node> {
dan sinclair41e4d9a2022-05-01 14:40:55 +000031 public:
32 /// Create a new struct member statement
33 /// @param pid the identifier of the program that owns this node
Ben Clayton4a92a3c2022-07-18 20:50:02 +000034 /// @param nid the unique node identifier
dan sinclair41e4d9a2022-05-01 14:40:55 +000035 /// @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,
Ben Clayton4a92a3c2022-07-18 20:50:02 +000040 NodeID nid,
dan sinclair41e4d9a2022-05-01 14:40:55 +000041 const Source& src,
42 const Symbol& sym,
43 const ast::Type* type,
Ben Clayton783b1692022-08-02 17:03:35 +000044 utils::VectorRef<const Attribute*> attributes);
dan sinclair41e4d9a2022-05-01 14:40:55 +000045 /// Move constructor
46 StructMember(StructMember&&);
Ryan Harrisondbc13af2022-02-21 15:19:07 +000047
dan sinclair41e4d9a2022-05-01 14:40:55 +000048 ~StructMember() override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000049
dan sinclair41e4d9a2022-05-01 14:40:55 +000050 /// Clones this node and all transitive child nodes using the `CloneContext`
51 /// `ctx`.
52 /// @param ctx the clone context
53 /// @return the newly cloned node
54 const StructMember* Clone(CloneContext* ctx) const override;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000055
dan sinclair41e4d9a2022-05-01 14:40:55 +000056 /// The symbol
57 const Symbol symbol;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000058
dan sinclair41e4d9a2022-05-01 14:40:55 +000059 /// The type
60 const ast::Type* const type;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000061
dan sinclair41e4d9a2022-05-01 14:40:55 +000062 /// The attributes
Ben Clayton783b1692022-08-02 17:03:35 +000063 const utils::Vector<const Attribute*, 4> attributes;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000064};
65
dan sinclair34323ac2022-04-07 18:39:35 +000066} // namespace tint::ast
Ryan Harrisondbc13af2022-02-21 15:19:07 +000067
68#endif // SRC_TINT_AST_STRUCT_MEMBER_H_