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 "src/sksl/SkSLCompiler.h" 12 #include "src/sksl/SkSLLexer.h" 13 #include "src/sksl/ir/SkSLExpression.h" 14 15 namespace SkSL { 16 17 /** 18 * An expression modified by a unary operator appearing after it, such as 'i++'. 19 */ 20 struct PostfixExpression : public Expression { PostfixExpressionPostfixExpression21 PostfixExpression(std::unique_ptr<Expression> operand, Token::Kind op) 22 : INHERITED(operand->fOffset, kPostfix_Kind, operand->fType) 23 , fOperand(std::move(operand)) 24 , fOperator(op) {} 25 hasSideEffectsPostfixExpression26 bool hasSideEffects() const override { 27 return true; 28 } 29 clonePostfixExpression30 std::unique_ptr<Expression> clone() const override { 31 return std::unique_ptr<Expression>(new PostfixExpression(fOperand->clone(), fOperator)); 32 } 33 descriptionPostfixExpression34 String description() const override { 35 return fOperand->description() + Compiler::OperatorName(fOperator); 36 } 37 38 std::unique_ptr<Expression> fOperand; 39 const Token::Kind fOperator; 40 41 typedef Expression INHERITED; 42 }; 43 44 } // namespace 45 46 #endif 47