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 | |
| 15 | #include "src/ast/binding_decoration.h" |
| 16 | |
Ben Clayton | 1e29f4b | 2021-01-21 16:20:40 +0000 | [diff] [blame] | 17 | #include "src/clone_context.h" |
Ben Clayton | a6b9a8e | 2021-01-26 16:57:10 +0000 | [diff] [blame] | 18 | #include "src/program_builder.h" |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 19 | |
Ben Clayton | 89ea705 | 2020-12-02 18:19:28 +0000 | [diff] [blame] | 20 | TINT_INSTANTIATE_CLASS_ID(tint::ast::BindingDecoration); |
| 21 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 22 | namespace tint { |
| 23 | namespace ast { |
| 24 | |
Ben Clayton | 5aad70a | 2020-12-14 21:10:07 +0000 | [diff] [blame] | 25 | BindingDecoration::BindingDecoration(const Source& source, uint32_t val) |
Ben Clayton | e319d7f | 2020-11-30 23:30:58 +0000 | [diff] [blame] | 26 | : Base(source), value_(val) {} |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 27 | |
| 28 | BindingDecoration::~BindingDecoration() = default; |
| 29 | |
Ben Clayton | dd1b6fc | 2021-01-29 10:55:40 +0000 | [diff] [blame] | 30 | void BindingDecoration::to_str(const semantic::Info&, |
| 31 | std::ostream& out, |
| 32 | size_t indent) const { |
Ben Clayton | 6f58546 | 2020-11-13 21:43:58 +0000 | [diff] [blame] | 33 | make_indent(out, indent); |
Dan Sinclair | 3a1368d | 2020-03-10 17:47:56 +0000 | [diff] [blame] | 34 | out << "BindingDecoration{" << value_ << "}" << std::endl; |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 35 | } |
| 36 | |
Ben Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 37 | BindingDecoration* BindingDecoration::Clone(CloneContext* ctx) const { |
Ben Clayton | 545c974 | 2021-02-11 20:27:14 +0000 | [diff] [blame^] | 38 | // 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 Clayton | ed2b978 | 2020-12-01 18:04:17 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 43 | } // namespace ast |
| 44 | } // namespace tint |