Improved DSL Array error checking
Change-Id: I4b1235f7363309bd2aa3e2f1b3e00c94b43976bb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430058 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
92c7cecad2
commit
ed6e54f1b4
@ -187,7 +187,13 @@ DSLExpression DSLType::Construct(DSLType type, SkTArray<DSLExpression> argArray)
|
||||
}
|
||||
|
||||
DSLType Array(const DSLType& base, int count) {
|
||||
SkASSERT(count >= 1);
|
||||
if (count <= 0) {
|
||||
DSLWriter::ReportError("error: array size must be positive\n");
|
||||
}
|
||||
if (base.isArray()) {
|
||||
DSLWriter::ReportError("error: multidimensional arrays are not permitted\n");
|
||||
return base;
|
||||
}
|
||||
return DSLWriter::SymbolTable()->addArrayDimension(&base.skslType(), count);
|
||||
}
|
||||
|
||||
|
@ -556,6 +556,16 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLType, r, ctxInfo) {
|
||||
DSLExpression e = x + 1;
|
||||
REPORTER_ASSERT(r, e.type().isFloat());
|
||||
e.release();
|
||||
|
||||
{
|
||||
ExpectError error(r, "error: array size must be positive\n");
|
||||
Array(kFloat_Type, -1);
|
||||
}
|
||||
|
||||
{
|
||||
ExpectError error(r, "error: multidimensional arrays are not permitted\n");
|
||||
Array(Array(kFloat_Type, 2), 2);
|
||||
}
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLMatrices, r, ctxInfo) {
|
||||
|
Loading…
Reference in New Issue
Block a user