Title: [235533] trunk/Tools
Revision
235533
Author
[email protected]
Date
2018-08-30 17:39:09 -0700 (Thu, 30 Aug 2018)

Log Message

[WHLSL] Fix array indexing behavior
https://bugs.webkit.org/show_bug.cgi?id=189175

Array, pointer, and array ref types are now parsed and then constructed
in reverse so that the declaration order matches the indexing order, as
in C/C++.

Patch by Thomas Denney <[email protected]> on 2018-08-30
Reviewed by Myles C. Maxfield.

* WebGPUShadingLanguageRI/Parse.js:
(parseType):
* WebGPUShadingLanguageRI/Test.js:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (235532 => 235533)


--- trunk/Tools/ChangeLog	2018-08-30 23:32:14 UTC (rev 235532)
+++ trunk/Tools/ChangeLog	2018-08-31 00:39:09 UTC (rev 235533)
@@ -1,3 +1,18 @@
+2018-08-30  Thomas Denney  <[email protected]>
+
+        [WHLSL] Fix array indexing behavior
+        https://bugs.webkit.org/show_bug.cgi?id=189175
+
+        Array, pointer, and array ref types are now parsed and then constructed
+        in reverse so that the declaration order matches the indexing order, as
+        in C/C++.
+
+        Reviewed by Myles C. Maxfield.
+
+        * WebGPUShadingLanguageRI/Parse.js:
+        (parseType):
+        * WebGPUShadingLanguageRI/Test.js:
+
 2018-08-30  Wenson Hsieh  <[email protected]>
 
         Followup to [iOS] TestWebKitAPI.PasteImage tests are flaky failures

Modified: trunk/Tools/WebGPUShadingLanguageRI/Parse.js (235532 => 235533)


--- trunk/Tools/WebGPUShadingLanguageRI/Parse.js	2018-08-30 23:32:14 UTC (rev 235532)
+++ trunk/Tools/WebGPUShadingLanguageRI/Parse.js	2018-08-31 00:39:09 UTC (rev 235533)
@@ -259,24 +259,33 @@
             return consume(...addressSpaces).text;
         }
         
-        while (token = tryConsume("*", "[")) {
+        const typeConstructorStack = [ ];
+
+        for (let token; token = tryConsume("*", "[");) {
             if (token.text == "*") {
-                type = new PtrType(token, getAddressSpace(), type);
+                // Likewise, the address space must be parsed before parsing continues.
+                const addressSpace = getAddressSpace();
+                typeConstructorStack.unshift(type => new PtrType(token, addressSpace, type));
                 continue;
             }
-            
+
             if (tryConsume("]")) {
-                type = new ArrayRefType(token, getAddressSpace(), type);
+                const addressSpace = getAddressSpace();
+                typeConstructorStack.unshift(type => new ArrayRefType(token, addressSpace, type));
                 continue;
             }
-            
-            type = new ArrayType(token, type, parseConstexpr());
+
+            const lengthExpr = parseConstexpr();
+            typeConstructorStack.unshift(type => new ArrayType(token, type, lengthExpr));
             consume("]");
         }
-        
+
+        for (let constructor of typeConstructorStack)
+            type = constructor(type);
+
         if (addressSpace && !addressSpaceConsumed)
             lexer.fail("Address space specified for type that does not need address space");
-        
+
         return type;
     }
     

Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (235532 => 235533)


--- trunk/Tools/WebGPUShadingLanguageRI/Test.js	2018-08-30 23:32:14 UTC (rev 235532)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js	2018-08-31 00:39:09 UTC (rev 235533)
@@ -5551,7 +5551,7 @@
     checkFloat(program, callFunction(program, "foo13", []), 29 * 7 + 43 * 11 + 61 * 13);
 }
 
-tests.DISABLED_arrayIndex = function() {
+tests.arrayIndex = function() {
     let program = doPrep(`
         uint innerArrayLength() {
             int[2][3] array;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to