blob: 055d33db662db5ce0b0ac25026dfba8a41e3a39b [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/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
24namespace tint {
25namespace ast {
26
27Literal::Literal() = default;
28
29Literal::~Literal() = default;
30
31BoolLiteral* Literal::AsBool() {
32 assert(IsBool());
33 return static_cast<BoolLiteral*>(this);
34}
35
36FloatLiteral* Literal::AsFloat() {
37 assert(IsFloat());
38 return static_cast<FloatLiteral*>(this);
39}
40
41IntLiteral* Literal::AsInt() {
42 assert(IsInt());
43 return static_cast<IntLiteral*>(this);
44}
45
46UintLiteral* Literal::AsUint() {
47 assert(IsUint());
48 return static_cast<UintLiteral*>(this);
49}
50
51} // namespace ast
52} // namespace tint