gpu.js
gpu.js copied to clipboard
why array.length gives an error
const A = [9, 2]; const test = gpu .createKernel(function (A) { return A.length; }) .setOutput([1]); console.log(test(A));
ERROR: throw this.astErrorOutput('Unexpected expression', ast); ^
Error: Unexpected expression on line 1, position 0: A.length at WebGLFunctionNode.astErrorOutput (E:\ProData\G\node_modules\gpu.js\src\backend\function-node.js:972:12) at WebGLFunctionNode.getMemberExpressionDetails (E:\ProData\G\node_modules\gpu.js\src\backend\function-node.js:1305:24) at WebGLFunctionNode.astMemberExpression (E:\ProData\G\node_modules\gpu.js\src\backend\web-gl\function-node.js:1051:14) at WebGLFunctionNode.astGeneric (E:\ProData\G\node_modules\gpu.js\src\backend\function-node.js:944:23) at WebGLFunctionNode.astReturnStatement (E:\ProData\G\node_modules\gpu.js\src\backend\web-gl\function-node.js:168:18) at WebGLFunctionNode.astGeneric (E:\ProData\G\node_modules\gpu.js\src\backend\function-node.js:900:23) at WebGLFunctionNode.astFunction (E:\ProData\G\node_modules\gpu.js\src\backend\web-gl\function-node.js:116:12) at WebGLFunctionNode.astFunctionExpression (E:\ProData\G\node_modules\gpu.js\src\backend\function-node.js:1019:17) at WebGLFunctionNode.astGeneric (E:\ProData\G\node_modules\gpu.js\src\backend\function-node.js:898:23) at WebGLFunctionNode.toString (E:\ProData\G\node_modules\gpu.js\src\backend\function-node.js:324:32)
Unfortunatly, Array.lenght isn't supported in GPU.js yet. You need to find another way.
You can set a constant ahead of time though