Support larger compound types in the interpreter
Field access and array indexing are supported, including
dynamic indices. Larger types (> 4 slots) can be used as
lvalues, rvalues, etc.
Change-Id: I9bb4ed850be4259c05c8952c6c0a17b71f813772
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214443
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLByteCodeGenerator.h b/src/sksl/SkSLByteCodeGenerator.h
index 3a2306c..4d16997 100644
--- a/src/sksl/SkSLByteCodeGenerator.h
+++ b/src/sksl/SkSLByteCodeGenerator.h
@@ -96,6 +96,8 @@
void writeTypedInstruction(const Type& type, ByteCodeInstruction s, ByteCodeInstruction u,
ByteCodeInstruction f, int count);
+ static int SlotCount(const Type& type);
+
private:
// reserves 16 bits in the output code, to be filled in later with an address once we determine
// it
@@ -171,11 +173,18 @@
*/
int getLocation(const Variable& var);
+ /**
+ * As above, but computes the (possibly dynamic) address of an expression involving indexing &
+ * field access. If the address is known, it's returned. If not, -1 is returned, and the
+ * location will be left on the top of the stack.
+ */
+ int getLocation(const Expression& expr, Variable::Storage* storage);
+
std::unique_ptr<ByteCodeFunction> writeFunction(const FunctionDefinition& f);
void writeVarDeclarations(const VarDeclarations& decl);
- void writeVariableReference(const VariableReference& ref);
+ void writeVariableExpression(const Expression& expr);
void writeExpression(const Expression& expr);
@@ -195,16 +204,12 @@
void writeExternalValue(const ExternalValueReference& r);
- void writeFieldAccess(const FieldAccess& f);
-
void writeSwizzle(const Swizzle& swizzle);
void writeBinaryExpression(const BinaryExpression& b);
void writeTernaryExpression(const TernaryExpression& t);
- void writeIndexExpression(const IndexExpression& expr);
-
void writeLogicalAnd(const BinaryExpression& b);
void writeLogicalOr(const BinaryExpression& o);
@@ -268,7 +273,7 @@
std::unordered_map<String, ByteCodeInstruction> fIntrinsics;
friend class DeferredLocation;
- friend class ByteCodeVariableLValue;
+ friend class ByteCodeExpressionLValue;
friend class ByteCodeSwizzleLValue;
typedef CodeGenerator INHERITED;