Title: [221692] trunk/Tools
Revision
221692
Author
[email protected]
Date
2017-09-06 13:03:59 -0700 (Wed, 06 Sep 2017)

Log Message

WSL: Inliner doesn't allow double-negation
https://bugs.webkit.org/show_bug.cgi?id=176440

Reviewed by Mylex Maxfield.
        
The problem was that we were visiting the operands to calls while inside doVisit. This is too strict
since it rejects nested calls like foo(foo(x)). The solution is to visit the operands to calls before
entering doVisit.
        
This also fixes some other issues in the parser that made the Inliner's error really strange.

* WebGPUShadingLanguageRI/Func.js:
(Func):
* WebGPUShadingLanguageRI/Inliner.js:
(Inliner.prototype.visitCallExpression):
(Inliner):
* WebGPUShadingLanguageRI/Parse.js:
(parseOperatorFuncDefValues):
(parseNonOperatorFuncDefValues):
(parseGenericFuncDefValues):
(parseFuncDecl):
* WebGPUShadingLanguageRI/Test.js:
* WebGPUShadingLanguageRI/VisitingSet.js:
(VisitingSet.prototype.doVisit):
(VisitingSet):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (221691 => 221692)


--- trunk/Tools/ChangeLog	2017-09-06 19:46:38 UTC (rev 221691)
+++ trunk/Tools/ChangeLog	2017-09-06 20:03:59 UTC (rev 221692)
@@ -1,3 +1,31 @@
+2017-09-06  Filip Pizlo  <[email protected]>
+
+        WSL: Inliner doesn't allow double-negation
+        https://bugs.webkit.org/show_bug.cgi?id=176440
+
+        Reviewed by Mylex Maxfield.
+        
+        The problem was that we were visiting the operands to calls while inside doVisit. This is too strict
+        since it rejects nested calls like foo(foo(x)). The solution is to visit the operands to calls before
+        entering doVisit.
+        
+        This also fixes some other issues in the parser that made the Inliner's error really strange.
+
+        * WebGPUShadingLanguageRI/Func.js:
+        (Func):
+        * WebGPUShadingLanguageRI/Inliner.js:
+        (Inliner.prototype.visitCallExpression):
+        (Inliner):
+        * WebGPUShadingLanguageRI/Parse.js:
+        (parseOperatorFuncDefValues):
+        (parseNonOperatorFuncDefValues):
+        (parseGenericFuncDefValues):
+        (parseFuncDecl):
+        * WebGPUShadingLanguageRI/Test.js:
+        * WebGPUShadingLanguageRI/VisitingSet.js:
+        (VisitingSet.prototype.doVisit):
+        (VisitingSet):
+
 2017-09-06  Myles C. Maxfield  <[email protected]>
 
         WSL should support the bool type

Modified: trunk/Tools/WebGPUShadingLanguageRI/Func.js (221691 => 221692)


--- trunk/Tools/WebGPUShadingLanguageRI/Func.js	2017-09-06 19:46:38 UTC (rev 221691)
+++ trunk/Tools/WebGPUShadingLanguageRI/Func.js	2017-09-06 20:03:59 UTC (rev 221692)
@@ -27,6 +27,8 @@
 class Func extends Node {
     constructor(origin, name, returnType, typeParameters, parameters, isCast)
     {
+        if (!(origin instanceof LexerToken))
+            throw new Error("Bad origin: " + origin);
         super();
         this._origin = origin;
         this._name = name;

Modified: trunk/Tools/WebGPUShadingLanguageRI/Inliner.js (221691 => 221692)


--- trunk/Tools/WebGPUShadingLanguageRI/Inliner.js	2017-09-06 19:46:38 UTC (rev 221691)
+++ trunk/Tools/WebGPUShadingLanguageRI/Inliner.js	2017-09-06 20:03:59 UTC (rev 221692)
@@ -43,19 +43,16 @@
     
     visitCallExpression(node)
     {
+        let result = super.visitCallExpression(node);
         return this._visiting.doVisit(node.func, () => {
-            let func = this._program.funcInstantiator.getUnique(node.func, node.actualTypeArguments);
+            let func = this._program.funcInstantiator.getUnique(result.func, result.actualTypeArguments);
             if (func.isNative) {
-                let result = super.visitCallExpression(node);
                 result.nativeFuncInstance = func;
                 return result;
             }
             _inlineFunction(this._program, func, this._visiting);
             return new FunctionLikeBlock(
-                node.origin,
-                func.returnType,
-                node.argumentList.map(argument => argument.visit(this)),
-                func.parameters, func.body);
+                result.origin, func.returnType, result.argumentList, func.parameters, func.body);
         });
     }
 

Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (221691 => 221692)


--- trunk/Tools/WebGPUShadingLanguageRI/Test.js	2017-09-06 19:46:38 UTC (rev 221691)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js	2017-09-06 20:03:59 UTC (rev 221692)
@@ -977,6 +977,18 @@
         });
 }
 
+function TEST_doubleNot()
+{
+    let program = doPrep(`
+        bool foo(bool x)
+        {
+            return !!x;
+        }
+    `);
+    checkBool(program, callFunction(program, "foo", [], [makeBool(program, true)]), true);
+    checkBool(program, callFunction(program, "foo", [], [makeBool(program, false)]), false);
+}
+
 let filter = /.*/; // run everything by default
 if (this["arguments"]) {
     for (let i = 0; i < arguments.length; i++) {

Modified: trunk/Tools/WebGPUShadingLanguageRI/VisitingSet.js (221691 => 221692)


--- trunk/Tools/WebGPUShadingLanguageRI/VisitingSet.js	2017-09-06 19:46:38 UTC (rev 221691)
+++ trunk/Tools/WebGPUShadingLanguageRI/VisitingSet.js	2017-09-06 20:03:59 UTC (rev 221692)
@@ -33,7 +33,7 @@
     doVisit(item, callback)
     {
         if (this._set.has(item))
-            throw new WTypeError(item.origin.originString, "Recursive " + item.kind);
+            throw new WTypeError(item.origin.originString, "Recursive " + item.kind.name);
         this._set.add(item);
         try {
             return callback();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to