-
If I want to write a wasm to wasm tool using Binaryen, that adds some logic into a wasm module, how do I traverse and modify the module's tree? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The C API by itself doesn't have enough, I think. Using C++, you'd write a module traversal (see You can write that C++ in a new pass inside binaryen, or you can write a new program that uses libbinaryen and the C++ API, externally to binaryen. (I don't think we have a way to write an external pass atm: binaryen won't scan for passes in a dynamic way, the list is hardcoded. But external code can do pretty much anything else using the C++ API.) |
Beta Was this translation helpful? Give feedback.
The C API by itself doesn't have enough, I think.
Using C++, you'd write a module traversal (see
wasm-traversal.h
, but it is usually easier to read example code in the various passes, I'd say).You can write that C++ in a new pass inside binaryen, or you can write a new program that uses libbinaryen and the C++ API, externally to binaryen.
(I don't think we have a way to write an external pass atm: binaryen won't scan for passes in a dynamic way, the list is hardcoded. But external code can do pretty much anything else using the C++ API.)