mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 01:11:32 +00:00
use gc interface directly, document
This commit is contained in:
24
tests/binaryen/break-value.js
Normal file
24
tests/binaryen/break-value.js
Normal 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();
|
Reference in New Issue
Block a user