Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle WithStatement for kernels #804

Open
emptyflash opened this issue Dec 4, 2022 · 0 comments
Open

Handle WithStatement for kernels #804

emptyflash opened this issue Dec 4, 2022 · 0 comments

Comments

@emptyflash
Copy link

A GIF or MEME to give some spice of the internet

What is wrong?

When using a javascript with statement, you get Error: unhandled type "WithStatement"

Error: unhandled type "WithStatement"
    at FunctionTracer.scan (gpu-browser.js:8658:15)
    at FunctionTracer.scan (gpu-browser.js:8481:14)
    at gpu-browser.js:8493:16
    at FunctionTracer.newContext (gpu-browser.js:8433:5)
    at FunctionTracer.scan (gpu-browser.js:8492:14)
    at FunctionTracer.scan (gpu-browser.js:8555:16)
    at new FunctionTracer (gpu-browser.js:8392:10)
    at WebGL2FunctionNode.traceFunctionAST (gpu-browser.js:7182:79)
    at WebGL2FunctionNode.getJsAST (gpu-browser.js:7172:10)
    at WebGL2FunctionNode.toString (gpu-browser.js:7281:48)

Where does it happen?

Pretty much any system, just missing functionality

How do we replicate the issue?

const { GPU } = require('gpu.js');
const gpu = new GPU();
const calcCircle = gpu.createKernel(function(r) {
    with (Math) {
      a = PI * r * r;
      x = r * cos(PI);
      y = r * sin(PI / 2);
    }
}).setOutput([512, 512]);

const c = calcCircle(a, b);

How important is this (1-5)?

2-3

Expected behavior (i.e. solution)

It should update the scope to be able to look up variables in the Math namespace.

Other Comments

Mostly just a nice to have, might tackle this issue if I have some free time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant