• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
hasPropertyPostfixExpression26     bool hasProperty(Property property) const override {
27         if (property == Property::kSideEffects) {
28             return true;
29         }
30         return fOperand->hasProperty(property);
31     }
32 
clonePostfixExpression33     std::unique_ptr<Expression> clone() const override {
34         return std::unique_ptr<Expression>(new PostfixExpression(fOperand->clone(), fOperator));
35     }
36 
37 #ifdef SK_DEBUG
descriptionPostfixExpression38     String description() const override {
39         return fOperand->description() + Compiler::OperatorName(fOperator);
40     }
41 #endif
42 
43     std::unique_ptr<Expression> fOperand;
44     const Token::Kind fOperator;
45 
46     typedef Expression INHERITED;
47 };
48 
49 } // namespace
50 
51 #endif
52