-
-
Notifications
You must be signed in to change notification settings - Fork 688
Expand file tree
/
Copy pathdecompiler.js
More file actions
25 lines (21 loc) · 652 Bytes
/
decompiler.js
File metadata and controls
25 lines (21 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var binaryen = global.Binaryen = require("../lib/binaryen");
require("ts-node").register({ project: require("path").join(__dirname, "..", "src", "tsconfig.json") });
require("../src/glue/js");
var mod = new binaryen.Module();
var ftype = mod.addFunctionType("i", binaryen.i32, [ ]);
var fn = mod.addFunction("main", ftype, [],
mod.block(null, [
mod.return(
mod.i32.add(
mod.i32.const(1),
mod.i32.const(2)
)
)
])
);
mod.validate();
mod.emitText();
var Decompiler = require("../src/decompiler").Decompiler;
var decompiler = new Decompiler();
decompiler.decompileFunction(fn);
console.log(decompiler.finish());