• 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_ASTPREFIXEXPRESSION
9 #define SKSL_ASTPREFIXEXPRESSION
10 
11 #include "SkSLASTExpression.h"
12 #include "../SkSLCompiler.h"
13 #include "../SkSLLexer.h"
14 
15 namespace SkSL {
16 
17 /**
18  * An expression modified by a unary operator appearing in front of it, such as '-x' or '!inside'.
19  */
20 struct ASTPrefixExpression : public ASTExpression {
ASTPrefixExpressionASTPrefixExpression21     ASTPrefixExpression(Token op, std::unique_ptr<ASTExpression> operand)
22     : INHERITED(op.fOffset, kPrefix_Kind)
23     , fOperator(op.fKind)
24     , fOperand(std::move(operand)) {}
25 
descriptionASTPrefixExpression26     String description() const override {
27         return Compiler::OperatorName(fOperator) + fOperand->description();
28     }
29 
30     const Token::Kind fOperator;
31     const std::unique_ptr<ASTExpression> fOperand;
32 
33     typedef ASTExpression INHERITED;
34 };
35 
36 } // namespace
37 
38 #endif
39