Revert "Revert "moved BinaryExpression's data into IRNode""
This reverts commit b61c3a9a01c44840eaa35b28cae0a4b358727f3c.
Change-Id: I4689e1f4977fab3233ff492cee06fbc301b5c689
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317386
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp
index 433b11b..6ef3b9b 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/SkSLGLSLCodeGenerator.cpp
@@ -913,31 +913,33 @@
void GLSLCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
Precedence parentPrecedence) {
+ const Expression& left = b.left();
+ const Expression& right = b.right();
+ Token::Kind op = b.getOperator();
if (fProgram.fSettings.fCaps->unfoldShortCircuitAsTernary() &&
- (b.fOperator == Token::Kind::TK_LOGICALAND ||
- b.fOperator == Token::Kind::TK_LOGICALOR)) {
+ (op == Token::Kind::TK_LOGICALAND || op == Token::Kind::TK_LOGICALOR)) {
this->writeShortCircuitWorkaroundExpression(b, parentPrecedence);
return;
}
- Precedence precedence = GetBinaryPrecedence(b.fOperator);
+ Precedence precedence = GetBinaryPrecedence(op);
if (precedence >= parentPrecedence) {
this->write("(");
}
bool positionWorkaround = fProgramKind == Program::Kind::kVertex_Kind &&
- Compiler::IsAssignment(b.fOperator) &&
- b.fLeft->kind() == Expression::Kind::kFieldAccess &&
- is_sk_position((FieldAccess&) *b.fLeft) &&
- !b.fRight->containsRTAdjust() &&
+ Compiler::IsAssignment(op) &&
+ left.kind() == Expression::Kind::kFieldAccess &&
+ is_sk_position((FieldAccess&) left) &&
+ !right.containsRTAdjust() &&
!fProgram.fSettings.fCaps->canUseFragCoord();
if (positionWorkaround) {
this->write("sk_FragCoord_Workaround = (");
}
- this->writeExpression(*b.fLeft, precedence);
+ this->writeExpression(left, precedence);
this->write(" ");
- this->write(Compiler::OperatorName(b.fOperator));
+ this->write(Compiler::OperatorName(op));
this->write(" ");
- this->writeExpression(*b.fRight, precedence);
+ this->writeExpression(right, precedence);
if (positionWorkaround) {
this->write(")");
}
@@ -955,20 +957,20 @@
// Transform:
// a && b => a ? b : false
// a || b => a ? true : b
- this->writeExpression(*b.fLeft, kTernary_Precedence);
+ this->writeExpression(b.left(), kTernary_Precedence);
this->write(" ? ");
- if (b.fOperator == Token::Kind::TK_LOGICALAND) {
- this->writeExpression(*b.fRight, kTernary_Precedence);
+ if (b.getOperator() == Token::Kind::TK_LOGICALAND) {
+ this->writeExpression(b.right(), kTernary_Precedence);
} else {
BoolLiteral boolTrue(fContext, -1, true);
this->writeBoolLiteral(boolTrue);
}
this->write(" : ");
- if (b.fOperator == Token::Kind::TK_LOGICALAND) {
+ if (b.getOperator() == Token::Kind::TK_LOGICALAND) {
BoolLiteral boolFalse(fContext, -1, false);
this->writeBoolLiteral(boolFalse);
} else {
- this->writeExpression(*b.fRight, kTernary_Precedence);
+ this->writeExpression(b.right(), kTernary_Precedence);
}
if (kTernary_Precedence >= parentPrecedence) {
this->write(")");