Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [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 | |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 15 | #ifndef SRC_AST_BINDING_ATTRIBUTE_H_ |
| 16 | #define SRC_AST_BINDING_ATTRIBUTE_H_ |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 17 | |
Ben Clayton | 241c16d | 2021-06-09 18:53:57 +0000 | [diff] [blame] | 18 | #include <string> |
| 19 | |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 20 | #include "src/ast/attribute.h" |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 21 | |
| 22 | namespace tint { |
| 23 | namespace ast { |
| 24 | |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 25 | /// A binding attribute |
| 26 | class BindingAttribute : public Castable<BindingAttribute, Attribute> { |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 27 | public: |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 28 | /// Constructor |
Ben Clayton | 4f3ff57 | 2021-10-15 17:33:10 +0000 | [diff] [blame] | 29 | /// @param pid the identifier of the program that owns this node |
| 30 | /// @param src the source of this node |
Ben Clayton | e6995de | 2021-04-13 23:27:27 +0000 | [diff] [blame] | 31 | /// @param value the binding value |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 32 | BindingAttribute(ProgramID pid, const Source& src, uint32_t value); |
| 33 | ~BindingAttribute() override; |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 34 | |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 35 | /// @returns the WGSL name for the attribute |
Ben Clayton | 4f3ff57 | 2021-10-15 17:33:10 +0000 | [diff] [blame] | 36 | std::string Name() const override; |
Ben Clayton | 241c16d | 2021-06-09 18:53:57 +0000 | [diff] [blame] | 37 | |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 38 | /// Clones this node and all transitive child nodes using the `CloneContext` |
| 39 | /// `ctx`. |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 40 | /// @param ctx the clone context |
| 41 | /// @return the newly cloned node |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 42 | const BindingAttribute* Clone(CloneContext* ctx) const override; |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 43 | |
Ben Clayton | 4f3ff57 | 2021-10-15 17:33:10 +0000 | [diff] [blame] | 44 | /// the binding value |
Ben Clayton | 8648120 | 2021-10-19 18:38:54 +0000 | [diff] [blame] | 45 | const uint32_t value; |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | } // namespace ast |
| 49 | } // namespace tint |
| 50 | |
Ben Clayton | a996ffb | 2022-02-02 23:07:11 +0000 | [diff] [blame] | 51 | #endif // SRC_AST_BINDING_ATTRIBUTE_H_ |