Log Message
Add "if" statements to WSL https://bugs.webkit.org/show_bug.cgi?id=176294
Reviewed by Filip Pizlo.
Fairly straightforward implementation. ReturnChecker only returns true iff there is an else block,
and both the if body and the else body recursively return true.
In order to accept both syntaxes:
if (foo)
bar;
... and ...
if (foo) {
bar;
}
This patch lets parseStatement() call parseBlock(). This means that the following is valid:
int x = 7;
if (foo) {
int x = 8;
// x is 8 here!
}
// x is 7 here!
This production means that these blocks don't require "if" statements, so you can just have:
int foo() {
int x = 7;
{
int x = 8;
// x is 8 here!
}
// x is 7 here!
}
However, this patch doesn't touch the following use-case:
if (int x = bar()) {
// use x here
}
* WebGPUShadingLanguageRI/All.js:
* WebGPUShadingLanguageRI/Checker.js:
* WebGPUShadingLanguageRI/Evaluator.js:
(Evaluator.prototype.visitIfStatement):
* WebGPUShadingLanguageRI/IfStatement.js: Copied from Tools/WebGPUShadingLanguageRI/TypeDef.js.
(IfStatement):
(IfStatement.prototype.get origin):
(IfStatement.prototype.get conditional):
(IfStatement.prototype.get body):
(IfStatement.prototype.get elseBody):
(IfStatement.prototype.toString):
* WebGPUShadingLanguageRI/NameResolver.js:
(NameResolver.prototype.visitIfStatement):
* WebGPUShadingLanguageRI/Parse.js:
(parseTypeParameters):
(parseIfStatement):
(parseStatement):
* WebGPUShadingLanguageRI/ReturnChecker.js:
(ReturnChecker.prototype.visitIfStatement):
* WebGPUShadingLanguageRI/Rewriter.js:
(Rewriter.prototype.visitIfStatement):
(Rewriter):
* WebGPUShadingLanguageRI/Test.html:
* WebGPUShadingLanguageRI/Test.js:
(TEST_variableShadowing):
(TEST_ifStatement):
(TEST_ifElseStatement):
(TEST_ifElseIfStatement):
(TEST_ifElseIfElseStatement):
(TEST_returnIf):
(TEST_protocolMonoPolySigDoublePolyDefExplicit): Deleted.
* WebGPUShadingLanguageRI/TypeDef.js:
(TypeDef.prototype.toString):
(TypeDef):
* WebGPUShadingLanguageRI/Visitor.js:
(Visitor.prototype.visitIfStatement):
Modified Paths
- trunk/Tools/ChangeLog
- trunk/Tools/WebGPUShadingLanguageRI/All.js
- trunk/Tools/WebGPUShadingLanguageRI/Checker.js
- trunk/Tools/WebGPUShadingLanguageRI/Evaluator.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/TypeDef.js
- trunk/Tools/WebGPUShadingLanguageRI/Visitor.js
Added Paths
Diff
Modified: trunk/Tools/ChangeLog (221775 => 221776)
--- trunk/Tools/ChangeLog 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/ChangeLog 2017-09-08 02:57:23 UTC (rev 221776)
@@ -1,3 +1,80 @@
+2017-09-07 Myles C. Maxfield <[email protected]>
+
+ Add "if" statements to WSL
+ https://bugs.webkit.org/show_bug.cgi?id=176294
+
+ Reviewed by Filip Pizlo.
+
+ Fairly straightforward implementation. ReturnChecker only returns true iff there is an else block,
+ and both the if body and the else body recursively return true.
+
+ In order to accept both syntaxes:
+ if (foo)
+ bar;
+ ... and ...
+ if (foo) {
+ bar;
+ }
+ This patch lets parseStatement() call parseBlock(). This means that the following is valid:
+ int x = 7;
+ if (foo) {
+ int x = 8;
+ // x is 8 here!
+ }
+ // x is 7 here!
+
+ This production means that these blocks don't require "if" statements, so you can just have:
+ int foo() {
+ int x = 7;
+ {
+ int x = 8;
+ // x is 8 here!
+ }
+ // x is 7 here!
+ }
+
+ However, this patch doesn't touch the following use-case:
+ if (int x = bar()) {
+ // use x here
+ }
+
+ * WebGPUShadingLanguageRI/All.js:
+ * WebGPUShadingLanguageRI/Checker.js:
+ * WebGPUShadingLanguageRI/Evaluator.js:
+ (Evaluator.prototype.visitIfStatement):
+ * WebGPUShadingLanguageRI/IfStatement.js: Copied from Tools/WebGPUShadingLanguageRI/TypeDef.js.
+ (IfStatement):
+ (IfStatement.prototype.get origin):
+ (IfStatement.prototype.get conditional):
+ (IfStatement.prototype.get body):
+ (IfStatement.prototype.get elseBody):
+ (IfStatement.prototype.toString):
+ * WebGPUShadingLanguageRI/NameResolver.js:
+ (NameResolver.prototype.visitIfStatement):
+ * WebGPUShadingLanguageRI/Parse.js:
+ (parseTypeParameters):
+ (parseIfStatement):
+ (parseStatement):
+ * WebGPUShadingLanguageRI/ReturnChecker.js:
+ (ReturnChecker.prototype.visitIfStatement):
+ * WebGPUShadingLanguageRI/Rewriter.js:
+ (Rewriter.prototype.visitIfStatement):
+ (Rewriter):
+ * WebGPUShadingLanguageRI/Test.html:
+ * WebGPUShadingLanguageRI/Test.js:
+ (TEST_variableShadowing):
+ (TEST_ifStatement):
+ (TEST_ifElseStatement):
+ (TEST_ifElseIfStatement):
+ (TEST_ifElseIfElseStatement):
+ (TEST_returnIf):
+ (TEST_protocolMonoPolySigDoublePolyDefExplicit): Deleted.
+ * WebGPUShadingLanguageRI/TypeDef.js:
+ (TypeDef.prototype.toString):
+ (TypeDef):
+ * WebGPUShadingLanguageRI/Visitor.js:
+ (Visitor.prototype.visitIfStatement):
+
2017-09-07 Lucas Forschler <[email protected]>
Test commit after server upgrade from subversion 1.9.5 to 1.9.7
Modified: trunk/Tools/WebGPUShadingLanguageRI/All.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/All.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/All.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -65,6 +65,7 @@
load("FuncInstantiator.js");
load("FuncParameter.js");
load("FunctionLikeBlock.js");
+load("IfStatement.js");
load("Inline.js");
load("Inliner.js");
load("InstantiateImmediates.js");
Modified: trunk/Tools/WebGPUShadingLanguageRI/Checker.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/Checker.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/Checker.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -220,11 +220,23 @@
{
let resultType = node.operand.visit(this);
if (!resultType)
- throw new Error("Trying to negate something with no type: " + node.value);
+ throw new Error("Trying to negate something with no type: " + node.operand);
if (!resultType.equals(this._program.intrinsics.bool))
- throw new WError("Trying to negate something that isn't a bool: " + node.value);
+ throw new WError("Trying to negate something that isn't a bool: " + node.operand);
return this._program.intrinsics.bool;
}
+
+ visitIfStatement(node)
+ {
+ let conditionalResultType = node.conditional.visit(this);
+ if (!conditionalResultType)
+ throw new Error("Trying to negate something with no type: " + node.conditional);
+ if (!conditionalResultType.equals(this._program.intrinsics.bool))
+ throw new WError("Trying to negate something that isn't a bool: " + node.conditional);
+ node.body.visit(this);
+ if (node.elseBody)
+ node.elseBody.visit(this);
+ }
visitCommaExpression(node)
{
Modified: trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/Evaluator.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -150,6 +150,14 @@
{
return EPtr.box(!node.operand.visit(this).loadValue());
}
+
+ visitIfStatement(node)
+ {
+ if (node.conditional.visit(this).loadValue())
+ return node.body.visit(this);
+ else if (node.elseBody)
+ return node.elseBody.visit(this);
+ }
visitCallExpression(node)
{
Copied: trunk/Tools/WebGPUShadingLanguageRI/IfStatement.js (from rev 221775, trunk/Tools/WebGPUShadingLanguageRI/TypeDef.js) (0 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/IfStatement.js (rev 0)
+++ trunk/Tools/WebGPUShadingLanguageRI/IfStatement.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -0,0 +1,50 @@
+/*
+ * 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 IfStatement extends Node {
+ constructor(origin, conditional, body, elseBody)
+ {
+ super();
+ this._origin = origin;
+ this._conditional = conditional;
+ this._body = body;
+ this._elseBody = elseBody;
+ }
+
+ get origin() { return this._origin; }
+ get conditional() { return this._conditional; }
+ get body() { return this._body; }
+ get elseBody() { return this._elseBody; }
+
+ toString()
+ {
+ let result = "if (" + this.conditional + ") " + this.body;
+ if (this.elseBody)
+ return result + " else " + this.elseBody;
+ return result;
+ }
+};
+
Modified: trunk/Tools/WebGPUShadingLanguageRI/NameResolver.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/NameResolver.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/NameResolver.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -90,6 +90,15 @@
for (let statement of node.statements)
statement.visit(checker);
}
+
+ visitIfStatement(node)
+ {
+ node.conditional.visit(this);
+ // If statement's bodies might not be Blocks, so we need to explicitly give them a new context.
+ node.body.visit(new NameResolver(new NameContext(this._nameContext)));
+ if (node.elseBody)
+ node.elseBody.visit(new NameResolver(new NameContext(this._nameContext)));
+ }
visitProtocolDecl(node)
{
Modified: trunk/Tools/WebGPUShadingLanguageRI/Parse.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/Parse.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/Parse.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -148,7 +148,7 @@
let type = parseType();
let name = consumeKind("identifier");
assertNext(",", ">", ">>");
- return new ConstexprTypeParameter(type.origin, name, type);
+ return new ConstexprTypeParameter(type.origin, name.text, type);
});
if (constexpr)
result.push(constexpr);
@@ -535,6 +535,19 @@
consume(";");
return new Return(origin, _expression_);
}
+
+ function parseIfStatement()
+ {
+ let origin = consume("if");
+ consume("(");
+ let conditional = parseExpression();
+ consume(")");
+ let body = parseStatement();
+ let elseBody;
+ if (tryConsume("else"))
+ elseBody = parseStatement();
+ return new IfStatement(origin, new CastExpression(conditional.origin, new TypeRef(conditional.origin, "bool", []), [], [conditional]), body, elseBody);
+ }
function parseVariableDecls()
{
@@ -567,6 +580,10 @@
return parseDo();
if (token.text == "for")
return parseFor();
+ if (token.text == "if")
+ return parseIfStatement();
+ if (token.text == "{")
+ return parseBlock();
let variableDecl = lexer.backtrackingScope(parseVariableDecls);
if (variableDecl)
return variableDecl;
Modified: trunk/Tools/WebGPUShadingLanguageRI/ReturnChecker.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/ReturnChecker.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/ReturnChecker.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -40,8 +40,12 @@
// https://bugs.webkit.org/show_bug.cgi?id=176263
return node.statements.reduce((result, statement) => result || statement.visit(this), false);
}
-
- // When we add control flow statements, we'll need to return true only if both blocks return true.
+
+ visitIfStatement(node)
+ {
+ return node.elseBody && node.body.visit(this) && node.elseBody.visit(this);
+ }
+
// If a loop returns, then it counts only if the loop is guaranteed to run at least once.
visitReturn(node)
Modified: trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -283,5 +283,10 @@
{
return new LogicalNot(node.origin, node.operand.visit(this));
}
+
+ visitIfStatement(node)
+ {
+ return new IfStatement(node.origin, node.conditional.visit(this), node.body.visit(this), node.elseBody ? node.elseBody.visit(this) : undefined);
+ }
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.html (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.html 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.html 2017-09-08 02:57:23 UTC (rev 221776)
@@ -41,6 +41,7 @@
<script src=""
<script src=""
<script src=""
+<script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -1109,6 +1109,233 @@
checkInt(program, callFunction(program, "foo", [], [makeInt(program, 54), makeInt(program, 12), makeInt(program, 39)]), 54 + 12 + 39);
}
+function TEST_variableShadowing()
+{
+ let program = doPrep(`
+ int foo()
+ {
+ int y;
+ int x = 7;
+ {
+ int x = 8;
+ y = x;
+ }
+ return y;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], []), 8);
+ program = doPrep(`
+ int foo()
+ {
+ int y;
+ int x = 7;
+ {
+ int x = 8;
+ }
+ y = x;
+ return y;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], []), 7);
+}
+
+function TEST_ifStatement()
+{
+ let program = doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ y = 8;
+ }
+ return y;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 6);
+ 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)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 6);
+}
+
+function TEST_ifElseStatement()
+{
+ let program = doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ y = 8;
+ } else {
+ y = 9;
+ }
+ return y;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 9);
+}
+
+function TEST_ifElseIfStatement()
+{
+ let program = doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ y = 8;
+ } else if (x == 8) {
+ y = 9;
+ }
+ return y;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 6);
+ 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)]), 6);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 6);
+}
+
+function TEST_ifElseIfElseStatement()
+{
+ let program = doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ y = 8;
+ } else if (x == 8) {
+ y = 9;
+ } else {
+ y = 10;
+ }
+ return y;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 10);
+ 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)]), 8);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 10);
+}
+
+function TEST_returnIf()
+{
+ checkFail(
+ () => doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return y;
+ }
+ }
+ `),
+ (e) => e instanceof WTypeError);
+ checkFail(
+ () => doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return y;
+ } else {
+ y = 8;
+ }
+ }
+ `),
+ (e) => e instanceof WTypeError);
+ checkFail(
+ () => doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ y = 8;
+ } else {
+ return y;
+ }
+ }
+ `),
+ (e) => e instanceof WTypeError);
+ let program = doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else {
+ return 10;
+ }
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 10);
+ 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)]), 8);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 10);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 10);
+ checkFail(
+ () => doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else if (x == 9) {
+ return 10;
+ }
+ }
+ `),
+ (e) => e instanceof WTypeError);
+ program = doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else {
+ y = 9;
+ }
+ return y;
+ }
+ `);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 3)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 4)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 5)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 6)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 7)]), 8);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 8)]), 9);
+ checkInt(program, callFunction(program, "foo", [], [makeInt(program, 9)]), 9);
+ checkFail(
+ () => doPrep(`
+ int foo(int x)
+ {
+ int y = 6;
+ if (x == 7) {
+ return 8;
+ } else {
+ return 10;
+ }
+ return 11;
+ }
+ `),
+ (e) => e instanceof WTypeError);
+}
+
function TEST_protocolMonoPolySigDoublePolyDefExplicit()
{
checkFail(
Modified: trunk/Tools/WebGPUShadingLanguageRI/TypeDef.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/TypeDef.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/TypeDef.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -38,5 +38,10 @@
get name() { return this._name; }
get typeParameters() { return this._typeParameters; }
get type() { return this._type; }
+
+ toString()
+ {
+ return "typedef " + this.name + "<" + this.typeParameters + "> = " + this.type;
+ }
}
Modified: trunk/Tools/WebGPUShadingLanguageRI/Visitor.js (221775 => 221776)
--- trunk/Tools/WebGPUShadingLanguageRI/Visitor.js 2017-09-08 01:49:23 UTC (rev 221775)
+++ trunk/Tools/WebGPUShadingLanguageRI/Visitor.js 2017-09-08 02:57:23 UTC (rev 221776)
@@ -208,6 +208,14 @@
node.variable.visit(this);
}
+ visitIfStatement(node)
+ {
+ node.conditional.visit(this);
+ node.body.visit(this);
+ if (node.elseBody)
+ node.elseBody.visit(this);
+ }
+
visitReturn(node)
{
if (node.value)
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
