1
0
mirror of https://github.com/fluencelabs/assemblyscript synced 2025-07-15 22:32:16 +00:00
Files
bin
dist
examples
lib
media
scripts
snap
src
std
tests
allocators
binaryen
asmjs.wat
block-stack.js
get_global-missing.js
get_local-missing.js
i64-binary-result.js
optimize-if-eqz.js
optimize-if-eqz.wat
precompute-join.wat
set_global-immutable.js
compiler
parser
util
.gitignore
README.md
compiler.js
decompiler.js
parser.js
tokenizer.js
util-path.js
.gitattributes
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
NOTICE
README.md
index.d.ts
index.js
package-lock.json
package.json
tsconfig-base.json
tsconfig-docs.json
tslint.json
webpack.config.js
assemblyscript/tests/binaryen/block-stack.js
2017-12-03 01:18:35 +01:00

20 lines
545 B
JavaScript

var binaryen = require("binaryen");
// "non-final block elements returning a value must be drop()ed"
// "0 == 0: block with value must not have last element that is none, on"
var mod = new binaryen.Module();
var funcType = mod.addFunctionType("i", binaryen.i32, []);
var func = mod.addFunction("test", funcType, [ binaryen.i32 ],
mod.block("", [
mod.teeLocal(0, mod.i32.const(1)),
mod.nop()
], binaryen.i32)
);
mod.addExport("test", func);
console.log(mod.emitText());
if (!mod.validate())
console.log("-> does not validate");