WebAssembly interacts with the external environment through imported and exported functions.
If it's a simple function that takes an integer and returns an integer, there is no problem.
However, when trying to use complex data types (such as strings or arrays), the limitation of WebAssembly 1.0 having only 4 types (i32
, i64
, f32
, f64
) becomes an issue.
To represent strings or user-defined types, we have to represent it using these 4 types, and there are no predefined rules on how to represent them in linear memory.
The consumers of these modules need to understand how these data structures are laid out in linear memory and implement glue code accordingly.