Implement reference counting (#592)

This commit is contained in:
Daniel Wirtz
2019-06-05 23:15:39 +02:00
committed by GitHub
parent 3ed76a97f0
commit 0484a6b740
601 changed files with 261645 additions and 146131 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();