36 if (
args.size() == 1) {
37 std::unique_ptr<Expression>& argument =
args.front();
38 if (
type.isVector() && argument->type().isVector() &&
39 argument->type().componentType().matches(
type.componentType()) &&
40 argument->type().slotCount() >
type.slotCount()) {
45 const char* swizzleHint;
46 switch (
type.slotCount()) {
47 case 2: swizzleHint =
"; use '.xy' instead";
break;
48 case 3: swizzleHint =
"; use '.xyz' instead";
break;
49 default: swizzleHint =
"";
SkDEBUGFAIL(
"unexpected slicing cast");
break;
53 "' is not a valid parameter to '" +
type.displayName() +
"' constructor" +
58 if (argument->type().isScalar()) {
64 context,
pos,
type.componentType(), std::move(
args));
70 return type.isMatrix()
73 }
else if (argument->type().isVector()) {
76 if (
type.isVector() && argument->type().columns() ==
type.columns()) {
79 }
else if (argument->type().isMatrix()) {
82 if (
type.isMatrix()) {
86 const Type& typecastType =
type.componentType().toCompound(
88 argument->type().columns(),
89 argument->type().rows());
100 if (
type.isVector() &&
type.columns() == 4 && argument->type().slotCount() == 4) {
103 const Type& vectorType = argument->type().componentType().toCompound(context,
106 std::unique_ptr<Expression> vecCtor =
117 int expected =
type.rows() *
type.columns();
119 for (std::unique_ptr<Expression>& arg :
args) {
120 if (!arg->type().isScalar() && !arg->type().isVector()) {
122 "' is not a valid parameter to '" +
type.displayName() +
"' constructor");
130 const Type& ctorType =
type.componentType().toCompound(context, arg->type().columns(),
141 if (actual != expected) {
155 if (
args.size() == 1 &&
args[0]->type().matches(
type) && !
type.componentType().isOpaque()) {
159 return std::move(
args[0]);
161 if (
type.isScalar()) {
164 if (
type.isVector() ||
type.isMatrix()) {
167 if (
type.isArray() &&
type.columns() > 0) {
170 if (
type.isStruct() &&
type.fields().size() > 0) {
180 for (
const std::unique_ptr<Expression>& arg : this->
argumentSpan()) {
181 int argSlots = arg->type().slotCount();
183 return arg->getConstantValue(n);
188 SkDEBUGFAIL(
"argument-list slot count doesn't match constructor-type slot count");
200 for (
int n = 0; n < exprs; ++n) {
203 if (!left.has_value()) {
207 if (!right.has_value()) {
211 if (*left != *right) {
231 for (
const std::unique_ptr<Expression>& arg : this->
argumentSpan()) {
232 result += separator();
#define SkDEBUGFAIL(message)
std::optional< double > getConstantValue(int n) const override
ComparisonResult compareConstant(const Expression &other) const override
virtual SkSpan< std::unique_ptr< Expression > > argumentSpan()=0
static std::unique_ptr< Expression > Convert(const Context &context, Position pos, const Type &type, ExpressionArray args)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, ExpressionArray args)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
static std::unique_ptr< Expression > Convert(const Context &context, Position pos, const Type &rawType, ExpressionArray args)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
static std::unique_ptr< Expression > Convert(const Context &context, Position pos, const Type &type, ExpressionArray args)
void error(Position position, std::string_view msg)
virtual bool supportsConstantValues() const
const Type & type() const
virtual std::optional< double > getConstantValue(int n) const
std::string description() const final
AnyConstructor & asAnyConstructor()
bool isAnyConstructor() const
virtual int columns() const
virtual size_t slotCount() const
std::string description() const override
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
std::unique_ptr< Expression > Convert(const Context &context, Position pos, const Type &type, ExpressionArray args)
std::string void void auto Separator()
static std::unique_ptr< Expression > convert_compound_constructor(const Context &context, Position pos, const Type &type, ExpressionArray args)
static SkString to_string(int n)