Open Heath123 opened 2 years ago
Should this be a discussion?
Good point, that text isn't very clear. I edited it now, and added an example - does that help?
(This could be a discussion, yeah - we aren't very strict about that here though.)
Ah, thanks, I see what that meant now - still using the tree structure but storing and loading locals each time. That wasn't quite what I was looking for though, I wanted to generate the normal stack machine instructions so instead of
(i32.add
(local.get $0)
(local.get $1)
)
I could do the normal
(local.get $0)
(local.get $1)
(i32.add)
Is that possible as well? I know BInaryen doesn't use that format internally but it has to be able to understand it to read WASM files, is there an API for it?
There isn't an API for that atm. Binaryen can't even read wat in that format, actually. At least the wat side may get fixed with @tlively 's current work on a new parser, though.
Are you using text, or the C API, or something else?
There isn't an API for that atm. Binaryen can't even read wat in that format, actually. At least the wat side may get fixed with @tlively 's current work on a new parser, though.
Are you using text, or the C API, or something else?
I’m using Python bindings for the C API, I wanted to mess with trying to compile Python bytecode to WASM and since Python bytecode is also a stack machine I wanted to avoid converting it out of the stack machine format and back into it
I’d probably have to convert it out of the stack machine format anyway though because Python bytecode is a lot less strict so maybe that’s not a problem
I have no idea if this will actually be possible but it’s a fun hobby project if I can get it working for simple code I guess
Sounds like a cool project!
I hope adding locals and local operations wouldn't be too hard to do. But eventually it might be nice to add a C API for real stack machine input, where Binaryen would automatically convert it to use locals and local operations.
The page https://github.com/WebAssembly/binaryen/wiki/Compiling-to-WebAssembly-with-Binaryen says:
However, e.g.
BinaryenBinary
takesleft
andright
parameters, and passing innull
results in:So how would I make a module from a list of WebAssembly instructions?