Title: [235470] trunk/Tools
- Revision
- 235470
- Author
- [email protected]
- Date
- 2018-08-29 11:24:45 -0700 (Wed, 29 Aug 2018)
Log Message
[WHLSL] Ensure that isLValue is copied by the rewriter
https://bugs.webkit.org/show_bug.cgi?id=189083
The value of isLValue was not propagated when new TernaryExpressions are
created in Rewriter.
Patch by Thomas Denney <[email protected]> on 2018-08-29
Reviewed by Myles C. Maxfield.
* WebGPUShadingLanguageRI/Rewriter.js:
(Rewriter.prototype.visitTernaryExpression):
* WebGPUShadingLanguageRI/Test.js: Add new test to verify the value is
propagated.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (235469 => 235470)
--- trunk/Tools/ChangeLog 2018-08-29 18:21:49 UTC (rev 235469)
+++ trunk/Tools/ChangeLog 2018-08-29 18:24:45 UTC (rev 235470)
@@ -1,3 +1,18 @@
+2018-08-29 Thomas Denney <[email protected]>
+
+ [WHLSL] Ensure that isLValue is copied by the rewriter
+ https://bugs.webkit.org/show_bug.cgi?id=189083
+
+ The value of isLValue was not propagated when new TernaryExpressions are
+ created in Rewriter.
+
+ Reviewed by Myles C. Maxfield.
+
+ * WebGPUShadingLanguageRI/Rewriter.js:
+ (Rewriter.prototype.visitTernaryExpression):
+ * WebGPUShadingLanguageRI/Test.js: Add new test to verify the value is
+ propagated.
+
2018-08-29 Myles C. Maxfield <[email protected]>
[WHLSL] Add more functions to the standard library
Modified: trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js (235469 => 235470)
--- trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2018-08-29 18:21:49 UTC (rev 235469)
+++ trunk/Tools/WebGPUShadingLanguageRI/Rewriter.js 2018-08-29 18:24:45 UTC (rev 235470)
@@ -167,7 +167,9 @@
visitTernaryExpression(node)
{
- return new TernaryExpression(node.origin, node.predicate.visit(this), node.bodyExpression.visit(this), node.elseExpression.visit(this));
+ let result = new TernaryExpression(node.origin, node.predicate.visit(this), node.bodyExpression.visit(this), node.elseExpression.visit(this));
+ result.isLValue = node.isLValue;
+ return result;
}
_handlePropertyAccessExpression(result, node)
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (235469 => 235470)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-08-29 18:21:49 UTC (rev 235469)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-08-29 18:24:45 UTC (rev 235470)
@@ -273,6 +273,29 @@
(e) => e instanceof WTypeError);
}
+tests.ternaryExpressionIsLValue = function() {
+ function ternaryExpressionIsLValue(node)
+ {
+ let isLValue;
+ class TernaryExpressionVisitor extends Visitor {
+ visitTernaryExpression(node)
+ {
+ isLValue = node.isLValue;
+ }
+ }
+ node.visit(new TernaryExpressionVisitor());
+ return isLValue;
+ }
+
+ let program = doPrep(`int foo() { return 0 < 1 ? 0 : 1; }`);
+ if (ternaryExpressionIsLValue(program))
+ throw new Error(`r-value ternary _expression_ incorrectly parsed as l-value`);
+
+ program = doPrep(`void foo() { int x; int y; (0 < 1 ? x : y) = 1; }`);
+ if (!ternaryExpressionIsLValue(program))
+ throw new Error(`l-value ternary _expression_ incorrectly parsed as r-value`);
+}
+
tests.literalBool = function() {
let program = doPrep("bool foo() { return true; }");
checkBool(program, callFunction(program, "foo", []), true);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes