Improved error reporting in DSLParser::swizzle
With this change, it will either match or improve on the reports we currently get from SkSLParser. Change-Id: I9b3c0f0c2225bf47fec141a1c01c94d9c2ab6a6b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/443056 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
c898d04fb7
commit
be8f73d714
@ -1496,12 +1496,12 @@ skstd::optional<DSLWrapper<DSLExpression>> DSLParser::swizzle(int offset, DSLExp
|
|||||||
return base.field(swizzleMask, this->position(offset));
|
return base.field(swizzleMask, this->position(offset));
|
||||||
}
|
}
|
||||||
int length = swizzleMask.length();
|
int length = swizzleMask.length();
|
||||||
if (length > 4) {
|
|
||||||
this->error(offset, "too many components in swizzle mask");
|
|
||||||
return skstd::nullopt;
|
|
||||||
}
|
|
||||||
SkSL::SwizzleComponent::Type components[4];
|
SkSL::SwizzleComponent::Type components[4];
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
|
if (i >= 4) {
|
||||||
|
this->error(offset, "too many components in swizzle mask");
|
||||||
|
return {{DSLExpression::Poison()}};
|
||||||
|
}
|
||||||
switch (swizzleMask[i]) {
|
switch (swizzleMask[i]) {
|
||||||
case '0': components[i] = SwizzleComponent::ZERO; break;
|
case '0': components[i] = SwizzleComponent::ZERO; break;
|
||||||
case '1': components[i] = SwizzleComponent::ONE; break;
|
case '1': components[i] = SwizzleComponent::ONE; break;
|
||||||
@ -1524,7 +1524,7 @@ skstd::optional<DSLWrapper<DSLExpression>> DSLParser::swizzle(int offset, DSLExp
|
|||||||
default:
|
default:
|
||||||
this->error(offset,
|
this->error(offset,
|
||||||
String::printf("invalid swizzle component '%c'", swizzleMask[i]).c_str());
|
String::printf("invalid swizzle component '%c'", swizzleMask[i]).c_str());
|
||||||
return skstd::nullopt;
|
return {{DSLExpression::Poison()}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (length) {
|
switch (length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user