-
Notifications
You must be signed in to change notification settings - Fork 15
Support AssemblyScript imports #26
Description
I'm proposing adding two function imports for AssemblyScript that work sort-of like wasi does. The Javascript implementations of these functions exist in the assemblyscript loader located here:
The functions are very straight forward and simply write to stdout.
In order to get a string out of an AssemblyScript module, assemblyscript passes up a pointer that points directly at the start of a utf16le string.
The only way to figure out how to determine the size of the string is to inspect the rtSize property of the header block that exists directly before the pointer. The formula is rtSize >>> 1 because rtSize is a byte length not a string length. The header block definition is shaped like the following struct/class:
This file explains the header of each AssemblyScript block which is 16 bytes (32 bit wasm) or (20 bytes in 64 bit wasm) in offset directly before the pointer.
Please ask any questions, because I'm sure I forgot lots of details and this would help assemblyscript devs get started a lot easier.