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

Code generation without depending on gotos #29

Open
swang206 opened this issue Aug 23, 2021 · 1 comment
Open

Code generation without depending on gotos #29

swang206 opened this issue Aug 23, 2021 · 1 comment
Labels
suggestion I want this please

Comments

@swang206
Copy link

It is very unfortunate world of warcraft uses Lua 5.1 which does not provide goto.

Although bit is provided, it does not provide all the functions that bitops provide which means they have to be emulated with lua apis itself.

BTW, how can I deal with wasi syscalls? should I implement those syscalls by myself?

    function __FUNCS__.func_3(reg0, reg1, reg2, reg3)
        local reg4;
        reg4 = __IMPORTS__.wasi_snapshot_preview1.fd_write(reg0,reg1,reg2,reg3);
        do return (bit_band(reg4,65535)); end;
    end
    function __FUNCS__.func_4(reg0)
        __IMPORTS__.wasi_snapshot_preview1.proc_exit(reg0);
        error('unreachable');
    end
@SwadicalRag
Copy link
Owner

SwadicalRag commented Aug 24, 2021

It's been a while since I've last worked on this but if memory serves right, gotos were used because there is a limit to how far a lua vm can do a jump: wasm2lua uses these goto trampolines to split very large jump instructions into multiple smaller gotos.

It is theoretically possible to work around this by rewriting the compiler (and I recall having different ideas on how to do this, like by wrapping each simple statement block into their own stateless functions)

Another use for gotos in wasm2lua is for setjmp emulation - I bet it's theoretically possible to figure something out without gotos but...

I'm glad that you find this silly project useful, however I am no longer insane enough to continue to work on this project (but you are more than welcome to do whatever you want, so long as the license permits).

And yes, WASI syscalls need to be self-implemented (a la https://github.com/SwadicalRag/wasm2lua/blob/master/resources/wasilib.lua )

@SwadicalRag SwadicalRag changed the title world of warcraft addon support? Code generation without depending on gotos Aug 24, 2021
@SwadicalRag SwadicalRag added the suggestion I want this please label Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion I want this please
Projects
None yet
Development

No branches or pull requests

2 participants