forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecompiler.js
More file actions
29 lines (25 loc) · 691 Bytes
/
Copy pathdecompiler.js
File metadata and controls
29 lines (25 loc) · 691 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
26
27
28
29
var binaryen = global.binaryen = require("../lib/binaryen");
require("ts-node").register({
project: require("path").join(__dirname, "..", "src", "tsconfig.json"),
compilerHost: true,
files: true
});
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());