SkSLPostfixExpression.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_POSTFIXEXPRESSION
  8. #define SKSL_POSTFIXEXPRESSION
  9. #include "src/sksl/SkSLCompiler.h"
  10. #include "src/sksl/SkSLLexer.h"
  11. #include "src/sksl/ir/SkSLExpression.h"
  12. namespace SkSL {
  13. /**
  14. * An expression modified by a unary operator appearing after it, such as 'i++'.
  15. */
  16. struct PostfixExpression : public Expression {
  17. PostfixExpression(std::unique_ptr<Expression> operand, Token::Kind op)
  18. : INHERITED(operand->fOffset, kPostfix_Kind, operand->fType)
  19. , fOperand(std::move(operand))
  20. , fOperator(op) {}
  21. bool hasSideEffects() const override {
  22. return true;
  23. }
  24. std::unique_ptr<Expression> clone() const override {
  25. return std::unique_ptr<Expression>(new PostfixExpression(fOperand->clone(), fOperator));
  26. }
  27. String description() const override {
  28. return fOperand->description() + Compiler::OperatorName(fOperator);
  29. }
  30. std::unique_ptr<Expression> fOperand;
  31. const Token::Kind fOperator;
  32. typedef Expression INHERITED;
  33. };
  34. } // namespace
  35. #endif