Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
 
virtual 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
 
std::unique_ptr< Expressionclone () const
 
std::string description () const final
 
- Public Member Functions inherited from SkSL::IRNode
virtual ~IRNode ()
 
 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 const Type& baseType = base->type();
25 if (!baseType.isNumber()) {
26 context.fErrors->error(pos, "'" + std::string(op.tightOperatorName()) +
27 "' cannot operate on '" + baseType.displayName() + "'");
28 return nullptr;
29 }
31 context.fErrors)) {
32 return nullptr;
33 }
34 return PostfixExpression::Make(context, pos, std::move(base), op);
35}
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 46 of file SkSLPostfixExpression.cpp.

46 {
47 bool needsParens = (OperatorPrecedence::kPostfix >= parentPrecedence);
48 return std::string(needsParens ? "(" : "") +
50 std::string(this->getOperator().tightOperatorName()) +
51 std::string(needsParens ? ")" : "");
52}
std::string description() const final
OperatorPrecedence
Definition ref_ptr.h:256

◆ 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 37 of file SkSLPostfixExpression.cpp.

40 {
41 SkASSERT(base->type().isNumber());
43 return std::make_unique<PostfixExpression>(pos, std::move(base), op);
44}
#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: