1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SKSL_NULLLITERAL
9#define SKSL_NULLLITERAL
10
11#include "src/sksl/SkSLContext.h"
12#include "src/sksl/ir/SkSLExpression.h"
13
14namespace SkSL {
15
16/**
17 * Represents 'null'.
18 */
19struct NullLiteral : public Expression {
20 NullLiteral(const Context& context, int offset)
21 : INHERITED(offset, kNullLiteral_Kind, *context.fNull_Type) {}
22
23 NullLiteral(int offset, const Type& type)
24 : INHERITED(offset, kNullLiteral_Kind, type) {}
25
26 String description() const override {
27 return "null";
28 }
29
30 bool hasProperty(Property property) const override {
31 return false;
32 }
33
34 bool isCompileTimeConstant() const override {
35 return true;
36 }
37
38 bool compareConstant(const Context& context, const Expression& other) const override {
39 return true;
40 }
41
42 int nodeCount() const override {
43 return 1;
44 }
45
46 std::unique_ptr<Expression> clone() const override {
47 return std::unique_ptr<Expression>(new NullLiteral(fOffset, fType));
48 }
49
50 typedef Expression INHERITED;
51};
52
53} // namespace SkSL
54
55#endif
56