Remix.run Logo
keithwinstein 2 hours ago

I can't speak to Binaryen, but afaik WABT's wat2wasm and wasm-tools's wat2wasm (aka wasm-tools parse) are both 100% spec-correct in this respect. Parsing the Wasm text format doesn't require any knowledge of the type of each instruction. If you have a counterexample would love to see it!

There are some cool edge cases if you want to print a mismatched multi-value instruction sequence in the folded form (which WABT and wasm-tools again handle "correctly," but not identically to each other, and not particularly meaningfully).

asibahi 2 hours ago | parent [-]

This is the wat2wasm tool I have been playing with: https://webassembly.github.io/wabt/demo/wat2wasm/

It refuses to accept the following

    (module
      (func (export "addTwo") (param i32 i32) (result i32)
        (i32.add 
          local.get 0
          local.get 1
        )
      )
    )
which based on my reading should be accepted.

I will try the tools you mentioned but I personally settled on generating the unfolded ones for my experiments as they just seem easier.