MCPcopy Index your code
hub / github.com/benediktwerner/rewasm

github.com/benediktwerner/rewasm @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
208 symbols 506 edges 23 files 19 documented · 9% updated 4y agov0.1.0 · 2019-12-27★ 133
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Re:Wasm

rewasm is a decompiler for WebAssembly binaries. It can decompile all WASM binaries from the MVP version 1, however it's still under development so some features, like proper type recovery, are still missing and some binaries still produce pretty unreadable output.

Requirements

Running rewasm requires libz3 (version 4.8.6 or 4.8.7 should work).

Building and Installation

Building or installing rewasm from source requires a working Rust Installation (probably at least version 1.37.0).

To build and install rewasm (this will place the binary in ~/.cargo/bin which should be in your $PATH):

$ git clone https://github.com/benediktwerner/rewasm
$ cargo install --path rewasm
$ rewasm --version

To just build rewasm from source:

$ git clone https://github.com/benediktwerner/rewasm
$ cd rewasm
$ cargo build --release
$ ./target/release/rewasm --version

Usage

Decompile whole file:

$ rewasm example.wasm > example.dec

Decompile a single function (with index 42):

$ rewasm example.wasm 42

Example

Convert examples/loop.wat to a .wasm file using WABT's wat2wasm and decompile it:

$ wat2wasm examples/loop.wat
$ rewasm loop.wasm

Output:

fn func_0(i32 arg_0, i32 arg_1) -> i32 {
    i32 var_2;
    i32 var_3;
    i32 var_4;

    var_2 = 0;
    while var_4 >s 0 {
        var_3 = arg_1;
        while var_3 >s 0 {
            var_2 += 1;
            var_3 += -1;
        }
        var_4 = arg_0 + -1;
    }
    return var_2;
}

Extension points exported contracts — how you extend this code

CodeDisplay (Interface)
(no doc) [8 implementers]
src/fmt.rs

Core symbols most depended-on inside this repo

write
called by 119
src/fmt.rs
binop
called by 76
src/cfg/builder.rs
push
called by 75
src/cfg/builder.rs
write_unop_func
called by 58
src/ssa/expr.rs
write_binop
called by 52
src/ssa/expr.rs
unop
called by 47
src/cfg/builder.rs
pop
called by 35
src/cfg/builder.rs
remove
called by 20
src/dominance.rs

Shape

Method 124
Function 47
Class 24
Enum 12
Interface 1

Languages

Rust100%

Modules by API surface

src/cfg/builder.rs30 symbols
src/ssa/cond.rs23 symbols
src/fmt.rs20 symbols
src/cfg/mod.rs20 symbols
src/ssa/expr.rs14 symbols
src/dominance.rs14 symbols
src/structuring/mod.rs13 symbols
src/analysis/expression_propagation.rs11 symbols
src/ssa/stmt.rs9 symbols
src/ssa/construction.rs9 symbols
src/ssa/structuring.rs8 symbols
src/wasm.rs7 symbols

For agents

$ claude mcp add rewasm \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact