blob: b15f023090a2565713940561119157ef25793df6 [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 Clayton1e29f4b2021-01-21 16:20:40 +000017#include "src/clone_context.h"
Ben Claytona6b9a8e2021-01-26 16:57:10 +000018#include "src/program_builder.h"
Ben Claytoned2b9782020-12-01 18:04:17 +000019
Ben Clayton89ea7052020-12-02 18:19:28 +000020TINT_INSTANTIATE_CLASS_ID(tint::ast::BindingDecoration);
21
Dan Sinclair6e581892020-03-02 15:47:43 -050022namespace tint {
23namespace ast {
24
Ben Clayton5aad70a2020-12-14 21:10:07 +000025BindingDecoration::BindingDecoration(const Source& source, uint32_t val)
Ben Claytone319d7f2020-11-30 23:30:58 +000026 : Base(source), value_(val) {}
Dan Sinclair6e581892020-03-02 15:47:43 -050027
28BindingDecoration::~BindingDecoration() = default;
29
Ben Claytondd1b6fc2021-01-29 10:55:40 +000030void BindingDecoration::to_str(const semantic::Info&,
31 std::ostream& out,
32 size_t indent) const {
Ben Clayton6f585462020-11-13 21:43:58 +000033 make_indent(out, indent);
Dan Sinclair3a1368d2020-03-10 17:47:56 +000034 out << "BindingDecoration{" << value_ << "}" << std::endl;
Dan Sinclair6e581892020-03-02 15:47:43 -050035}
36
Ben Claytoned2b9782020-12-01 18:04:17 +000037BindingDecoration* BindingDecoration::Clone(CloneContext* ctx) const {
Ben Clayton545c9742021-02-11 20:27:14 +000038 // Clone arguments outside of create() call to have deterministic ordering
39 auto src = ctx->Clone(source());
40 return ctx->dst->create<BindingDecoration>(src, value_);
Ben Claytoned2b9782020-12-01 18:04:17 +000041}
42
Dan Sinclair6e581892020-03-02 15:47:43 -050043} // namespace ast
44} // namespace tint