Log Message
WSL should support for loops https://bugs.webkit.org/show_bug.cgi?id=176682
Reviewed by Filip Pizlo. Follows the pattern of the existing infrastructure of while loops. * WebGPUShadingLanguageRI/All.js: * WebGPUShadingLanguageRI/Checker.js: * WebGPUShadingLanguageRI/Evaluator.js: (Evaluator.prototype.visitForLoop): * WebGPUShadingLanguageRI/ForLoop.js: Copied from Tools/WebGPUShadingLanguageRI/LoopChecker.js. (ForLoop): (ForLoop.prototype.get origin): (ForLoop.prototype.get initialization): (ForLoop.prototype.get condition): (ForLoop.prototype.get increment): (ForLoop.prototype.get body): (ForLoop.prototype.toString): * WebGPUShadingLanguageRI/LoopChecker.js: (LoopChecker.prototype.visitForLoop): * WebGPUShadingLanguageRI/NameResolver.js: (NameResolver.prototype.visitForLoop): * WebGPUShadingLanguageRI/Parse.js: (parseFor): * WebGPUShadingLanguageRI/ReturnChecker.js: (ReturnChecker.prototype._isBoolCastFromLiteralTrue): (ReturnChecker.prototype.visitWhileLoop): (ReturnChecker.prototype.visitDoWhileLoop): (ReturnChecker.prototype.visitForLoop): * WebGPUShadingLanguageRI/Rewriter.js: (Rewriter.prototype.visitForLoop): (Rewriter): * WebGPUShadingLanguageRI/Test.html: * WebGPUShadingLanguageRI/Test.js: (TEST_forLoop): * WebGPUShadingLanguageRI/Visitor.js: (Visitor.prototype.visitForLoop):
Modified Paths
- trunk/Tools/ChangeLog
- trunk/Tools/WebGPUShadingLanguageRI/All.js
- trunk/Tools/WebGPUShadingLanguageRI/Checker.js
- trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js
- trunk/Tools/WebGPUShadingLanguageRI/LoopChecker.js
- trunk/Tools/WebGPUShadingLanguageRI/NameResolver.js
- trunk/Tools/WebGPUShadingLanguageRI/Parse.js
- trunk/Tools/WebGPUShadingLanguageRI/ReturnChecker.js
- trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js
- trunk/Tools/WebGPUShadingLanguageRI/Test.html
- trunk/Tools/WebGPUShadingLanguageRI/Test.js
- trunk/Tools/WebGPUShadingLanguageRI/Visitor.js
Added Paths
Diff
Modified: trunk/Tools/ChangeLog (221864 => 221865)
--- trunk/Tools/ChangeLog 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/ChangeLog 2017-09-11 17:47:44 UTC (rev 221865)
@@ -1,3 +1,44 @@
+2017-09-11 Myles C. Maxfield <[email protected]>
+
+ WSL should support for loops
+ https://bugs.webkit.org/show_bug.cgi?id=176682
+
+ Reviewed by Filip Pizlo.
+
+ Follows the pattern of the existing infrastructure of while loops.
+
+ * WebGPUShadingLanguageRI/All.js:
+ * WebGPUShadingLanguageRI/Checker.js:
+ * WebGPUShadingLanguageRI/Evaluator.js:
+ (Evaluator.prototype.visitForLoop):
+ * WebGPUShadingLanguageRI/ForLoop.js: Copied from Tools/WebGPUShadingLanguageRI/LoopChecker.js.
+ (ForLoop):
+ (ForLoop.prototype.get origin):
+ (ForLoop.prototype.get initialization):
+ (ForLoop.prototype.get condition):
+ (ForLoop.prototype.get increment):
+ (ForLoop.prototype.get body):
+ (ForLoop.prototype.toString):
+ * WebGPUShadingLanguageRI/LoopChecker.js:
+ (LoopChecker.prototype.visitForLoop):
+ * WebGPUShadingLanguageRI/NameResolver.js:
+ (NameResolver.prototype.visitForLoop):
+ * WebGPUShadingLanguageRI/Parse.js:
+ (parseFor):
+ * WebGPUShadingLanguageRI/ReturnChecker.js:
+ (ReturnChecker.prototype._isBoolCastFromLiteralTrue):
+ (ReturnChecker.prototype.visitWhileLoop):
+ (ReturnChecker.prototype.visitDoWhileLoop):
+ (ReturnChecker.prototype.visitForLoop):
+ * WebGPUShadingLanguageRI/Rewriter.js:
+ (Rewriter.prototype.visitForLoop):
+ (Rewriter):
+ * WebGPUShadingLanguageRI/Test.html:
+ * WebGPUShadingLanguageRI/Test.js:
+ (TEST_forLoop):
+ * WebGPUShadingLanguageRI/Visitor.js:
+ (Visitor.prototype.visitForLoop):
+
2017-09-11 Robin Morisset <[email protected]>
Just added myself to the contributors.json file as a committer
Modified: trunk/Tools/WebGPUShadingLanguageRI/All.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/All.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/All.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -64,6 +64,7 @@
load("EvaluationCommon.js");
load("Evaluator.js");
load("Field.js");
+load("ForLoop.js");
load("Func.js");
load("FuncDef.js");
load("FuncInstantiator.js");
Modified: trunk/Tools/WebGPUShadingLanguageRI/Checker.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/Checker.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/Checker.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -257,6 +257,22 @@
if (!conditionalResultType.equals(this._program.intrinsics.bool))
throw new WError("Do-While loop conditional isn't a bool: " + node.conditional);
}
+
+ visitForLoop(node)
+ {
+ if (node.initialization)
+ node.initialization.visit(this);
+ if (node.condition) {
+ let conditionResultType = node.condition.visit(this);
+ if (!conditionResultType)
+ throw new Error("For loop conditional has no type: " + node.conditional);
+ if (!conditionResultType.equals(this._program.intrinsics.bool))
+ throw new WError("For loop conditional isn't a bool: " + node.conditional);
+ }
+ if (node.increment)
+ node.increment.visit(this);
+ node.body.visit(this);
+ }
visitCommaExpression(node)
{
Modified: trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -190,6 +190,23 @@
} while (node.conditional.visit(this).loadValue());
}
+ visitForLoop(node)
+ {
+ for (node.initialization ? node.initialization.visit(this) : true;
+ node.condition ? node.condition.visit(this).loadValue() : true;
+ node.increment ? node.increment.visit(this) : true) {
+ try {
+ node.body.visit(this);
+ } catch (e) {
+ if (e instanceof Break)
+ break;
+ if (e instanceof Continue)
+ continue;
+ throw e;
+ }
+ }
+ }
+
visitBreak(node)
{
throw node;
Copied: trunk/Tools/WebGPUShadingLanguageRI/ForLoop.js (from rev 221864, trunk/Tools/WebGPUShadingLanguageRI/LoopChecker.js) (0 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/ForLoop.js (rev 0)
+++ trunk/Tools/WebGPUShadingLanguageRI/ForLoop.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+"use strict";
+
+class ForLoop extends Node {
+ constructor(origin, initialization, condition, increment, body)
+ {
+ super();
+ this._origin = origin;
+ this._initialization = initialization;
+ this._condition = condition;
+ this._increment = increment;
+ this._body = body;
+ }
+
+ get origin() { return this._origin; }
+ get initialization() { return this._initialization; }
+ get condition() { return this._condition; }
+ get increment() { return this._increment; }
+ get body() { return this._body; }
+
+ toString()
+ {
+ return "for (" + (this.initialization ? this.initialization : " ") + "; " + (this.condition ? this.condition : "") + "; " + (this.increment ? this.increment : "") + ") " + body;
+ }
+};
+
Modified: trunk/Tools/WebGPUShadingLanguageRI/LoopChecker.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/LoopChecker.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/LoopChecker.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -60,6 +60,22 @@
--this._loopDepth;
node.conditional.visit(this);
}
+
+ visitForLoop(node)
+ {
+ if (node.initialization)
+ node.initialization.visit(this);
+ if (node.condition)
+ node.condition.visit(this);
+ if (node.increment)
+ node.increment.visit(this);
+ ++this._loopDepth;
+ node.body.visit(this);
+ if (this._loopDepth == 0) {
+ throw new Error("The number of nested loops is negative!");
+ }
+ --this._loopDepth;
+ }
visitBreak(node)
{
Modified: trunk/Tools/WebGPUShadingLanguageRI/NameResolver.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/NameResolver.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/NameResolver.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -114,6 +114,18 @@
node.body.visit(new NameResolver(new NameContext(this._nameContext)));
node.conditional.visit(this);
}
+
+ visitForLoop(node)
+ {
+ let newResolver = new NameResolver(new NameContext(this._nameContext))
+ if (node.initialization)
+ node.initialization.visit(newResolver);
+ if (node.condition)
+ node.condition.visit(newResolver);
+ if (node.increment)
+ node.increment.visit(newResolver);
+ node.body.visit(newResolver);
+ }
visitProtocolDecl(node)
{
Modified: trunk/Tools/WebGPUShadingLanguageRI/Parse.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/Parse.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/Parse.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -573,6 +573,37 @@
return new WhileLoop(origin, new CallExpression(conditional.origin, "bool", [], [conditional]), body);
}
+ function parseFor()
+ {
+ let origin = consume("for");
+ consume("(");
+ let initialization;
+ if (tryConsume(";"))
+ initialization = undefined;
+ else {
+ initialization = lexer.backtrackingScope(parseVariableDecls);
+ if (!initialization)
+ initialization = parseEffectfulStatement();
+ }
+ let condition = tryConsume(";");
+ if (condition)
+ condition = undefined;
+ else {
+ condition = parseExpression();
+ consume(";");
+ condition = new CallExpression(condition.origin, "bool", [], [condition]);
+ }
+ let increment;
+ if (tryConsume(")"))
+ increment = undefined;
+ else {
+ increment = parseExpression();
+ consume(")");
+ }
+ let body = parseStatement();
+ return new ForLoop(origin, initialization, condition, increment, body);
+ }
+
function parseDo()
{
let origin = consume("do");
Modified: trunk/Tools/WebGPUShadingLanguageRI/ReturnChecker.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/ReturnChecker.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/ReturnChecker.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -74,10 +74,17 @@
return this.returnStyle.HasntReturnedYet;
}
+ _isBoolCastFromLiteralTrue(node)
+ {
+ return node.isCast && node.returnType instanceof TypeRef && node.returnType.equals(this._program.intrinsics.bool) && node.argumentList.length == 1 && node.argumentList[0].list.length == 1 && node.argumentList[0].list[0] instanceof BoolLiteral && node.argumentList[0].list[0].value;
+ }
+
visitWhileLoop(node)
{
- if (node.conditional instanceof CallExpression && node.conditional.isCast && node.conditional.returnType instanceof TypeRef && node.conditional.returnType.equals(this._program.intrinsics.bool) && node.conditional.argumentList.length == 1 && node.conditional.argumentList[0].list.length == 1 && node.conditional.argumentList[0].list[0] instanceof BoolLiteral && node.conditional.argumentList[0].list[0].value) {
- switch (node.body.visit(this)) {
+ node.conditional.visit(this);
+ let bodyReturn = node.body.visit(this);
+ if (node.conditional instanceof CallExpression && this._isBoolCastFromLiteralTrue(node.conditional)) {
+ switch (bodyReturn) {
case this.returnStyle.DefinitelyReturns:
return this.returnStyle.DefinitelyReturns;
case this.returnStyle.DefinitelyDoesntReturn:
@@ -84,14 +91,13 @@
case this.returnStyle.HasntReturnedYet:
return this.returnStyle.HasntReturnedYet;
}
- } else
- node.conditional.visit(this);
+ }
return this.returnStyle.HasntReturnedYet;
}
visitDoWhileLoop(node)
{
- let result;
+ let result = this.returnStyle.HasntReturnedYet;
switch (node.body.visit(this)) {
case this.returnStyle.DefinitelyReturns:
result = this.returnStyle.DefinitelyReturns;
@@ -102,6 +108,26 @@
node.conditional.visit(this);
return result;
}
+
+ visitForLoop(node)
+ {
+ if (node.initialization)
+ node.initialization.visit(this);
+ if (node.condition)
+ node.condition.visit(this);
+ if (node.increment)
+ node.increment.visit(this);
+ let bodyReturn = node.body.visit(this);
+ if (node.condition === undefined || this._isBoolCastFromLiteralTrue(node.condition)) {
+ switch (bodyReturn) {
+ case this.returnStyle.DefinitelyReturns:
+ return this.returnStyle.DefinitelyReturns;
+ case this.returnStyle.DefinitelyDoesntReturn:
+ case this.returnStyle.HasntReturnedYet:
+ return this.returnStyle.HasntReturnedYet;
+ }
+ }
+ }
visitReturn(node)
{
Modified: trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -304,5 +304,14 @@
{
return new DoWhileLoop(node.origin, node.body.visit(this), node.conditional.visit(this));
}
+
+ visitForLoop(node)
+ {
+ return new ForLoop(node.origin,
+ node.initialization ? node.initialization.visit(this) : undefined,
+ node.condition ? node.condition.visit(this) : undefined,
+ node.increment ? node.increment.visit(this) : undefined,
+ node.body.visit(this));
+ }
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.html (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.html 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.html 2017-09-11 17:47:44 UTC (rev 221865)
@@ -40,6 +40,7 @@
<script src=""
<script src=""
<script src=""
+<script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -1663,6 +1663,185 @@
checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 19);
}
+function TEST_forLoop()
+{
+ let program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ int i;
+ for (i = 0; i < x; i = i + 1) {
+ sum = sum + i;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ for (int i = 0; i < x; i = i + 1) {
+ sum = sum + i;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ int i = 100;
+ for (int i = 0; i < x; i = i + 1) {
+ sum = sum + i;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ for (int i = 0; i < x; i = i + 1) {
+ if (i == 4)
+ continue;
+ sum = sum + i;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 11);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ for (int i = 0; i < x; i = i + 1) {
+ if (i == 5)
+ break;
+ sum = sum + i;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 10);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ for (int i = 0; ; i = i + 1) {
+ if (i >= x)
+ break;
+ sum = sum + i;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 15);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 21);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ int i = 0;
+ for ( ; ; i = i + 1) {
+ if (i >= x)
+ break;
+ sum = sum + i;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 15);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 21);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int sum = 0;
+ int i = 0;
+ for ( ; ; ) {
+ if (i >= x)
+ break;
+ sum = sum + i;
+ i = i + 1;
+ }
+ return sum;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 3);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 15);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 21);
+ checkFail(
+ () => doPrep(`
+ void foo(int x)
+ {
+ for (int i = 0; ; i = i + 1) {
+ break;
+ x = i;
+ }
+ }
+ `),
+ (e) => e instanceof WTypeError);
+ program = doPrep(`
+ int foo(int x)
+ {
+ for ( ; ; ) {
+ return 7;
+ }
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 7);
+ checkFail(
+ () => doPrep(`
+ int foo(int x)
+ {
+ for ( ; x < 10; ) {
+ return 7;
+ }
+ }
+ `),
+ (e) => e instanceof WTypeError);
+ program = doPrep(`
+ int foo(int x)
+ {
+ for ( ; true; ) {
+ return 7;
+ }
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 7);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 7);
+}
+
let filter = /.*/; // run everything by default
if (this["arguments"]) {
for (let i = 0; i < arguments.length; i++) {
Modified: trunk/Tools/WebGPUShadingLanguageRI/Visitor.js (221864 => 221865)
--- trunk/Tools/WebGPUShadingLanguageRI/Visitor.js 2017-09-11 17:43:00 UTC (rev 221864)
+++ trunk/Tools/WebGPUShadingLanguageRI/Visitor.js 2017-09-11 17:47:44 UTC (rev 221865)
@@ -227,6 +227,17 @@
node.body.visit(this);
node.conditional.visit(this);
}
+
+ visitForLoop(node)
+ {
+ if (node.initialization)
+ node.initialization.visit(this);
+ if (node.condition)
+ node.condition.visit(this);
+ if (node.increment)
+ node.increment.visit(this);
+ node.body.visit(this);
+ }
visitReturn(node)
{
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
