blob: 6560a9460947f4241073d55502228b1819a9f1c6 [file] [log] [blame]
Dan Sinclair6e581892020-03-02 15:47:43 -05001// 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 Claytona996ffb2022-02-02 23:07:11 +000015#ifndef SRC_AST_BINDING_ATTRIBUTE_H_
16#define SRC_AST_BINDING_ATTRIBUTE_H_
Dan Sinclair6e581892020-03-02 15:47:43 -050017
Ben Clayton241c16d2021-06-09 18:53:57 +000018#include <string>
19
Ben Claytona996ffb2022-02-02 23:07:11 +000020#include "src/ast/attribute.h"
Dan Sinclair6e581892020-03-02 15:47:43 -050021
22namespace tint {
23namespace ast {
24
Ben Claytona996ffb2022-02-02 23:07:11 +000025/// A binding attribute
26class BindingAttribute : public Castable<BindingAttribute, Attribute> {
Dan Sinclair6e581892020-03-02 15:47:43 -050027 public:
Ben Claytona996ffb2022-02-02 23:07:11 +000028 /// Constructor
Ben Clayton4f3ff572021-10-15 17:33:10 +000029 /// @param pid the identifier of the program that owns this node
30 /// @param src the source of this node
Ben Claytone6995de2021-04-13 23:27:27 +000031 /// @param value the binding value
Ben Claytona996ffb2022-02-02 23:07:11 +000032 BindingAttribute(ProgramID pid, const Source& src, uint32_t value);
33 ~BindingAttribute() override;
Dan Sinclair6e581892020-03-02 15:47:43 -050034
Ben Claytona996ffb2022-02-02 23:07:11 +000035 /// @returns the WGSL name for the attribute
Ben Clayton4f3ff572021-10-15 17:33:10 +000036 std::string Name() const override;
Ben Clayton241c16d2021-06-09 18:53:57 +000037
Ben Claytoned2b9782020-12-01 18:04:17 +000038 /// Clones this node and all transitive child nodes using the `CloneContext`
39 /// `ctx`.
Ben Claytoned2b9782020-12-01 18:04:17 +000040 /// @param ctx the clone context
41 /// @return the newly cloned node
Ben Claytona996ffb2022-02-02 23:07:11 +000042 const BindingAttribute* Clone(CloneContext* ctx) const override;
Ben Claytoned2b9782020-12-01 18:04:17 +000043
Ben Clayton4f3ff572021-10-15 17:33:10 +000044 /// the binding value
Ben Clayton86481202021-10-19 18:38:54 +000045 const uint32_t value;
Dan Sinclair6e581892020-03-02 15:47:43 -050046};
47
48} // namespace ast
49} // namespace tint
50
Ben Claytona996ffb2022-02-02 23:07:11 +000051#endif // SRC_AST_BINDING_ATTRIBUTE_H_