SkSLNullLiteral.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef SKSL_NULLLITERAL
  8. #define SKSL_NULLLITERAL
  9. #include "src/sksl/SkSLContext.h"
  10. #include "src/sksl/ir/SkSLExpression.h"
  11. namespace SkSL {
  12. /**
  13. * Represents 'null'.
  14. */
  15. struct NullLiteral : public Expression {
  16. NullLiteral(const Context& context, int offset)
  17. : INHERITED(offset, kNullLiteral_Kind, *context.fNull_Type) {}
  18. NullLiteral(int offset, const Type& type)
  19. : INHERITED(offset, kNullLiteral_Kind, type) {}
  20. String description() const override {
  21. return "null";
  22. }
  23. bool hasSideEffects() const override {
  24. return false;
  25. }
  26. bool isConstant() const override {
  27. return true;
  28. }
  29. bool compareConstant(const Context& context, const Expression& other) const override {
  30. return true;
  31. }
  32. std::unique_ptr<Expression> clone() const override {
  33. return std::unique_ptr<Expression>(new NullLiteral(fOffset, fType));
  34. }
  35. typedef Expression INHERITED;
  36. };
  37. } // namespace
  38. #endif