Skip to main content
100%

WebAssembly transform giving support for multi return values

✓ Published0🌍 Public
CColinEberhardt
Last edited May 29, 2018
Created on May 29, 2018

This example demonstrates a WebAssembly transformation that rewrites WebAssembly text (WAT) modules to support multiple return values, a feature not natively supported. The code parses an input `.wat` file using `@webassemblyjs/wast-parser`, traverses and modifies the abstract syntax tree, and prints the result with `@webassemblyjs/wast-printer`. It calculates the maximum function return count, inserts global variables, and rewrites call sites, replacing multi-value returns with `set_global` and `get_global` instructions. The transform relies on the `traverse` API to visit `Func` and `CallInstruction` nodes.

AI-generated description

Similar vizzes