• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_STRUCT_MEMBER_H_
16 #define SRC_AST_STRUCT_MEMBER_H_
17 
18 #include <utility>
19 #include <vector>
20 
21 #include "src/ast/decoration.h"
22 
23 namespace tint {
24 namespace ast {
25 
26 // Forward declaration
27 class Type;
28 
29 /// A struct member statement.
30 class StructMember : public Castable<StructMember, Node> {
31  public:
32   /// Create a new struct member statement
33   /// @param pid the identifier of the program that owns this node
34   /// @param src the source of this node for the struct member statement
35   /// @param sym The struct member symbol
36   /// @param type The struct member type
37   /// @param decorations The struct member decorations
38   StructMember(ProgramID pid,
39                const Source& src,
40                const Symbol& sym,
41                const ast::Type* type,
42                DecorationList decorations);
43   /// Move constructor
44   StructMember(StructMember&&);
45 
46   ~StructMember() override;
47 
48   /// Clones this node and all transitive child nodes using the `CloneContext`
49   /// `ctx`.
50   /// @param ctx the clone context
51   /// @return the newly cloned node
52   const StructMember* Clone(CloneContext* ctx) const override;
53 
54   /// The symbol
55   const Symbol symbol;
56 
57   /// The type
58   const ast::Type* const type;
59 
60   /// The decorations
61   const DecorationList decorations;
62 };
63 
64 /// A list of struct members
65 using StructMemberList = std::vector<const StructMember*>;
66 
67 }  // namespace ast
68 }  // namespace tint
69 
70 #endif  // SRC_AST_STRUCT_MEMBER_H_
71