26 std::unique_ptr<Expression>
test,
27 std::unique_ptr<Expression> ifTrue,
28 std::unique_ptr<Expression> ifFalse) {
33 if (
ifTrue->type().componentType().isOpaque()) {
35 ifTrue->type().displayName() +
"' is not allowed");
39 const Type* falseType;
40 const Type* resultType;
41 Operator equalityOp(Operator::Kind::EQEQ);
43 &trueType, &falseType, &resultType) ||
44 !trueType->
matches(*falseType)) {
46 if (
ifTrue->type().isVoid()) {
47 context.
fErrors->
error(errorPos,
"ternary expression of type 'void' is not allowed");
49 context.
fErrors->
error(errorPos,
"ternary operator result mismatch: '" +
50 ifTrue->type().displayName() +
"', '" +
51 ifFalse->type().displayName() +
"'");
56 context.
fErrors->
error(
pos,
"ternary operator result may not be an array (or struct "
57 "containing an array)");
74 std::unique_ptr<Expression>
test,
75 std::unique_ptr<Expression> ifTrue,
76 std::unique_ptr<Expression> ifFalse) {
112 Operator::Kind::LOGICALAND, std::move(
ifTrue));
118 Operator::Kind::LOGICALOR, std::move(
ifFalse));
135 return std::make_unique<TernaryExpression>(
pos, std::move(
test), std::move(
ifTrue),
141 return std::string(needsParens ?
"(" :
"") +
145 std::string(needsParens ?
")" :
"");
static std::unique_ptr< Expression > Make(const Context &context, Position pos, std::unique_ptr< Expression > left, Operator op, std::unique_ptr< Expression > right)
const std::unique_ptr< Type > fBool
static const Expression * GetConstantValueForVariable(const Expression &value)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, const Type &type, std::unique_ptr< Expression > arg)
const BuiltinTypes & fTypes
void error(Position position, std::string_view msg)
bool isBoolLiteral() const
std::string description() const final
SKSL_INT boolValue() const
bool determineBinaryType(const Context &context, const Type &left, const Type &right, const Type **outLeftType, const Type **outRightType, const Type **outResultType) const
static std::unique_ptr< Expression > Make(const Context &context, Position pos, Operator op, std::unique_ptr< Expression > base)
static std::unique_ptr< Expression > Make(const Context &context, Position pos, std::unique_ptr< Expression > test, std::unique_ptr< Expression > ifTrue, std::unique_ptr< Expression > ifFalse)
std::unique_ptr< Expression > & ifTrue()
std::unique_ptr< Expression > & test()
static std::unique_ptr< Expression > Convert(const Context &context, Position pos, std::unique_ptr< Expression > test, std::unique_ptr< Expression > ifTrue, std::unique_ptr< Expression > ifFalse)
std::unique_ptr< Expression > & ifFalse()
std::unique_ptr< Expression > coerceExpression(std::unique_ptr< Expression > expr, const Context &context) const
virtual bool isOrContainsArray() const
bool matches(const Type &other) const
bool IsSameExpressionTree(const Expression &left, const Expression &right)
bool HasSideEffects(const Expression &expr)
bool strictES2Mode() const
ProgramSettings fSettings