Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 1 | // Copyright 2022 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/tint/ast/parameter.h" |
| 16 | |
Ben Clayton | 783b169 | 2022-08-02 17:03:35 +0000 | [diff] [blame] | 17 | #include <utility> |
| 18 | |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 19 | #include "src/tint/program_builder.h" |
| 20 | |
| 21 | TINT_INSTANTIATE_TYPEINFO(tint::ast::Parameter); |
| 22 | |
| 23 | namespace tint::ast { |
| 24 | |
| 25 | Parameter::Parameter(ProgramID pid, |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 26 | NodeID nid, |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 27 | const Source& src, |
Ben Clayton | 651d9e2 | 2023-02-09 10:34:14 +0000 | [diff] [blame^] | 28 | const Identifier* n, |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 29 | const ast::Type* ty, |
Ben Clayton | 783b169 | 2022-08-02 17:03:35 +0000 | [diff] [blame] | 30 | utils::VectorRef<const Attribute*> attrs) |
Ben Clayton | 651d9e2 | 2023-02-09 10:34:14 +0000 | [diff] [blame^] | 31 | : Base(pid, nid, src, n, ty, nullptr, std::move(attrs)) {} |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 32 | |
| 33 | Parameter::Parameter(Parameter&&) = default; |
| 34 | |
| 35 | Parameter::~Parameter() = default; |
| 36 | |
Ben Clayton | e48ef8e | 2022-06-26 10:52:50 +0000 | [diff] [blame] | 37 | const char* Parameter::Kind() const { |
| 38 | return "parameter"; |
| 39 | } |
| 40 | |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 41 | const Parameter* Parameter::Clone(CloneContext* ctx) const { |
| 42 | auto src = ctx->Clone(source); |
Ben Clayton | 651d9e2 | 2023-02-09 10:34:14 +0000 | [diff] [blame^] | 43 | auto* n = ctx->Clone(name); |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 44 | auto* ty = ctx->Clone(type); |
| 45 | auto attrs = ctx->Clone(attributes); |
Ben Clayton | 651d9e2 | 2023-02-09 10:34:14 +0000 | [diff] [blame^] | 46 | return ctx->dst->create<Parameter>(src, n, ty, std::move(attrs)); |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | } // namespace tint::ast |