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/literal.h" |
| 16 | |
| 17 | #include <assert.h> |
| 18 | |
| 19 | #include "src/ast/bool_literal.h" |
| 20 | #include "src/ast/float_literal.h" |
| 21 | #include "src/ast/int_literal.h" |
| 22 | #include "src/ast/uint_literal.h" |
| 23 | |
| 24 | namespace tint { |
| 25 | namespace ast { |
| 26 | |
| 27 | Literal::Literal() = default; |
| 28 | |
| 29 | Literal::~Literal() = default; |
| 30 | |
| 31 | BoolLiteral* Literal::AsBool() { |
| 32 | assert(IsBool()); |
| 33 | return static_cast<BoolLiteral*>(this); |
| 34 | } |
| 35 | |
| 36 | FloatLiteral* Literal::AsFloat() { |
| 37 | assert(IsFloat()); |
| 38 | return static_cast<FloatLiteral*>(this); |
| 39 | } |
| 40 | |
| 41 | IntLiteral* Literal::AsInt() { |
| 42 | assert(IsInt()); |
| 43 | return static_cast<IntLiteral*>(this); |
| 44 | } |
| 45 | |
| 46 | UintLiteral* Literal::AsUint() { |
| 47 | assert(IsUint()); |
| 48 | return static_cast<UintLiteral*>(this); |
| 49 | } |
| 50 | |
| 51 | } // namespace ast |
| 52 | } // namespace tint |