ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 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 | */ |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 7 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 8 | #ifndef SKSL_ASTPREFIXEXPRESSION |
| 9 | #define SKSL_ASTPREFIXEXPRESSION |
| 10 | |
| 11 | #include "SkSLASTExpression.h" |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 12 | #include "../SkSLCompiler.h" |
| 13 | #include "../SkSLLexer.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 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 { |
| 21 | ASTPrefixExpression(Token op, std::unique_ptr<ASTExpression> operand) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 22 | : INHERITED(op.fOffset, kPrefix_Kind) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 23 | , fOperator(op.fKind) |
| 24 | , fOperand(std::move(operand)) {} |
| 25 | |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 26 | String description() const override { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 27 | return Compiler::OperatorName(fOperator) + fOperand->description(); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 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 |