Reputation: 3164
Currently most programming languages, can compile to WebAssembly (officially or through an external package).
So I'm wondering... is it possible to decompile the web assembly file? So we can have the code written in one language that can compile to .wasm
, and decompile it using another language? And then, generate .java
, .js
, .py
, .go
and etc, from the .wasm
file. Is it possible?
Upvotes: 22
Views: 40380
Reputation: 1018
@KadoBOT you can use wasm-decompile.exe to decompile your wasm file https://github.com/WebAssembly/wabt
Upvotes: 6
Reputation: 5693
There is a converter from webassembly binaries to C.
https://github.com/WebAssembly/wabt/tree/master/wasm2c
As written in the other answer it will not look anything of the original source file, but at least it should be able to transfer the logic to C which then again also could be used with other languages by wrapping it into a library.
Upvotes: 21
Reputation: 70160
There are no WebAssembly disassemblers that I am aware of at the moment. One significant obstacle to this is that a great deal of information is discarded in the compilation process. The languages you are interested in (JavaScript, Java, Python, Go) have constructs like strings, classes, structs, etc ... none of which exist at the WebAssembly level. Furthermore, function and variables names are not (typically) present in the resulting WebAssembly module.
While you could create a tool that would 'translate' a WebAssembly module into a Java, Python, Go or JavaScript program that when executed it exhibited the correct behaviour, it would look nothing like the original program that was compiled to WebAssembly.
Upvotes: 20