37 }
else if (index <
base.type().columns()) {
42 base.type().displayName() +
"'");
69 std::unique_ptr<Expression>
base,
70 std::unique_ptr<Expression> index) {
87 "expected array, but found '" + baseType.
displayName() +
"'");
90 if (!
index->type().isInteger()) {
109 std::unique_ptr<Expression>
base,
110 std::unique_ptr<Expression> index) {
111 const Type& baseType =
base->type();
135 return arguments[indexValue]->clone(
pos);
146 int vecWidth = baseType.
rows();
148 indexValue *= vecWidth;
151 bool allConstant =
true;
152 for (
int slot = 0; slot < vecWidth; ++slot) {
153 std::optional<double> slotVal = baseExpr->
getConstantValue(indexValue + slot);
154 if (slotVal.has_value()) {
155 ctorArgs[slot] = *slotVal;
169 return std::make_unique<IndexExpression>(context,
pos, std::move(
base), std::move(
index));
const std::unique_ptr< Type > fFloat2
const std::unique_ptr< Type > fHalf4
const std::unique_ptr< Type > fInt
const std::unique_ptr< Type > fFloat4
const std::unique_ptr< Type > fHalf2
const std::unique_ptr< Type > fHalf3
const std::unique_ptr< Type > fFloat
const std::unique_ptr< Type > fFloat3
const std::unique_ptr< Type > fHalf
static const Expression * GetConstantValueForVariable(const Expression &value)
static std::unique_ptr< Expression > MakeFromConstants(const Context &context, Position pos, const Type &type, const double values[])
const BuiltinTypes & fTypes
SymbolTable * fSymbolTable
void error(Position position, std::string_view msg)
bool isIntLiteral() const
const Type & type() const
virtual std::optional< double > getConstantValue(int n) const
std::string description() const final
static std::unique_ptr< Expression > Make(const Context &context, Position pos, std::unique_ptr< Expression > base, std::unique_ptr< Expression > index)
std::unique_ptr< Expression > & base()
static std::unique_ptr< Expression > Convert(const Context &context, Position pos, std::unique_ptr< Expression > base, std::unique_ptr< Expression > index)
static const Type & IndexType(const Context &context, const Type &type)
std::unique_ptr< Expression > & index()
ExpressionArray & arguments()
static std::unique_ptr< Expression > Make(const Context &context, Position pos, std::unique_ptr< Expression > expr, ComponentArray inComponents)
const Type * addArrayDimension(const Context &context, const Type *type, int arraySize)
static std::unique_ptr< TypeReference > Convert(const Context &context, Position pos, const Type *type)
virtual bool isArray() const
virtual bool isVector() const
virtual const Type & componentType() const
SKSL_INT convertArraySize(const Context &context, Position arrayPos, std::unique_ptr< Expression > size) const
bool matches(const Type &other) const
virtual bool isMatrix() const
virtual int columns() const
static constexpr int kUnsizedArray
const Type & columnType(const Context &context) const
std::string displayName() const
bool HasSideEffects(const Expression &expr)
static bool index_out_of_range(const Context &context, Position pos, SKSL_INT index, const Expression &base)
static SkString to_string(int n)