Skip to content

Commit a05d27b

Browse files
Ethan NicholasSkia Commit-Bot
authored andcommitted
moved SkSL BoolLiteral data into IRNode
Change-Id: I177b6daf4d6cb024ba20264ab01d0aa68e768a6d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319782 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
1 parent 68861e3 commit a05d27b

13 files changed

+423
-39
lines changed

src/sksl/SkSLByteCodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ bool ByteCodeGenerator::writeBinaryExpression(const BinaryExpression& b, bool di
901901

902902
void ByteCodeGenerator::writeBoolLiteral(const BoolLiteral& b) {
903903
this->write(ByteCodeInstruction::kPushImmediate);
904-
this->write32(b.fValue ? ~0 : 0);
904+
this->write32(b.value() ? ~0 : 0);
905905
}
906906

907907
void ByteCodeGenerator::writeConstructor(const Constructor& c) {

src/sksl/SkSLCFGGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ void CFGGenerator::addLValue(CFG& cfg, std::unique_ptr<Expression>* e) {
479479
}
480480

481481
static bool is_true(Expression& expr) {
482-
return expr.is<BoolLiteral>() && expr.as<BoolLiteral>().fValue;
482+
return expr.is<BoolLiteral>() && expr.as<BoolLiteral>().value();
483483
}
484484

485485
void CFGGenerator::addStatement(CFG& cfg, std::unique_ptr<Statement>* s) {

src/sksl/SkSLCompiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ void Compiler::simplifyExpression(DefinitionMap& definitions,
881881
if (t->fTest->kind() == Expression::Kind::kBoolLiteral) {
882882
// ternary has a constant test, replace it with either the true or
883883
// false branch
884-
if (t->fTest->as<BoolLiteral>().fValue) {
884+
if (t->fTest->as<BoolLiteral>().value()) {
885885
(*iter)->setExpression(std::move(t->fIfTrue));
886886
} else {
887887
(*iter)->setExpression(std::move(t->fIfFalse));
@@ -1292,7 +1292,7 @@ void Compiler::simplifyStatement(DefinitionMap& definitions,
12921292
IfStatement& i = stmt->as<IfStatement>();
12931293
if (i.fTest->kind() == Expression::Kind::kBoolLiteral) {
12941294
// constant if, collapse down to a single branch
1295-
if (i.fTest->as<BoolLiteral>().fValue) {
1295+
if (i.fTest->as<BoolLiteral>().value()) {
12961296
SkASSERT(i.fIfTrue);
12971297
(*iter)->setStatement(std::move(i.fIfTrue));
12981298
} else {

src/sksl/SkSLDehydrator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void Dehydrator::write(const Expression* e) {
267267
case Expression::Kind::kBoolLiteral: {
268268
const BoolLiteral& b = e->as<BoolLiteral>();
269269
this->writeU8(Rehydrator::kBoolLiteral_Command);
270-
this->writeU8(b.fValue);
270+
this->writeU8(b.value());
271271
break;
272272
}
273273
case Expression::Kind::kConstructor: {

src/sksl/SkSLGLSLCodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ void GLSLCodeGenerator::writePostfixExpression(const PostfixExpression& p,
10081008
}
10091009

10101010
void GLSLCodeGenerator::writeBoolLiteral(const BoolLiteral& b) {
1011-
this->write(b.fValue ? "true" : "false");
1011+
this->write(b.value() ? "true" : "false");
10121012
}
10131013

10141014
void GLSLCodeGenerator::writeIntLiteral(const IntLiteral& i) {

src/sksl/SkSLIRGenerator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ std::unique_ptr<Statement> IRGenerator::convertIf(const ASTNode& n) {
532532
}
533533
if (test->kind() == Expression::Kind::kBoolLiteral) {
534534
// static boolean value, fold down to a single branch
535-
if (test->as<BoolLiteral>().fValue) {
535+
if (test->as<BoolLiteral>().value()) {
536536
return ifTrue;
537537
} else if (ifFalse) {
538538
return ifFalse;
@@ -1710,7 +1710,7 @@ static std::unique_ptr<Expression> short_circuit_boolean(const Context& context,
17101710
Token::Kind op,
17111711
const Expression& right) {
17121712
SkASSERT(left.kind() == Expression::Kind::kBoolLiteral);
1713-
bool leftVal = left.as<BoolLiteral>().fValue;
1713+
bool leftVal = left.as<BoolLiteral>().value();
17141714
if (op == Token::Kind::TK_LOGICALAND) {
17151715
// (true && expr) -> (expr) and (false && expr) -> (false)
17161716
return leftVal ? right.clone()
@@ -1753,8 +1753,8 @@ std::unique_ptr<Expression> IRGenerator::constantFold(const Expression& left,
17531753
// types, which will let us be more intelligent about this.
17541754
if (left.kind() == Expression::Kind::kBoolLiteral &&
17551755
right.kind() == Expression::Kind::kBoolLiteral) {
1756-
bool leftVal = left.as<BoolLiteral>().fValue;
1757-
bool rightVal = right.as<BoolLiteral>().fValue;
1756+
bool leftVal = left.as<BoolLiteral>().value();
1757+
bool rightVal = right.as<BoolLiteral>().value();
17581758
bool result;
17591759
switch (op) {
17601760
case Token::Kind::TK_LOGICALAND: result = leftVal && rightVal; break;
@@ -2013,7 +2013,7 @@ std::unique_ptr<Expression> IRGenerator::convertTernaryExpression(const ASTNode&
20132013
}
20142014
if (test->kind() == Expression::Kind::kBoolLiteral) {
20152015
// static boolean test, just return one of the branches
2016-
if (test->as<BoolLiteral>().fValue) {
2016+
if (test->as<BoolLiteral>().value()) {
20172017
return ifTrue;
20182018
} else {
20192019
return ifFalse;
@@ -2409,7 +2409,7 @@ std::unique_ptr<Expression> IRGenerator::convertPrefixExpression(const ASTNode&
24092409
}
24102410
if (base->kind() == Expression::Kind::kBoolLiteral) {
24112411
return std::make_unique<BoolLiteral>(fContext, base->fOffset,
2412-
!base->as<BoolLiteral>().fValue);
2412+
!base->as<BoolLiteral>().value());
24132413
}
24142414
break;
24152415
case Token::Kind::TK_BITWISENOT:

src/sksl/SkSLMetalCodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ void MetalCodeGenerator::writePostfixExpression(const PostfixExpression& p,
907907
}
908908

909909
void MetalCodeGenerator::writeBoolLiteral(const BoolLiteral& b) {
910-
this->write(b.fValue ? "true" : "false");
910+
this->write(b.value() ? "true" : "false");
911911
}
912912

913913
void MetalCodeGenerator::writeIntLiteral(const IntLiteral& i) {

src/sksl/SkSLSPIRVCodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2503,7 +2503,7 @@ SpvId SPIRVCodeGenerator::writePostfixExpression(const PostfixExpression& p, Out
25032503
}
25042504

25052505
SpvId SPIRVCodeGenerator::writeBoolLiteral(const BoolLiteral& b) {
2506-
if (b.fValue) {
2506+
if (b.value()) {
25072507
if (fBoolTrue == 0) {
25082508
fBoolTrue = this->nextId();
25092509
this->writeInstruction(SpvOpConstantTrue, this->getType(b.type()), fBoolTrue,

0 commit comments

Comments
 (0)