skia2/tests/sksl/shared/ForLoopMultipleInit.glsl
John Stiles d68069019b Fix whitespace when commas are used in a binary-expression.
Previously, any code which emitted a binary expression would always emit
a leading and trailing space. This caused comma expressions to look
goofy: `foo() , bar();` instead of `foo(), bar();`.

Operator::operatorName() now returns the operator token with appropriate
whitespace around it, and tightOperatorName() is a new method which
omits the whitespace. Functions which assemble binary expressions
should now concatenate `x + operatorName() + y` instead of hard-coding
`x + " " + operatorName() + " " + y`. Prefix/postfix expressions should
use `tightOperatorName()` because otherwise negation looks bad (` - 123`
instead of `-123`).

Super low priority, but it was easy to fix.

Change-Id: I3c92832207293a310fb1070b3b5e72455757b0ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/497776
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-01-24 16:21:43 +00:00

33 lines
630 B
GLSL

out vec4 sk_FragColor;
vec4 main() {
vec4 result = vec4(0.0);
{
float a = 0.0;
float b = 0.0;
for (; a < 10.0 && b < 10.0; (++a, ++b)) {
result.x += a;
result.y += b;
}
}
{
int c = 0;
for (; c < 10; ++c) {
result.z += 1.0;
}
}
{
float d[2] = float[2](0.0, 10.0);
float e[4] = float[4](1.0, 2.0, 3.0, 4.0);
float f = 9.0;
for (; d[0] < d[1]; ++d[0]) {
result.w = e[0] * f;
}
}
{
for (; ; ) break;
}
for (; ; ) break;
return result;
}