If we assume that structs are always going to be stored in memory (which for the time being, it's fine if they are), a relatively simple implementation for them presents itself in that we can just replace getfield and setfield! with calls to load/store memory operations at the offset given by fieldoffset.
(I don't really know what alignment is and I can't seem to find out how to set it to the default value that the wasm compiler uses, so for the time being it's just set to 1, it seems to only effect efficiency and not correctness.)
If we assume that structs are always going to be stored in memory (which for the time being, it's fine if they are), a relatively simple implementation for them presents itself in that we can just replace
getfield
andsetfield!
with calls to load/store memory operations at the offset given byfieldoffset
.(I don't really know what alignment is and I can't seem to find out how to set it to the default value that the wasm compiler uses, so for the time being it's just set to 1, it seems to only effect efficiency and not correctness.)
Here's the decompiled output:
addTwo
Adds the two values in the struct together and returns the result andaltertwo
sets the first value to the second and returns the struct.