small error improvements; moved where proc directives go
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 30 Aug 2020 17:10:33 +0000 (12:10 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 30 Aug 2020 17:10:33 +0000 (12:10 -0500)
core/intrinsics.onyx
core/printing.onyx
core/wasi.onyx
include/bh.h
onyx
progs/poly_test.onyx
src/onyxchecker.c
src/onyxparser.c

index cf4364dc29066002a70471bbec66185fb329f9cc..3d727272d430a93db3af240327078a99b4f883ef 100644 (file)
@@ -1,48 +1,48 @@
 package intrinsics
 
-memory_size  :: proc #intrinsic -> i32 ---
-memory_grow  :: proc #intrinsic (val: i32) -> i32 ---
+memory_size  :: proc -> i32 #intrinsic ---
+memory_grow  :: proc (val: i32) -> i32 #intrinsic ---
 
-clz_i32      :: proc #intrinsic (val: i32) -> i32 ---
-ctz_i32      :: proc #intrinsic (val: i32) -> i32 ---
-popcnt_i32   :: proc #intrinsic (val: i32) -> i32 ---
-and_i32      :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
-or_i32       :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
-xor_i32      :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
-shl_i32      :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
-slr_i32      :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
-sar_i32      :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
-rotl_i32     :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
-rotr_i32     :: proc #intrinsic (lhs: i32, rhs: i32) -> i32 ---
+clz_i32      :: proc (val: i32) -> i32 #intrinsic ---
+ctz_i32      :: proc (val: i32) -> i32 #intrinsic ---
+popcnt_i32   :: proc (val: i32) -> i32 #intrinsic ---
+and_i32      :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+or_i32       :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+xor_i32      :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+shl_i32      :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+slr_i32      :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+sar_i32      :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+rotl_i32     :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
+rotr_i32     :: proc (lhs: i32, rhs: i32) -> i32 #intrinsic ---
 
-clz_i64      :: proc #intrinsic (val: i64) -> i64 ---
-ctz_i64      :: proc #intrinsic (val: i64) -> i64 ---
-popcnt_i64   :: proc #intrinsic (val: i64) -> i64 ---
-and_i64      :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
-or_i64       :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
-xor_i64      :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
-shl_i64      :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
-slr_i64      :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
-sar_i64      :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
-rotl_i64     :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
-rotr_i64     :: proc #intrinsic (lhs: i64, rhs: i64) -> i64 ---
+clz_i64      :: proc (val: i64) -> i64 #intrinsic ---
+ctz_i64      :: proc (val: i64) -> i64 #intrinsic ---
+popcnt_i64   :: proc (val: i64) -> i64 #intrinsic ---
+and_i64      :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+or_i64       :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+xor_i64      :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+shl_i64      :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+slr_i64      :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+sar_i64      :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+rotl_i64     :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
+rotr_i64     :: proc (lhs: i64, rhs: i64) -> i64 #intrinsic ---
 
-abs_f32      :: proc #intrinsic (val: f32) -> f32 ---
-ceil_f32     :: proc #intrinsic (val: f32) -> f32 ---
-floor_f32    :: proc #intrinsic (val: f32) -> f32 ---
-trunc_f32    :: proc #intrinsic (val: f32) -> f32 ---
-nearest_f32  :: proc #intrinsic (val: f32) -> f32 ---
-sqrt_f32     :: proc #intrinsic (val: f32) -> f32 ---
-min_f32      :: proc #intrinsic (lhs: f32, rhs: f32) -> f32 ---
-max_f32      :: proc #intrinsic (lhs: f32, rhs: f32) -> f32 ---
-copysign_f32 :: proc #intrinsic (lhs: f32, rhs: f32) -> f32 ---
+abs_f32      :: proc (val: f32) -> f32 #intrinsic ---
+ceil_f32     :: proc (val: f32) -> f32 #intrinsic ---
+floor_f32    :: proc (val: f32) -> f32 #intrinsic ---
+trunc_f32    :: proc (val: f32) -> f32 #intrinsic ---
+nearest_f32  :: proc (val: f32) -> f32 #intrinsic ---
+sqrt_f32     :: proc (val: f32) -> f32 #intrinsic ---
+min_f32      :: proc (lhs: f32, rhs: f32) -> f32 #intrinsic ---
+max_f32      :: proc (lhs: f32, rhs: f32) -> f32 #intrinsic ---
+copysign_f32 :: proc (lhs: f32, rhs: f32) -> f32 #intrinsic ---
 
-abs_f64      :: proc #intrinsic (val: f64) -> f64 ---
-ceil_f64     :: proc #intrinsic (val: f64) -> f64 ---
-floor_f64    :: proc #intrinsic (val: f64) -> f64 ---
-trunc_f64    :: proc #intrinsic (val: f64) -> f64 ---
-nearest_f64  :: proc #intrinsic (val: f64) -> f64 ---
-sqrt_f64     :: proc #intrinsic (val: f64) -> f64 ---
-min_f64      :: proc #intrinsic (lhs: f64, rhs: f64) -> f64 ---
-max_f64      :: proc #intrinsic (lhs: f64, rhs: f64) -> f64 ---
-copysign_f64 :: proc #intrinsic (lhs: f64, rhs: f64) -> f64 ---
+abs_f64      :: proc (val: f64) -> f64 #intrinsic ---
+ceil_f64     :: proc (val: f64) -> f64 #intrinsic ---
+floor_f64    :: proc (val: f64) -> f64 #intrinsic ---
+trunc_f64    :: proc (val: f64) -> f64 #intrinsic ---
+nearest_f64  :: proc (val: f64) -> f64 #intrinsic ---
+sqrt_f64     :: proc (val: f64) -> f64 #intrinsic ---
+min_f64      :: proc (lhs: f64, rhs: f64) -> f64 #intrinsic ---
+max_f64      :: proc (lhs: f64, rhs: f64) -> f64 #intrinsic ---
+copysign_f64 :: proc (lhs: f64, rhs: f64) -> f64 #intrinsic ---
index dc56e8870cb68e2dcf57eee9c73686338848e967..9569ed3ee223fdc6137a5de062f4b5e6dfb2f6f7 100644 (file)
@@ -1,10 +1,10 @@
 package printing
 
-print_bool :: proc #foreign "host" "print" (value: bool) ---
-print_i32  :: proc #foreign "host" "print" (value: i32) ---
-print_f32  :: proc #foreign "host" "print" (value: f32) ---
-print_i64  :: proc #foreign "host" "print" (value: i64) ---
-print_f64  :: proc #foreign "host" "print" (value: f64) ---
+print_bool :: proc (value: bool) #foreign "host" "print" ---
+print_i32  :: proc (value: i32)  #foreign "host" "print" ---
+print_f32  :: proc (value: f32)  #foreign "host" "print" ---
+print_i64  :: proc (value: i64)  #foreign "host" "print" ---
+print_f64  :: proc (value: f64)  #foreign "host" "print" ---
 
 PrintableArray :: struct {
     data: ^u8;
@@ -36,7 +36,7 @@ print_str_by_byte :: proc (str: ^u8) {
     }
 }
 
-print_str :: proc #foreign "host" "print_str" (str: ^u8) ---
+print_str :: proc (str: ^u8) #foreign "host" "print_str" ---
 
 print_str_len :: proc (str: [] u8, len: i32) {
     for i: 0, len do print(cast(i32) str[i]);
index 0f7a3a6bb86f9e0d6d3dc451e0727884bf4806ea..35122dbe5d82ab0a35959505a9b5ca9b18cbaf45 100644 (file)
@@ -356,65 +356,43 @@ IOVecArray :: struct {
 
 
 // FUNCTIONS
-args_get       :: proc #foreign "wasi_snapshot_preview1" "args_get" (argv: ^^u8, argv_buf: ^u8) -> Errno ---
-args_sizes_get :: proc #foreign "wasi_snapshot_preview1" "args_sizes_get" (argc: ^Size, argv_buf_size: ^Size) -> Errno ---
-
-environ_get       :: proc #foreign "wasi_snapshot_preview1" "environ_get" (environ: ^^u8, environ_buf: ^u8) -> Errno ---
-environ_sizes_get :: proc #foreign "wasi_snapshot_preview1" "environ_sizes_get" (environc: ^Size, environ_buf_size: ^Size) -> Errno ---
-
-clock_res_get  :: proc #foreign "wasi_snapshot_preview1" "clock_res_get" (id: ClockID, resolution: ^Timestamp) -> Errno ---
-clock_time_get :: proc #foreign "wasi_snapshot_preview1" "clock_time_get" (id: ClockID, precision: Timestamp, time: ^Timestamp) -> Errno ---
-
-fd_advise             :: proc #foreign "wasi_snapshot_preview1" "fd_advise" (fd: FileDescriptor, offset: Filesize, len: Filesize, advice: Advice) -> Errno ---
-fd_allocate           :: proc #foreign "wasi_snapshot_preview1" "fd_allocate" (fd: FileDescriptor, offset: Filesize, len: Filesize) -> Errno ---
-fd_close              :: proc #foreign "wasi_snapshot_preview1" "fd_close" (fd: FileDescriptor) -> Errno ---
-fd_datasync           :: proc #foreign "wasi_snapshot_preview1" "fd_datasync" (fd: FileDescriptor) -> Errno ---
-fd_fdstat_get         :: proc #foreign "wasi_snapshot_preview1" "fd_fdstat_get" (fd: FileDescriptor, stat: ^FDStat) -> Errno ---
-fd_fdstat_set_flags   :: proc #foreign "wasi_snapshot_preview1" "fd_fdstat_set_flags" (fd: FileDescriptor, flags: FDFlags) -> Errno ---
-fd_fdstat_set_rights  :: proc #foreign "wasi_snapshot_preview1" "fd_fdstat_set_rights" (fd: FileDescriptor, rights_base: Rights, rights_inheriting: Rights) -> Errno ---
-fd_filestat_get       :: proc #foreign "wasi_snapshot_preview1" "fd_filestat_get" (fd: FileDescriptor, buf: ^FileStat) -> Errno ---
-fd_filestat_set_size  :: proc #foreign "wasi_snapshot_preview1" "fd_filestat_set_size" (fd: FileDescriptor, size: Filesize) -> Errno ---
-fd_filestat_set_times :: proc #foreign "wasi_snapshot_preview1" "fd_filestat_set_times" (fd: FileDescriptor, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno ---
-fd_pread ::
-    proc #foreign "wasi_snapshot_preview1" "fd_pread"
-    (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nread: ^Size) -> Errno ---
-fd_prestat_get :: proc #foreign "wasi_snapshot_preview1" "fd_prestat_get" (fd: FileDescriptor, buf: ^PrestatTagged) -> Errno ---
-fd_prestat_dir_name :: proc #foreign "wasi_snapshot_preview1" "fd_prestat_dir_name" (fd: FileDescriptor, path: string) -> Errno ---
-fd_pwrite ::
-    proc #foreign "wasi_snapshot_preview1" "fd_pwrite"
-    (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nwritten: ^Size) -> Errno ---
-fd_read ::
-    proc #foreign "wasi_snapshot_preview1" "fd_read"
-    (fd: FileDescriptor, iovs: IOVecArray, nread: ^Size) -> Errno ---
-fd_readdir ::
-    proc #foreign "wasi_snapshot_preview1" "fd_readdir"
-    (fd: FileDescriptor, buf: ^u8, buf_len: Size, cookie: DirCookie, bufused: ^Size) -> Errno ---
-fd_renumber ::
-    proc #foreign "wasi_snapshot_preview1" "fd_renumber"
-    (fd: FileDescriptor, to: FileDescriptor) -> Errno ---
-fd_seek ::
-    proc #foreign "wasi_snapshot_preview1" "fd_seek"
-    (fd: FileDescriptor, offset: FileDelta, whence: Whence, newoffset: ^Filesize) -> Errno ---
-fd_sync :: proc #foreign "wasi_snapshot_preview1" "fd_sync" (fd: FileDescriptor) -> Errno ---
-fd_tell :: proc #foreign "wasi_snapshot_preview1" "fd_tell" (fd: FileDescriptor, offset: ^Filesize) -> Errno ---
-fd_write ::
-    proc #foreign "wasi_snapshot_preview1" "fd_write"
-    (fd: FileDescriptor, iovs: IOVecArray, nwritten: ^Size) -> Errno ---
-
-path_create_directory ::
-    proc #foreign "wasi_snapshot_preview1" "path_create_directory"
-    (fd: FileDescriptor, path: string) -> Errno ---
-path_filestat_get ::
-    proc #foreign "wasi_snapshot_preview1" "path_filestat_get"
-    (fd: FileDescriptor, flags: LookupFlags, path: string, buf: ^FileStat) -> Errno ---
-path_filestat_set_times ::
-    proc #foreign "wasi_snapshot_preview1" "path_filestat_set_times"
-    (fd: FileDescriptor, flags: LookupFlags, path: string, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno ---
-path_link ::
-    proc #foreign "wasi_snapshot_preview1" "path_link"
-    (fd: FileDescriptor, old_flags: LookupFlags, old_path: string, new_fd: FileDescriptor, new_path: string) -> Errno ---   
-path_open ::
-    proc #foreign "wasi_snapshot_preview1" "path_open"
+args_get       :: proc (argv: ^^u8, argv_buf: ^u8) -> Errno #foreign "wasi_snapshot_preview1" "args_get"---
+args_sizes_get :: proc (argc: ^Size, argv_buf_size: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "args_sizes_get" ---
+
+environ_get       :: proc (environ: ^^u8, environ_buf: ^u8) -> Errno #foreign "wasi_snapshot_preview1" "environ_get" ---
+environ_sizes_get :: proc (environc: ^Size, environ_buf_size: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "environ_sizes_get" ---
+
+clock_res_get  :: proc (id: ClockID, resolution: ^Timestamp) -> Errno #foreign "wasi_snapshot_preview1" "clock_res_get" ---
+clock_time_get :: proc (id: ClockID, precision: Timestamp, time: ^Timestamp) -> Errno #foreign "wasi_snapshot_preview1" "clock_time_get" ---
+
+fd_advise             :: proc (fd: FileDescriptor, offset: Filesize, len: Filesize, advice: Advice) -> Errno #foreign "wasi_snapshot_preview1" "fd_advise" ---
+fd_allocate           :: proc (fd: FileDescriptor, offset: Filesize, len: Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_allocate" ---
+fd_close              :: proc (fd: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_close" ---
+fd_datasync           :: proc (fd: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_datasync" ---
+fd_fdstat_get         :: proc (fd: FileDescriptor, stat: ^FDStat) -> Errno #foreign "wasi_snapshot_preview1" "fd_fdstat_get" ---
+fd_fdstat_set_flags   :: proc (fd: FileDescriptor, flags: FDFlags) -> Errno #foreign "wasi_snapshot_preview1" "fd_fdstat_set_flags" ---
+fd_fdstat_set_rights  :: proc (fd: FileDescriptor, rights_base: Rights, rights_inheriting: Rights) -> Errno #foreign "wasi_snapshot_preview1" "fd_fdstat_set_rights" ---
+fd_filestat_get       :: proc (fd: FileDescriptor, buf: ^FileStat) -> Errno #foreign "wasi_snapshot_preview1" "fd_filestat_get" ---
+fd_filestat_set_size  :: proc (fd: FileDescriptor, size: Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_filestat_set_size" ---
+fd_filestat_set_times :: proc (fd: FileDescriptor, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_snapshot_preview1" "fd_filestat_set_times" ---
+fd_pread              :: proc (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nread: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_pread" ---
+fd_prestat_get        :: proc (fd: FileDescriptor, buf: ^PrestatTagged) -> Errno #foreign "wasi_snapshot_preview1" "fd_prestat_get" ---
+fd_prestat_dir_name   :: proc (fd: FileDescriptor, path: string) -> Errno #foreign "wasi_snapshot_preview1" "fd_prestat_dir_name" ---
+fd_pwrite             :: proc (fd: FileDescriptor, iovs: IOVecArray, offset: Filesize, nwritten: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_pwrite" ---
+fd_read               :: proc (fd: FileDescriptor, iovs: IOVecArray, nread: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_read" ---
+fd_readdir            :: proc (fd: FileDescriptor, buf: ^u8, buf_len: Size, cookie: DirCookie, bufused: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_readdir" ---
+fd_renumber           :: proc (fd: FileDescriptor, to: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_renumber" ---
+fd_seek               :: proc (fd: FileDescriptor, offset: FileDelta, whence: Whence, newoffset: ^Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_seek" ---
+fd_sync               :: proc (fd: FileDescriptor) -> Errno #foreign "wasi_snapshot_preview1" "fd_sync" ---
+fd_tell               :: proc (fd: FileDescriptor, offset: ^Filesize) -> Errno #foreign "wasi_snapshot_preview1" "fd_tell" ---
+fd_write              :: proc (fd: FileDescriptor, iovs: IOVecArray, nwritten: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "fd_write" ---
+
+path_create_directory   :: proc (fd: FileDescriptor, path: string) -> Errno #foreign "wasi_snapshot_preview1" "path_create_directory" ---
+path_filestat_get       :: proc (fd: FileDescriptor, flags: LookupFlags, path: string, buf: ^FileStat) -> Errno #foreign "wasi_snapshot_preview1" "path_filestat_get" ---
+path_filestat_set_times :: proc (fd: FileDescriptor, flags: LookupFlags, path: string, atim: Timestamp, mtim: Timestamp, fst_flags: FSTFlags) -> Errno #foreign "wasi_snapshot_preview1" "path_filestat_set_times" ---
+
+path_link :: proc (fd: FileDescriptor, old_flags: LookupFlags, old_path: string, new_fd: FileDescriptor, new_path: string) -> Errno #foreign "wasi_snapshot_preview1" "path_link" ---
+path_open :: proc
     ( fd: FileDescriptor
     , dirflags: LookupFlags
     , path: string
@@ -423,43 +401,27 @@ path_open ::
     , fs_rights_inherting: Rights
     , fdflags: FDFlags
     , opened_fd: ^FileDescriptor
-    ) -> Errno ---
-path_readlink ::
-    proc #foreign "wasi_snapshot_preview1" "path_readlink"
-    (fd: FileDescriptor, path: string, buf: ^u8, buf_len: Size, bufused: ^Size) -> Errno ---
-path_remove_directory ::
-    proc #foreign "wasi_snapshot_preview1" "path_remove_directory"
-    (fd: FileDescriptor, path: string) -> Errno ---
-path_rename ::
-    proc #foreign "wasi_snapshot_preview1" "path_rename"
-    (fd: FileDescriptor, old_path: string, new_fd: FileDescriptor, new_path: string) -> Errno ---
-path_symlink ::
-    proc #foreign "wasi_snapshot_preview1" "path_symlink"
-    (old_path: ^u8, old_path_len: Size, fd: FileDescriptor, new_path: string) -> Errno ---
-path_unlink_file ::
-    proc #foreign "wasi_snapshot_preview1" "path_unlink_file"
-    (fd: FileDescriptor, path: string) -> Errno ---
-
-poll_oneoff ::
-    proc #foreign "wasi_snapshot_preview1" "poll_oneoff"
-    (in: ^Subscription, out: ^Event, nsubscriptions: Size, nevents: ^Size) -> Errno ---
-
-proc_exit  :: proc #foreign "wasi_snapshot_preview1" "proc_exit" (rval: ExitCode) ---
-proc_raise :: proc #foreign "wasi_snapshot_preview1" "proc_raise" (sig: Signal) -> Errno ---
-
-sched_yield :: proc #foreign "wasi_snapshot_preview1" "sched_yield" -> Errno ---
-
-random_get :: proc #foreign "wasi_snapshot_preview1" "random_get" (buf: ^u8, buf_len: Size) -> Errno ---
-
-sock_recv ::
-    proc #foreign "wasi_snapshot_preview1" "sock_recv"
-    (fd: FileDescriptor, ri_data: IOVecArray, ri_flags: RIFlags, ro_datalen: ^Size, ro_flags: ^ROFlags) -> Errno ---
-sock_send ::
-    proc #foreign "wasi_snapshot_preview1" "sock_send"
-    (fd: FileDescriptor, si_data: IOVecArray, si_flags: SIFlags, so_datalen: ^Size) -> Errno ---
-sock_shutdown ::
-    proc #foreign "wasi_snapshot_preview1" "sock_shutdown"
-    (fd: FileDescriptor, how: SDFlags) -> Errno ---
+    ) -> Errno
+     #foreign "wasi_snapshot_preview1" "path_open" ---
+
+path_readlink :: proc (fd: FileDescriptor, path: string, buf: ^u8, buf_len: Size, bufused: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "path_readlink" ---
+path_remove_directory :: proc (fd: FileDescriptor, path: string) -> Errno #foreign "wasi_snapshot_preview1" "path_remove_directory" ---
+path_rename  :: proc (fd: FileDescriptor, old_path: string, new_fd: FileDescriptor, new_path: string) -> Errno #foreign "wasi_snapshot_preview1" "path_rename" ---
+path_symlink :: proc (old_path: ^u8, old_path_len: Size, fd: FileDescriptor, new_path: string) -> Errno #foreign "wasi_snapshot_preview1" "path_symlink" ---
+path_unlink_file :: proc (fd: FileDescriptor, path: string) -> Errno #foreign "wasi_snapshot_preview1" "path_unlink_file" ---
+
+poll_oneoff :: proc (in: ^Subscription, out: ^Event, nsubscriptions: Size, nevents: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "poll_oneoff" ---
+
+proc_exit  :: proc (rval: ExitCode) #foreign "wasi_snapshot_preview1" "proc_exit" ---
+proc_raise :: proc (sig: Signal) -> Errno #foreign "wasi_snapshot_preview1" "proc_raise" ---
+
+sched_yield :: proc -> Errno #foreign "wasi_snapshot_preview1" "proc_raise" ---
+
+random_get :: proc (buf: ^u8, buf_len: Size) -> Errno #foreign "wasi_snapshot_preview1" "random_get" ---
+
+sock_recv     :: proc (fd: FileDescriptor, ri_data: IOVecArray, ri_flags: RIFlags, ro_datalen: ^Size, ro_flags: ^ROFlags) -> Errno #foreign "wasi_snapshot_preview1" "sock_recv" ---
+sock_send     :: proc (fd: FileDescriptor, si_data: IOVecArray, si_flags: SIFlags, so_datalen: ^Size) -> Errno #foreign "wasi_snapshot_preview1" "sock_send" ---
+sock_shutdown :: proc (fd: FileDescriptor, how: SDFlags) -> Errno #foreign "wasi_snapshot_preview1" "sock_shutdown" ---
 
 
 
index 37d7b785b214c4c99aa0b98e7ada6819d1f969c8..c37366d9031dc71ab4671b758c772312b86d4c9c 100644 (file)
@@ -1503,7 +1503,8 @@ char* bh_bprintf(char const *fmt, ...) {
 
 char* bh_bprintf_va(char const *fmt, va_list va) {
     static char buffer[4096];
-    bh_snprintf_va(buffer, sizeof(buffer), fmt, va);
+    isize len = bh_snprintf_va(buffer, sizeof(buffer), fmt, va);
+    buffer[len - 1] = 0;
     return buffer;
 }
 
diff --git a/onyx b/onyx
index 41dca3893c87640dac97b09c424a0e52c35fc807..cb650b751f9c3ab7f7d30e46c6a875aa517d1d70 100755 (executable)
Binary files a/onyx and b/onyx differ
index 0e430e355a6a1757db32e54a639e46ce932dc026..0a6cbb7768437e3c7e710990887b284ae803c37c 100644 (file)
@@ -43,7 +43,7 @@ print_arr :: proc (arr: $T) {
     print("\n");
 }
 
-print_vec :: proc #add_overload print (v: Vec3) {
+print_vec :: proc (v: Vec3) #add_overload print {
     print("Vec3(");
     print(v.x);
     print(", ");
index 1c49144865b0622514b0683322138b4f4e40812d..de3e90fc893c9680089a09ffa71b977be57e19f3 100644 (file)
@@ -214,8 +214,21 @@ no_match:
         continue;
     }
 
-    onyx_report_error(call->token->pos, "unable to match overloaded function");
+    char* arg_str = bh_alloc(global_scratch_allocator, 1024);
 
+    AstArgument* arg = call->arguments;
+    while (arg != NULL) {
+        strncat(arg_str, type_get_name(arg->type), 1023);
+
+        if (arg->next != NULL)
+            strncat(arg_str, ", ", 1023);
+
+        arg = (AstArgument *) arg->next;
+    }
+
+    onyx_report_error(call->token->pos, "unable to match overloaded function with provided argument types: (%s)", arg_str);
+
+    bh_free(global_scratch_allocator, arg_str);
     return NULL;
 }
 
index 738c9064bdb54f52f9b9bb8e95cccec0d5d730e9..b025fd9525a54ebc6533635572fd1694bcc7c0d0 100644 (file)
@@ -1432,7 +1432,7 @@ static b32 parse_possible_directive(OnyxParser* parser, const char* dir) {
     return match;
 }
 
-// 'proc' <directive>* <func_params> ('->' <type>)? <block>
+// 'proc' <func_params> ('->' <type>)? <directive>* <block>
 static AstFunction* parse_function_definition(OnyxParser* parser) {
     AstFunction* func_def = make_node(AstFunction, Ast_Kind_Function);
     func_def->token = expect_token(parser, Token_Type_Keyword_Proc);
@@ -1443,6 +1443,16 @@ static AstFunction* parse_function_definition(OnyxParser* parser) {
     bh_arr(AstPolyParam) polymorphic_vars = NULL;
     bh_arr_new(global_heap_allocator, polymorphic_vars, 4);
 
+    parse_function_params(parser, func_def, &polymorphic_vars);
+
+    AstType* return_type = (AstType *) &basic_type_void;
+    if (parser->curr->type == Token_Type_Right_Arrow) {
+        expect_token(parser, Token_Type_Right_Arrow);
+
+        return_type = parse_type(parser, NULL);
+    }
+    func_def->return_type = return_type;
+
     while (parser->curr->type == '#') {
         if (parse_possible_directive(parser, "overloaded")) {
             AstOverloadedFunction* ofunc = make_node(AstOverloadedFunction, Ast_Kind_Overloaded_Function);
@@ -1469,6 +1479,8 @@ static AstFunction* parse_function_definition(OnyxParser* parser) {
         if (parse_possible_directive(parser, "add_overload")) {
             if (func_def->overloaded_function != NULL) {
                 onyx_report_error(parser->curr->pos, "cannot have multiple #add_overload directives on a single procedure.");
+                expect_token(parser, Token_Type_Symbol);
+                
             } else {
                 AstNode* sym_node = make_node(AstNode, Ast_Kind_Symbol);
                 sym_node->token = expect_token(parser, Token_Type_Symbol);
@@ -1517,16 +1529,6 @@ static AstFunction* parse_function_definition(OnyxParser* parser) {
         }
     }
 
-    parse_function_params(parser, func_def, &polymorphic_vars);
-
-    AstType* return_type = (AstType *) &basic_type_void;
-    if (parser->curr->type == Token_Type_Right_Arrow) {
-        expect_token(parser, Token_Type_Right_Arrow);
-
-        return_type = parse_type(parser, NULL);
-    }
-    func_def->return_type = return_type;
-
     func_def->body = parse_block(parser);
 
     if (bh_arr_length(polymorphic_vars) > 0) {