Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [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_TINT_AST_STRUCT_MEMBER_H_ |
| 16 | #define SRC_TINT_AST_STRUCT_MEMBER_H_ |
| 17 | |
| 18 | #include <utility> |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 19 | |
| 20 | #include "src/tint/ast/attribute.h" |
| 21 | |
Ben Clayton | a7230f0 | 2022-04-11 14:37:21 +0000 | [diff] [blame] | 22 | // Forward declarations |
dan sinclair | 34323ac | 2022-04-07 18:39:35 +0000 | [diff] [blame] | 23 | namespace tint::ast { |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 24 | class Type; |
Ben Clayton | a7230f0 | 2022-04-11 14:37:21 +0000 | [diff] [blame] | 25 | } // namespace tint::ast |
| 26 | |
| 27 | namespace tint::ast { |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 28 | |
| 29 | /// A struct member statement. |
Ben Clayton | 41f8d2a | 2022-03-07 18:37:46 +0000 | [diff] [blame] | 30 | class StructMember final : public Castable<StructMember, Node> { |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 31 | public: |
| 32 | /// Create a new struct member statement |
| 33 | /// @param pid the identifier of the program that owns this node |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 34 | /// @param nid the unique node identifier |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 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, |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 40 | NodeID nid, |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 41 | const Source& src, |
| 42 | const Symbol& sym, |
| 43 | const ast::Type* type, |
Ben Clayton | 783b169 | 2022-08-02 17:03:35 +0000 | [diff] [blame] | 44 | utils::VectorRef<const Attribute*> attributes); |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 45 | /// Move constructor |
| 46 | StructMember(StructMember&&); |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 47 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 48 | ~StructMember() override; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 49 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 50 | /// 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 Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 55 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 56 | /// The symbol |
| 57 | const Symbol symbol; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 58 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 59 | /// The type |
| 60 | const ast::Type* const type; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 61 | |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 62 | /// The attributes |
Ben Clayton | 783b169 | 2022-08-02 17:03:35 +0000 | [diff] [blame] | 63 | const utils::Vector<const Attribute*, 4> attributes; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
dan sinclair | 34323ac | 2022-04-07 18:39:35 +0000 | [diff] [blame] | 66 | } // namespace tint::ast |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 67 | |
| 68 | #endif // SRC_TINT_AST_STRUCT_MEMBER_H_ |