Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

@@ -0,0 +1,61 @@
module builtin
// print prints a message to stdout. Unlike `println` stdout is not automatically flushed.
pub fn print(s string) {
elm := CIOVec{
buf: s.str
len: usize(s.len)
}
WASM.fd_write(1, &elm, 1, 0)
}
// println prints a message with a line end, to stdout.
pub fn println(s string) {
elm := [CIOVec{
buf: s.str
len: usize(s.len)
}, CIOVec{
buf: c'\n'
len: 1
}]!
WASM.fd_write(1, &elm[0], 2, 0)
}
// eprint prints a message to stderr.
pub fn eprint(s string) {
elm := CIOVec{
buf: s.str
len: usize(s.len)
}
WASM.fd_write(2, &elm, 1, 0)
}
// eprintln prints a message with a line end, to stderr.
pub fn eprintln(s string) {
elm := [CIOVec{
buf: s.str
len: usize(s.len)
}, CIOVec{
buf: c'\n'
len: 1
}]!
WASM.fd_write(2, &elm[0], 2, 0)
}
// exit terminates execution immediately and returns exit `code` to the shell.
@[noreturn]
pub fn exit(code int) {
WASM.proc_exit(code)
}
// panic prints a nice error message, then exits the process with exit code of 1.
@[noreturn]
pub fn panic(s string) {
eprint('V panic: ')
eprintln(s)
exit(1)
}
@@ -0,0 +1,32 @@
module builtin
pub struct CIOVec {
pub:
buf &u8
len usize
}
type Errno = u16
type FileDesc = int
@[wasm_import_namespace: 'wasi_snapshot_preview1']
fn WASM.args_sizes_get(argc &u32, argc_buf_size &u32) Errno
@[wasm_import_namespace: 'wasi_snapshot_preview1']
fn WASM.args_get(argv &&u8, argv_buf &u8) Errno
@[wasm_import_namespace: 'wasi_snapshot_preview1']
fn WASM.fd_write(fd FileDesc, iovs &CIOVec, iovs_len usize, retptr &usize) Errno
@[wasm_import_namespace: 'wasi_snapshot_preview1']
fn WASM.fd_read(fd FileDesc, iovs &CIOVec, iovs_len usize, nread &usize) Errno
@[wasm_import_namespace: 'wasi_snapshot_preview1']
fn WASM.fd_sync(fd FileDesc) Errno
@[wasm_import_namespace: 'wasi_snapshot_preview1']
fn WASM.random_get(buf &u8, buf_len usize) Errno
@[wasm_import_namespace: 'wasi_snapshot_preview1']
@[noreturn]
fn WASM.proc_exit(rval int)