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/override.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::Override); |
| 22 | |
| 23 | namespace tint::ast { |
| 24 | |
| 25 | Override::Override(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, |
| 28 | const Symbol& sym, |
| 29 | const ast::Type* ty, |
dan sinclair | 6e77b47 | 2022-10-20 13:38:28 +0000 | [diff] [blame] | 30 | const Expression* init, |
Ben Clayton | 783b169 | 2022-08-02 17:03:35 +0000 | [diff] [blame] | 31 | utils::VectorRef<const Attribute*> attrs) |
dan sinclair | 6e77b47 | 2022-10-20 13:38:28 +0000 | [diff] [blame] | 32 | : Base(pid, nid, src, sym, ty, init, std::move(attrs)) {} |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 33 | |
| 34 | Override::Override(Override&&) = default; |
| 35 | |
| 36 | Override::~Override() = default; |
| 37 | |
Ben Clayton | e48ef8e | 2022-06-26 10:52:50 +0000 | [diff] [blame] | 38 | const char* Override::Kind() const { |
| 39 | return "override"; |
| 40 | } |
| 41 | |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 42 | const Override* Override::Clone(CloneContext* ctx) const { |
| 43 | auto src = ctx->Clone(source); |
| 44 | auto sym = ctx->Clone(symbol); |
| 45 | auto* ty = ctx->Clone(type); |
dan sinclair | 6e77b47 | 2022-10-20 13:38:28 +0000 | [diff] [blame] | 46 | auto* init = ctx->Clone(initializer); |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 47 | auto attrs = ctx->Clone(attributes); |
dan sinclair | 6e77b47 | 2022-10-20 13:38:28 +0000 | [diff] [blame] | 48 | return ctx->dst->create<Override>(src, sym, ty, init, std::move(attrs)); |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Ben Clayton | dcdf66e | 2022-06-17 12:48:51 +0000 | [diff] [blame] | 51 | } // namespace tint::ast |