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_H_ 16 #define SRC_AST_STRUCT_H_ 17 18 #include <string> 19 #include <utility> 20 21 #include "src/ast/decoration.h" 22 #include "src/ast/struct_member.h" 23 #include "src/ast/type_decl.h" 24 25 namespace tint { 26 namespace ast { 27 28 /// A struct statement. 29 class Struct : public Castable<Struct, TypeDecl> { 30 public: 31 /// Create a new struct statement 32 /// @param pid the identifier of the program that owns this node 33 /// @param src the source of this node for the import statement 34 /// @param name The name of the structure 35 /// @param members The struct members 36 /// @param decorations The struct decorations 37 Struct(ProgramID pid, 38 const Source& src, 39 Symbol name, 40 StructMemberList members, 41 DecorationList decorations); 42 /// Move constructor 43 Struct(Struct&&); 44 45 ~Struct() override; 46 47 /// @returns true if the struct is block decorated 48 bool IsBlockDecorated() const; 49 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 Struct* Clone(CloneContext* ctx) const override; 55 56 /// The members 57 const StructMemberList members; 58 59 /// The struct decorations 60 const DecorationList decorations; 61 }; 62 63 } // namespace ast 64 } // namespace tint 65 66 #endif // SRC_AST_STRUCT_H_ 67