Skip to content

Support AssemblyScript imports #26

@jtenner

Description

@jtenner

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:

https://github.com/AssemblyScript/assemblyscript/blob/master/lib/loader/index.js#L70

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:

https://github.com/AssemblyScript/assemblyscript/blob/master/std/assembly/rt/common.ts#L36

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions