mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 02:31:41 +00:00
Rework loop compilation / flows (#644)
This commit is contained in:
25
tests/binaryen/unreachable-spam.js
Normal file
25
tests/binaryen/unreachable-spam.js
Normal file
@ -0,0 +1,25 @@
|
||||
var binaryen = require("binaryen");
|
||||
|
||||
var mod = new binaryen.Module();
|
||||
var funcType = mod.addFunctionType("ii", binaryen.i32, [ binaryen.i32 ]);
|
||||
mod.addFunction("0", funcType, [],
|
||||
mod.block(null, [
|
||||
mod.loop("continue",
|
||||
mod.block(null, [
|
||||
mod.if(
|
||||
mod.local.get(0, binaryen.i32),
|
||||
mod.return(mod.i32.const(1)),
|
||||
mod.return(mod.i32.const(2))
|
||||
),
|
||||
mod.unreachable()
|
||||
])
|
||||
),
|
||||
mod.unreachable()
|
||||
], binaryen.i32)
|
||||
);
|
||||
mod.addExport("0", "0");
|
||||
|
||||
if (!mod.validate())
|
||||
console.log("-> does not validate");
|
||||
console.log(mod.emitText());
|
||||
console.log(mod.emitStackIR(/*true*/)); // optimize-stack-ir fixes this
|
Reference in New Issue
Block a user