use gc interface directly, document

This commit is contained in:
dcode
2019-03-26 23:35:08 +01:00
parent 7c0dc66849
commit 3146f8f9e0
95 changed files with 17360 additions and 13504 deletions

View File

@ -0,0 +1,24 @@
var binaryen = require("binaryen");
var mod = new binaryen.Module();
var ftype = mod.addFunctionType("ii", binaryen.i32, [ binaryen.i32 ]);
mod.addFunction("test", ftype, [],
mod.block("label", [
mod.drop( // "br_if returns the value too"
mod.break("label",
// condition: $0 == 1
mod.i32.eq(
mod.getLocal(0, binaryen.i32),
mod.i32.const(1)
),
// value: 1
mod.i32.const(1)
)
),
// push: 0
mod.i32.const(0)
], binaryen.i32)
);
console.log(mod.emitText());
mod.validate();