Revert "moved BinaryExpression's data into IRNode"
This reverts commit efc8797880e2cef85a1d6211430d1dd27e3d5b78.
Reason for revert: breakage due to std::max initializer list
Original change's description:
> moved BinaryExpression's data into IRNode
>
> This is another step in the process of merging the various IRNodes' data
> into the base class.
>
> Change-Id: Ide39c240e6178e23bb6fe317dd56addf2ffefcbb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317102
> Commit-Queue: John Stiles <johnstiles@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com
Change-Id: Ib8ef629ffa0ff8bb0aeddfa4f42b824e79ce72b6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317384
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLByteCodeGenerator.cpp b/src/sksl/SkSLByteCodeGenerator.cpp
index 1e9dab0..a213ca4 100644
--- a/src/sksl/SkSLByteCodeGenerator.cpp
+++ b/src/sksl/SkSLByteCodeGenerator.cpp
@@ -681,29 +681,28 @@
}
bool ByteCodeGenerator::writeBinaryExpression(const BinaryExpression& b, bool discard) {
- const Expression& left = b.left();
- const Expression& right = b.right();
- Token::Kind op = b.getOperator();
- if (op == Token::Kind::TK_EQ) {
- std::unique_ptr<LValue> lvalue = this->getLValue(left);
- this->writeExpression(right);
+ if (b.fOperator == Token::Kind::TK_EQ) {
+ std::unique_ptr<LValue> lvalue = this->getLValue(*b.fLeft);
+ this->writeExpression(*b.fRight);
lvalue->store(discard);
discard = false;
return discard;
}
- const Type& lType = left.type();
- const Type& rType = right.type();
+ const Type& lType = b.fLeft->type();
+ const Type& rType = b.fRight->type();
bool lVecOrMtx = (lType.typeKind() == Type::TypeKind::kVector ||
lType.typeKind() == Type::TypeKind::kMatrix);
bool rVecOrMtx = (rType.typeKind() == Type::TypeKind::kVector ||
rType.typeKind() == Type::TypeKind::kMatrix);
+ Token::Kind op;
std::unique_ptr<LValue> lvalue;
- if (Compiler::IsAssignment(op)) {
- lvalue = this->getLValue(left);
+ if (Compiler::IsAssignment(b.fOperator)) {
+ lvalue = this->getLValue(*b.fLeft);
lvalue->load();
- op = Compiler::RemoveAssignment(op);
+ op = Compiler::RemoveAssignment(b.fOperator);
} else {
- this->writeExpression(left);
+ this->writeExpression(*b.fLeft);
+ op = b.fOperator;
if (!lVecOrMtx && rVecOrMtx) {
for (int i = SlotCount(rType); i > 1; --i) {
this->write(ByteCodeInstruction::kDup, 1);
@@ -719,7 +718,7 @@
this->write(ByteCodeInstruction::kMaskPush);
this->write(ByteCodeInstruction::kBranchIfAllFalse);
DeferredLocation falseLocation(this);
- this->writeExpression(right);
+ this->writeExpression(*b.fRight);
this->write(ByteCodeInstruction::kAndB, 1);
falseLocation.set();
this->write(ByteCodeInstruction::kMaskPop);
@@ -732,7 +731,7 @@
this->write(ByteCodeInstruction::kMaskPush);
this->write(ByteCodeInstruction::kBranchIfAllFalse);
DeferredLocation falseLocation(this);
- this->writeExpression(right);
+ this->writeExpression(*b.fRight);
this->write(ByteCodeInstruction::kOrB, 1);
falseLocation.set();
this->write(ByteCodeInstruction::kMaskPop);
@@ -742,13 +741,13 @@
case Token::Kind::TK_SHR: {
SkASSERT(count == 1 && (tc == SkSL::TypeCategory::kSigned ||
tc == SkSL::TypeCategory::kUnsigned));
- if (!right.isCompileTimeConstant()) {
- fErrors.error(right.fOffset, "Shift amounts must be constant");
+ if (!b.fRight->isCompileTimeConstant()) {
+ fErrors.error(b.fRight->fOffset, "Shift amounts must be constant");
return false;
}
- int64_t shift = right.getConstantInt();
+ int64_t shift = b.fRight->getConstantInt();
if (shift < 0 || shift > 31) {
- fErrors.error(right.fOffset, "Shift amount out of range");
+ fErrors.error(b.fRight->fOffset, "Shift amount out of range");
return false;
}
@@ -766,7 +765,7 @@
default:
break;
}
- this->writeExpression(right);
+ this->writeExpression(*b.fRight);
if (lVecOrMtx && !rVecOrMtx) {
for (int i = SlotCount(lType); i > 1; --i) {
this->write(ByteCodeInstruction::kDup, 1);