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