Home | History | Annotate | Download | only in ir
      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 "SkSLContext.h"
     12 #include "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     String description() const override {
     27         return "null";
     28     }
     29 
     30     bool hasSideEffects() const override {
     31         return false;
     32     }
     33 
     34     bool isConstant() const override {
     35         return true;
     36     }
     37 
     38     bool compareConstant(const Context& context, const Expression& other) const override {
     39         return true;
     40     }
     41 
     42     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