blob: e02555db709ac96e60ea99f54e9d96dba9f49917 [file] [log] [blame]
ethannicholasb3058bd2016-07-01 08:22:01 -07001/*
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 */
Ethan Nicholas0df1b042017-03-31 13:56:23 -04007
ethannicholasb3058bd2016-07-01 08:22:01 -07008#ifndef SKSL_POSTFIXEXPRESSION
9#define SKSL_POSTFIXEXPRESSION
10
11#include "SkSLExpression.h"
Hal Canary6b20a552017-02-07 14:09:38 -050012#include "SkSLToken.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070013
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->fPosition, kPostfix_Kind, operand->fType)
22 , fOperand(std::move(operand))
23 , fOperator(op) {}
24
Ethan Nicholascb670962017-04-20 19:31:52 -040025 bool hasSideEffects() const override {
26 return true;
27 }
28
29 String description() const override {
ethannicholasb3058bd2016-07-01 08:22:01 -070030 return fOperand->description() + Token::OperatorName(fOperator);
31 }
32
Ethan Nicholas86a43402017-01-19 13:32:00 -050033 std::unique_ptr<Expression> fOperand;
ethannicholasb3058bd2016-07-01 08:22:01 -070034 const Token::Kind fOperator;
35
36 typedef Expression INHERITED;
37};
38
39} // namespace
40
41#endif