Closed JustinSDK closed 6 years ago
Seems like a bug in libwabt. I hope package https://www.npmjs.com/package/wabt will be updated. If not, i will use webassemblyjs again.
FYI: There are new versions of wabt.js now, preferrably v1.0.5-nightly.20180920. Note that the API to instantiate it has changed a little (WABT now uses Emscripten's MODULARIZE):
// old
var wabt = require("wabt");
// new
var wabt = require("wabt")();
@dcodeIO Unfortunately, wast@latest
and wabt@1.0.5-nightly.20180922
compiled that code incorrectly. This is a generated wasm:
(module
(type $t0 (func (param i32)))
(type $t1 (func))
(import "env" "log" (func $log (type $t0)))
(func $main (type $t1)
block $B0
block $B1
br 3228196 (; INVALID ;)
i32.const 3
call $log
end
i32.const 2
call $log
end
i32.const 1
call $log)
(start 1))
Probably, it's a bug in original wabt?
Seems so, yeah, or somehow just in its JS build. Appears that br $LABEL
always becomes br
+ some pointer value after parsing, as if a string wasn't correctly evaluated/printed.
For a likely solution to the issue, see: https://github.com/WebAssembly/wabt/issues/915#issuecomment-423859867
Thanks @dcodeIO @binji for your help!
When writing the code:
After right-clicking the .wat file, 'Save as WebAssembly binary file' and saving a 'program.wasm' file, l use the html:
And loading it by Chrome, it says:
The same code is ok after assembling and downloading .wasm from WebAssembly Explorer.