blob: 0403a2f1721af4a51a2613edb30e1a942ba441b7 [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_ASTPREFIXEXPRESSION
9#define SKSL_ASTPREFIXEXPRESSION
10
11#include "SkSLASTExpression.h"
Ethan Nicholas5b5f0962017-09-11 13:50:14 -070012#include "../SkSLCompiler.h"
13#include "../SkSLLexer.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070014
15namespace SkSL {
16
17/**
18 * An expression modified by a unary operator appearing in front of it, such as '-x' or '!inside'.
19 */
20struct ASTPrefixExpression : public ASTExpression {
21 ASTPrefixExpression(Token op, std::unique_ptr<ASTExpression> operand)
Ethan Nicholas5b5f0962017-09-11 13:50:14 -070022 : INHERITED(op.fOffset, kPrefix_Kind)
ethannicholasb3058bd2016-07-01 08:22:01 -070023 , fOperator(op.fKind)
24 , fOperand(std::move(operand)) {}
25
Ethan Nicholas0df1b042017-03-31 13:56:23 -040026 String description() const override {
Ethan Nicholas5b5f0962017-09-11 13:50:14 -070027 return Compiler::OperatorName(fOperator) + fOperand->description();
ethannicholasb3058bd2016-07-01 08:22:01 -070028 }
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