WebAssembly / binaryen

Optimizer and compiler/toolchain library for WebAssembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] How to do type evaluation in Binaryen?

hungryzzz opened this issue · comments

Hi, I found that when I use WasmBinaryReader to parse a type-mismatched wasm file, it would not raise error messages. So I just wonder could I do the type evaluation in Binaryen? i.e., Simulate execution on an abstract stack to determine whether there is a type mismatch. Thank you!

(; example of type-mismatched code ;)
global.get 0
i32.const 32
i64.sub

To check if the module is valid you also need to run validation,

https://github.com/WebAssembly/binaryen/blob/main/src/wasm-validator.h