From: Brendan Hansen Date: Mon, 28 Sep 2020 13:08:14 +0000 (-0500) Subject: updated CHANGELOG and call site bugfix X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=5edd490043512bd270bc3ab1a6be5e1207e4ead0;p=onyx.git updated CHANGELOG and call site bugfix --- diff --git a/CHANGELOG b/CHANGELOG index c7130299..7becc5f1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,14 +5,28 @@ Additions: * bitwise not operator, ~ * auto cast operator, ~~. In many circumstances, will automatically determine what to cast to. - Will also report errors in the cast is not possible. +* Arbitrarily typed varargs. They behave similar to C-style varargs. +* vararg_get builtin procedure to retrieve a value from a ... vararg. +* #private_file directive for placing a symbol at file scope. +* a basic implentation of printf in the standard library. +* use statements at the function level. Removals: Changes: * Procedure definitions now require parentheses, even if there are no arguments. This was done to allow for `proc { foo, bar }` to be the overload syntax. +* array_map takes an arbitrary parameter of polymorphic type to make up for the fact that + anonymous procs do not have closure. New type signature is: + array_map :: proc (arr: ^[..] $T, data: $R, f: proc (T, R) -> T) +* better syntax highlighting for VIM. Bug fixes: +* many bugs related to var args and procedure calls in general. +* polymorphic structs caused segmentation fault when trying to produce an error message. +* polymorhpic structs caused scope to change when using a struct literal of a polymoprhic type. +* #char "\"" did not work. +* nested function calls returning non-basic types would simply be wrong. diff --git a/onyx b/onyx index 7d901db8..d1898c4e 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 3d055bc6..23ff7745 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -1326,6 +1326,7 @@ EMIT_FUNC(call, AstCall* call) { u32 vararg_count = 0; u32 vararg_offset = -1; + u64 stack_top_store_local;; bh_arr_each(AstArgument *, parg, call->arg_arr) { AstArgument* arg = *parg; @@ -1341,8 +1342,26 @@ EMIT_FUNC(call, AstCall* call) { if (place_on_stack && !arg_is_struct) WID(WI_GLOBAL_GET, stack_top_idx); + if (stack_grow_amm != 0) { + stack_top_store_local = local_raw_allocate(mod->local_alloc, WASM_TYPE_INT32); + WID(WI_GLOBAL_GET, stack_top_idx); + WIL(WI_LOCAL_SET, stack_top_store_local); + + WID(WI_GLOBAL_GET, stack_top_idx); + WID(WI_I32_CONST, stack_grow_amm); + WI(WI_I32_ADD); + WID(WI_GLOBAL_SET, stack_top_idx); + } + emit_expression(mod, &code, arg->value); + if (stack_grow_amm != 0) { + WIL(WI_LOCAL_GET, stack_top_store_local); + WID(WI_GLOBAL_SET, stack_top_idx); + + local_raw_free(mod->local_alloc, WASM_TYPE_INT32); + } + if (place_on_stack) { if (arg_is_struct) WID(WI_GLOBAL_GET, stack_top_idx); emit_store_instruction(mod, &code, arg->value->type, stack_grow_amm); diff --git a/tests/i32map.onyx b/tests/i32map.onyx index a6f3e6f1..da65ae3e 100644 --- a/tests/i32map.onyx +++ b/tests/i32map.onyx @@ -17,8 +17,7 @@ main :: proc (args: [] cstring) { println(i32map_has(^imap, 50)); println(i32map_has(^imap, 51)); - print(i32map_get(^imap, 50, "")); - println(i32map_get(^imap, 1234, "")); + printf("%s%s\n", i32map_get(^imap, 50, ""), i32map_get(^imap, 1234, "")); i32map_delete(^imap, 50); println(i32map_has(^imap, 50));