-
Notifications
You must be signed in to change notification settings - Fork 0
Wasm docs
Minecraft wasm runtime uses wasmtime to run webassembly, so you're welcome to enable any features supported by it. You can see those here: https://webassembly.org/roadmap/
You also want to compile with WASI as the target.
To say what language you're compiling from, export an i32 called language
. Then assign it to whatever the id of the language your using is. If you don't specify a language, it'll assume assemblyscript by default.
AssemblyScript - 0
The language doesn't actually matter as long as you don't try to import or export reference types like strings or arrays. It's only used to determine how to convert those reference types into java objects.
To compile with WASI in AssemblyScript, have import "wasi"
at the top of the file.
You also want to compile with exportRuntime
set to true.
Example:
import "wasi"
export const language: i32 = 0;
These are languages I hope to support in the future, I might have to take stuff off the list due to technical problems, but hopefully not
Will error out when you try to do language specific stuff
I'm very unsure about this one, since the only resources I could find about compiling c# to wasm are about web frameworks.
Webassembly currently only supports numbers and specific reference types, like references to functions. This means that different languages can do whatever they like to make strings and arrays work, which means for any of those types to cross the boundary between wasm and minecraft, we have to know the language.