Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkSL::ConstructorCompoundCast Class Referencefinal

#include <SkSLConstructorCompoundCast.h>

Inheritance diagram for SkSL::ConstructorCompoundCast:
SkSL::SingleArgumentConstructor SkSL::AnyConstructor SkSL::Expression SkSL::IRNode SkSL::Poolable

Public Member Functions

 ConstructorCompoundCast (Position pos, const Type &type, std::unique_ptr< Expression > arg)
 
std::unique_ptr< Expressionclone (Position pos) const override
 
- Public Member Functions inherited from SkSL::SingleArgumentConstructor
 SingleArgumentConstructor (Position pos, Kind kind, const Type *type, std::unique_ptr< Expression > argument)
 
std::unique_ptr< Expression > & argument ()
 
const std::unique_ptr< Expression > & argument () const
 
SkSpan< std::unique_ptr< Expression > > argumentSpan () final
 
SkSpan< const std::unique_ptr< Expression > > argumentSpan () const final
 
- Public Member Functions inherited from SkSL::AnyConstructor
 AnyConstructor (Position pos, Kind kind, const Type *type)
 
std::string description (OperatorPrecedence) const override
 
const TypecomponentType () const
 
bool supportsConstantValues () const override
 
std::optional< double > getConstantValue (int n) const override
 
ComparisonResult compareConstant (const Expression &other) 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
 
CoercionCost coercionCost (const Type &target) 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< ExpressionMake (const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
 
- 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::kConstructorCompoundCast
 

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

Represents the construction of a vector/matrix typecast, such as half3(myInt3) or float4x4(myHalf4x4). Matrix resizes are done in ConstructorMatrixResize, not here.

These always contain exactly 1 vector or matrix of matching size, and are never constant.

Definition at line 30 of file SkSLConstructorCompoundCast.h.

Constructor & Destructor Documentation

◆ ConstructorCompoundCast()

SkSL::ConstructorCompoundCast::ConstructorCompoundCast ( Position  pos,
const Type type,
std::unique_ptr< Expression arg 
)
inline

Definition at line 34 of file SkSLConstructorCompoundCast.h.

35 : INHERITED(pos, kIRNodeKind, &type, std::move(arg)) {}
SkPoint pos
virtual const Type & type() const

Member Function Documentation

◆ clone()

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

Implements SkSL::Expression.

Definition at line 42 of file SkSLConstructorCompoundCast.h.

42 {
43 return std::make_unique<ConstructorCompoundCast>(pos, this->type(), argument()->clone());
44 }
std::unique_ptr< Expression > clone() const
std::unique_ptr< Expression > & argument()

◆ Make()

std::unique_ptr< Expression > SkSL::ConstructorCompoundCast::Make ( const Context context,
Position  pos,
const Type type,
std::unique_ptr< Expression arg 
)
static

Definition at line 72 of file SkSLConstructorCompoundCast.cpp.

75 {
76 // Only vectors or matrices of the same dimensions are allowed.
79 SkASSERT(arg->type().isVector() == type.isVector());
80 SkASSERT(arg->type().isMatrix() == type.isMatrix());
81 SkASSERT(type.columns() == arg->type().columns());
82 SkASSERT(type.rows() == arg->type().rows());
83
84 // If this is a no-op cast, return the expression as-is.
85 if (type.matches(arg->type())) {
86 arg->setPosition(pos);
87 return arg;
88 }
89 // Look up the value of constant variables. This allows constant-expressions like
90 // `int4(colorGreen)` to be replaced with the compile-time constant `int4(0, 1, 0, 1)`.
92
93 // We can cast a vector of compile-time constants at compile-time.
95 return cast_constant_composite(context, pos, type, std::move(arg));
96 }
97 return std::make_unique<ConstructorCompoundCast>(pos, type, std::move(arg));
98}
#define SkASSERT(cond)
Definition SkAssert.h:116
static std::unique_ptr< Expression > MakeConstantValueForVariable(Position pos, std::unique_ptr< Expression > expr)
virtual bool isVector() const
Definition SkSLType.h:524
bool isAllowedInES2(const Context &context) const
virtual int rows() const
Definition SkSLType.h:438
bool matches(const Type &other) const
Definition SkSLType.h:269
virtual bool isMatrix() const
Definition SkSLType.h:528
virtual int columns() const
Definition SkSLType.h:429
bool IsCompileTimeConstant(const Expression &expr)
static std::unique_ptr< Expression > cast_constant_composite(const Context &context, Position pos, const Type &destType, std::unique_ptr< Expression > constCtor)

Member Data Documentation

◆ kIRNodeKind

constexpr Kind SkSL::ConstructorCompoundCast::kIRNodeKind = Kind::kConstructorCompoundCast
inlinestaticconstexpr

Definition at line 32 of file SkSLConstructorCompoundCast.h.


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