原始内容
WASI Preview 1 implementation for MoonBit
⚠️ It's a complete rewrite since 0.17.0
- Wasm Backend
- Wasm-GC Backend
Note: not all APIs are fully tested.
ABI compatibility
This package uses inline wasm helpers to pass MoonBit strings, bytes, and arrays to WASIp1 calls. MoonBit changed the ABI layout for these values so the data pointer no longer needs the old 8-byte offset. This is a breaking change for packages that use inline wasm, but it is not something the MoonBit compiler can detect at the type level.
Use this package with a MoonBit toolchain that has the updated ABI layout. If an older toolchain or older generated bindings are mixed with this package, programs may still compile but fail at runtime with corrupted strings/bytes or traps.
Implemented functions
-
args_get -
args_sizes_get -
environ_get -
environ_sizes_get -
clock_res_get -
clock_time_get -
fd_advise -
fd_allocate -
fd_close -
fd_datasync -
fd_fdstat_get -
fd_fdstat_set_flags -
fd_fdstat_set_rights -
fd_filestat_get -
fd_filestat_set_size -
fd_filestat_set_times -
fd_pread -
fd_prestat_get -
fd_prestat_dir_name -
fd_pwrite -
fd_read -
fd_readdir -
fd_renumber -
fd_seek -
fd_sync -
fd_tell -
fd_write -
path_create_directory -
path_filestat_get -
path_filestat_set_times -
path_link -
path_open -
path_readlink -
path_remove_directory -
path_rename -
path_symlink -
path_unlink_file -
poll_oneoff -
proc_exit -
proc_raise -
sched_yield -
random_get -
sock_accept -
sock_recv -
sock_send -
sock_shutdown
Develop
Testing
- Requirements: you need wasmtime & deno. You may use wasmedge or wamr if you replace the
wasmtimeintest.ts, but it may cause different testing result. - Comamnds:
deno task test:build && deno task test