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 { NullLiteralNullLiteral20 NullLiteral(const Context& context, int offset) 21 : INHERITED(offset, kNullLiteral_Kind, *context.fNull_Type) {} 22 NullLiteralNullLiteral23 NullLiteral(int offset, const Type& type) 24 : INHERITED(offset, kNullLiteral_Kind, type) {} 25 descriptionNullLiteral26 String description() const override { 27 return "null"; 28 } 29 hasSideEffectsNullLiteral30 bool hasSideEffects() const override { 31 return false; 32 } 33 isConstantNullLiteral34 bool isConstant() const override { 35 return true; 36 } 37 compareConstantNullLiteral38 bool compareConstant(const Context& context, const Expression& other) const override { 39 return true; 40 } 41 cloneNullLiteral42 std::unique_ptr<Expression> clone() const override { 43 return std::unique_ptr<Expression>(new NullLiteral(fOffset, fType)); 44 } 45 46 typedef Expression INHERITED; 47 }; 48 49 } // namespace 50 51 #endif 52