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 | |
14 | namespace SkSL { |
15 | |
16 | /** |
17 | * Represents 'null'. |
18 | */ |
19 | struct 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 | #ifdef SK_DEBUG |
27 | String description() const override { |
28 | return "null"; |
29 | } |
30 | #endif |
31 | |
32 | bool hasProperty(Property property) const override { |
33 | return false; |
34 | } |
35 | |
36 | bool isConstant() const override { |
37 | return true; |
38 | } |
39 | |
40 | bool compareConstant(const Context& context, const Expression& other) const override { |
41 | return true; |
42 | } |
43 | |
44 | std::unique_ptr<Expression> clone() const override { |
45 | return std::unique_ptr<Expression>(new NullLiteral(fOffset, fType)); |
46 | } |
47 | |
48 | typedef Expression INHERITED; |
49 | }; |
50 | |
51 | } // namespace |
52 | |
53 | #endif |
54 |