Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkSL::PostfixExpression Class Referencefinal

#include <SkSLPostfixExpression.h>

Inheritance diagram for SkSL::PostfixExpression:
SkSL::Expression SkSL::IRNode SkSL::Poolable

Public Member Functions

 PostfixExpression (Position pos, std::unique_ptr< Expression > operand, Operator op)
 
Operator getOperator () const
 
std::unique_ptr< Expression > & operand ()
 
const std::unique_ptr< Expression > & operand () const
 
std::unique_ptr< Expressionclone (Position pos) const override
 
std::string description (OperatorPrecedence parentPrecedence) const override
 
- Public Member Functions inherited from SkSL::Expression
 Expression (Position pos, Kind kind, const Type *type)
 
Kind kind () const
 
const Typetype () const
 
bool isAnyConstructor () const
 
bool isIntLiteral () const
 
bool isFloatLiteral () const
 
bool isBoolLiteral () const
 
AnyConstructorasAnyConstructor ()
 
const AnyConstructorasAnyConstructor () const
 
bool isIncomplete (const Context &context) const
 
virtual ComparisonResult compareConstant (const Expression &other) const
 
CoercionCost coercionCost (const Type &target) const
 
virtual bool supportsConstantValues () const
 
virtual std::optional< double > getConstantValue (int n) const
 
virtual std::unique_ptr< Expressionclone (Position pos) const =0
 
std::unique_ptr< Expressionclone () const
 
std::string description () const final
 
virtual std::string description (OperatorPrecedence parentPrecedence) const =0
 
- Public Member Functions inherited from SkSL::IRNode
virtual ~IRNode ()
 
virtual std::string description () const =0
 
 IRNode (const IRNode &)=delete
 
IRNodeoperator= (const IRNode &)=delete
 
Position position () const
 
void setPosition (Position p)
 
template<typename T >
bool is () const
 
template<typename T >
const Tas () const
 
template<typename T >
Tas ()
 

Static Public Member Functions

static std::unique_ptr< ExpressionConvert (const Context &context, Position pos, std::unique_ptr< Expression > base, Operator op)
 
static std::unique_ptr< ExpressionMake (const Context &context, Position pos, std::unique_ptr< Expression > base, Operator op)
 
- Static Public Member Functions inherited from SkSL::Poolable
static void * operator new (const size_t size)
 
static void operator delete (void *ptr)
 

Static Public Attributes

static constexpr Kind kIRNodeKind = Kind::kPostfix
 

Additional Inherited Members

- Public Types inherited from SkSL::Expression
enum class  ComparisonResult { kUnknown = -1 , kNotEqual , kEqual }
 
using Kind = ExpressionKind
 
- Public Attributes inherited from SkSL::IRNode
Position fPosition
 
- Protected Member Functions inherited from SkSL::IRNode
 IRNode (Position position, int kind)
 
- Protected Attributes inherited from SkSL::IRNode
int fKind
 

Detailed Description

An expression modified by a unary operator appearing after it, such as 'i++'.

Definition at line 27 of file SkSLPostfixExpression.h.

Constructor & Destructor Documentation

◆ PostfixExpression()

SkSL::PostfixExpression::PostfixExpression ( Position  pos,
std::unique_ptr< Expression operand,
Operator  op 
)
inline

Definition at line 31 of file SkSLPostfixExpression.h.

32 : INHERITED(pos, kIRNodeKind, &operand->type())
33 , fOperand(std::move(operand))
34 , fOperator(op) {}
SkPoint pos
static constexpr Kind kIRNodeKind
std::unique_ptr< Expression > & operand()

Member Function Documentation

◆ clone()

std::unique_ptr< Expression > SkSL::PostfixExpression::clone ( Position  pos) const
inlineoverridevirtual

Implements SkSL::Expression.

Definition at line 60 of file SkSLPostfixExpression.h.

60 {
61 return std::make_unique<PostfixExpression>(pos, this->operand()->clone(),
62 this->getOperator());
63 }
std::unique_ptr< Expression > clone() const

◆ Convert()

std::unique_ptr< Expression > SkSL::PostfixExpression::Convert ( const Context context,
Position  pos,
std::unique_ptr< Expression base,
Operator  op 
)
static

Definition at line 20 of file SkSLPostfixExpression.cpp.

23 {
24 if (base->type().isArray() || !base->type().componentType().isNumber()) {
25 context.fErrors->error(pos, "'" + std::string(op.tightOperatorName()) +
26 "' cannot operate on '" + base->type().displayName() + "'");
27 return nullptr;
28 }
30 context.fErrors)) {
31 return nullptr;
32 }
33 return PostfixExpression::Make(context, pos, std::move(base), op);
34}
static std::unique_ptr< Expression > Make(const Context &context, Position pos, std::unique_ptr< Expression > base, Operator op)
bool UpdateVariableRefKind(Expression *expr, VariableRefKind kind, ErrorReporter *errors=nullptr)

◆ description()

std::string SkSL::PostfixExpression::description ( OperatorPrecedence  parentPrecedence) const
overridevirtual

Implements SkSL::Expression.

Definition at line 45 of file SkSLPostfixExpression.cpp.

45 {
46 bool needsParens = (OperatorPrecedence::kPostfix >= parentPrecedence);
47 return std::string(needsParens ? "(" : "") +
48 this->operand()->description(OperatorPrecedence::kPostfix) +
49 std::string(this->getOperator().tightOperatorName()) +
50 std::string(needsParens ? ")" : "");
51}

◆ getOperator()

Operator SkSL::PostfixExpression::getOperator ( ) const
inline

Definition at line 48 of file SkSLPostfixExpression.h.

48 {
49 return fOperator;
50 }

◆ Make()

std::unique_ptr< Expression > SkSL::PostfixExpression::Make ( const Context context,
Position  pos,
std::unique_ptr< Expression base,
Operator  op 
)
static

Definition at line 36 of file SkSLPostfixExpression.cpp.

39 {
40 SkASSERT(!base->type().isArray() && base->type().componentType().isNumber());
42 return std::make_unique<PostfixExpression>(pos, std::move(base), op);
43}
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool IsAssignable(Expression &expr, AssignmentInfo *info=nullptr, ErrorReporter *errors=nullptr)

◆ operand() [1/2]

std::unique_ptr< Expression > & SkSL::PostfixExpression::operand ( )
inline

Definition at line 52 of file SkSLPostfixExpression.h.

52 {
53 return fOperand;
54 }

◆ operand() [2/2]

const std::unique_ptr< Expression > & SkSL::PostfixExpression::operand ( ) const
inline

Definition at line 56 of file SkSLPostfixExpression.h.

56 {
57 return fOperand;
58 }

Member Data Documentation

◆ kIRNodeKind

constexpr Kind SkSL::PostfixExpression::kIRNodeKind = Kind::kPostfix
inlinestaticconstexpr

Definition at line 29 of file SkSLPostfixExpression.h.


The documentation for this class was generated from the following files: