Flutter Engine
The Flutter Engine
|
#include <SkSLExpression.h>
Public Types | |
enum class | ComparisonResult { kUnknown = -1 , kNotEqual , kEqual } |
using | Kind = ExpressionKind |
Public Member Functions | |
Expression (Position pos, Kind kind, const Type *type) | |
Kind | kind () const |
const Type & | type () const |
bool | isAnyConstructor () const |
bool | isIntLiteral () const |
bool | isFloatLiteral () const |
bool | isBoolLiteral () const |
AnyConstructor & | asAnyConstructor () |
const AnyConstructor & | asAnyConstructor () 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< Expression > | clone (Position pos) const =0 |
std::unique_ptr< Expression > | clone () 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 | |
IRNode & | operator= (const IRNode &)=delete |
Position | position () const |
void | setPosition (Position p) |
template<typename T > | |
bool | is () const |
template<typename T > | |
const T & | as () const |
template<typename T > | |
T & | as () |
Additional Inherited Members | |
Static Public Member Functions inherited from SkSL::Poolable | |
static void * | operator new (const size_t size) |
static void | operator delete (void *ptr) |
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 |
Abstract supertype of all expressions.
Definition at line 30 of file SkSLExpression.h.
using SkSL::Expression::Kind = ExpressionKind |
Definition at line 32 of file SkSLExpression.h.
|
strong |
Compares this constant expression against another constant expression. Returns kUnknown if we aren't able to deduce a result (an expression isn't actually constant, the types are mismatched, etc).
Enumerator | |
---|---|
kUnknown | |
kNotEqual | |
kEqual |
Definition at line 81 of file SkSLExpression.h.
Definition at line 34 of file SkSLExpression.h.
AnyConstructor & SkSL::Expression::asAnyConstructor | ( | ) |
Definition at line 218 of file SkSLConstructor.cpp.
const AnyConstructor & SkSL::Expression::asAnyConstructor | ( | ) | const |
Definition at line 223 of file SkSLConstructor.cpp.
|
inline |
|
pure virtual |
Implemented in SkSL::BinaryExpression, SkSL::ChildCall, SkSL::ConstructorArray, SkSL::ConstructorArrayCast, SkSL::ConstructorCompound, SkSL::ConstructorCompoundCast, SkSL::ConstructorDiagonalMatrix, SkSL::ConstructorMatrixResize, SkSL::ConstructorScalarCast, SkSL::ConstructorSplat, SkSL::ConstructorStruct, SkSL::EmptyExpression, SkSL::FieldAccess, SkSL::FunctionCall, SkSL::FunctionReference, SkSL::IndexExpression, SkSL::Literal, SkSL::MethodReference, SkSL::Poison, SkSL::PostfixExpression, SkSL::PrefixExpression, SkSL::Setting, SkSL::Swizzle, SkSL::TernaryExpression, SkSL::TypeReference, and SkSL::VariableReference.
|
inline |
Definition at line 90 of file SkSLExpression.h.
|
inlinevirtual |
Reimplemented in SkSL::AnyConstructor, and SkSL::Literal.
Definition at line 86 of file SkSLExpression.h.
|
finalvirtual |
Returns a description of the expression.
Implements SkSL::IRNode.
Definition at line 18 of file SkSLExpression.cpp.
|
pure virtual |
Implemented in SkSL::BinaryExpression, SkSL::PostfixExpression, SkSL::PrefixExpression, SkSL::TernaryExpression, SkSL::ChildCall, SkSL::AnyConstructor, SkSL::EmptyExpression, SkSL::FieldAccess, SkSL::FunctionCall, SkSL::FunctionReference, SkSL::IndexExpression, SkSL::Literal, SkSL::MethodReference, SkSL::Poison, SkSL::Setting, SkSL::Swizzle, SkSL::TypeReference, and SkSL::VariableReference.
|
inlinevirtual |
Returns the n'th compile-time constant value within a literal or constructor. Use Type::slotCount to determine the number of slots within an expression. Slots which do not contain compile-time constant values will return nullopt. vec4(1, vec2(2), 3)
contains four compile-time constants: (1, 2, 2, 3) mat2(f)
contains four slots, and two are constant: (nullopt, 0, 0, nullopt) All classes which override this function must also implement supportsConstantValues
.
Reimplemented in SkSL::AnyConstructor, SkSL::ConstructorDiagonalMatrix, SkSL::ConstructorMatrixResize, SkSL::ConstructorSplat, and SkSL::Literal.
Definition at line 116 of file SkSLExpression.h.
|
inline |
Definition at line 48 of file SkSLExpression.h.
|
inline |
Definition at line 62 of file SkSLExpression.h.
|
inline |
Definition at line 58 of file SkSLExpression.h.
bool SkSL::Expression::isIncomplete | ( | const Context & | context | ) | const |
Returns true if this expression is incomplete. Specifically, dangling function/method-call references that were never invoked, or type references that were never constructed, are considered incomplete expressions and should result in an error.
Definition at line 22 of file SkSLExpression.cpp.
|
inline |
Definition at line 54 of file SkSLExpression.h.
|
inline |
Definition at line 40 of file SkSLExpression.h.
|
inlinevirtual |
Returns true if this expression type supports getConstantValue
. (This particular expression may or may not actually contain a constant value.) It's harmless to call getConstantValue
on expressions which don't support constant values or don't contain any constant values, but if supportsConstantValues
returns false, you can assume that getConstantValue
will return nullopt for every slot of this expression. This allows for early-out opportunities in some cases. (Some expressions have tons of slots but never hold a constant value; e.g. a variable holding a very large array.)
Reimplemented in SkSL::AnyConstructor, SkSL::ConstructorDiagonalMatrix, SkSL::ConstructorMatrixResize, SkSL::ConstructorSplat, and SkSL::Literal.
Definition at line 103 of file SkSLExpression.h.
|
inline |
Definition at line 44 of file SkSLExpression.h.