Made out-of-bounds literals non-fatal errors in DSLParser
There was no good reason for this behavior in the first place, and this
change makes the error reporting behavior better match SkSLParser.
Change-Id: I7b69e7bcc64173c0ac6523e075c1f24e2be00ed0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/444758
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLDSLParser.cpp b/src/sksl/SkSLDSLParser.cpp
index 0b58fc5..d1854c9 100644
--- a/src/sksl/SkSLDSLParser.cpp
+++ b/src/sksl/SkSLDSLParser.cpp
@@ -1639,25 +1639,23 @@
}
case Token::Kind::TK_INT_LITERAL: {
SKSL_INT i;
- if (this->intLiteral(&i)) {
- return {{DSLExpression(i, this->position(t))}};
+ if (!this->intLiteral(&i)) {
+ i = 0;
}
- break;
+ return {{DSLExpression(i, this->position(t))}};
}
case Token::Kind::TK_FLOAT_LITERAL: {
SKSL_FLOAT f;
- if (this->floatLiteral(&f)) {
- return {{DSLExpression(f, this->position(t))}};
+ if (!this->floatLiteral(&f)) {
+ f = 0.0f;
}
- break;
+ return {{DSLExpression(f, this->position(t))}};
}
case Token::Kind::TK_TRUE_LITERAL: // fall through
case Token::Kind::TK_FALSE_LITERAL: {
bool b;
- if (this->boolLiteral(&b)) {
- return {{DSLExpression(b, this->position(t))}};
- }
- break;
+ SkAssertResult(this->boolLiteral(&b));
+ return {{DSLExpression(b, this->position(t))}};
}
case Token::Kind::TK_LPAREN: {
this->nextToken();