blob: f172eca96bf432c8bea1a0a3309167ac32d88ee5 [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
15#include "src/ast/binding_decoration.h"
16
Ben Clayton241c16d2021-06-09 18:53:57 +000017#include <string>
18
Ben Claytona6b9a8e2021-01-26 16:57:10 +000019#include "src/program_builder.h"
Ben Claytoned2b9782020-12-01 18:04:17 +000020
Ben Clayton7732ca52021-03-02 20:51:18 +000021TINT_INSTANTIATE_TYPEINFO(tint::ast::BindingDecoration);
Ben Clayton89ea7052020-12-02 18:19:28 +000022
Dan Sinclair6e581892020-03-02 15:47:43 -050023namespace tint {
24namespace ast {
25
Ben Claytone6995de2021-04-13 23:27:27 +000026BindingDecoration::BindingDecoration(ProgramID program_id,
27 const Source& source,
28 uint32_t val)
29 : Base(program_id, source), value_(val) {}
Dan Sinclair6e581892020-03-02 15:47:43 -050030
31BindingDecoration::~BindingDecoration() = default;
32
Ben Clayton241c16d2021-06-09 18:53:57 +000033std::string BindingDecoration::name() const {
34 return "binding";
35}
36
Antonio Maiorano5cd71b82021-04-16 19:07:51 +000037void BindingDecoration::to_str(const sem::Info&,
Ben Claytondd1b6fc2021-01-29 10:55:40 +000038 std::ostream& out,
39 size_t indent) const {
Ben Clayton6f585462020-11-13 21:43:58 +000040 make_indent(out, indent);
Dan Sinclair3a1368d2020-03-10 17:47:56 +000041 out << "BindingDecoration{" << value_ << "}" << std::endl;
Dan Sinclair6e581892020-03-02 15:47:43 -050042}
43
Ben Claytoned2b9782020-12-01 18:04:17 +000044BindingDecoration* BindingDecoration::Clone(CloneContext* ctx) const {
Ben Clayton545c9742021-02-11 20:27:14 +000045 // Clone arguments outside of create() call to have deterministic ordering
46 auto src = ctx->Clone(source());
47 return ctx->dst->create<BindingDecoration>(src, value_);
Ben Claytoned2b9782020-12-01 18:04:17 +000048}
49
Dan Sinclair6e581892020-03-02 15:47:43 -050050} // namespace ast
51} // namespace tint