From 0024e596094d029ea4143147bc93a47b73b61fa1 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 4 Apr 2022 10:29:31 -0500 Subject: [PATCH] bugfixes and added aprintf --- core/container/array.onyx | 2 +- core/stdio.onyx | 6 ++++++ misc/onyx.sublime-syntax | 2 +- src/wasm_type_table.h | 2 +- tests/struct_use_pointer_member | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/container/array.onyx b/core/container/array.onyx index dfaac276..3fca8aaa 100644 --- a/core/container/array.onyx +++ b/core/container/array.onyx @@ -31,7 +31,7 @@ free :: (arr: ^[..] $T) { arr.count = 0; arr.capacity = 0; - raw_free(arr.allocator, arr.data); + if arr.data != null do raw_free(arr.allocator, arr.data); arr.data = null; } diff --git a/core/stdio.onyx b/core/stdio.onyx index e7af56a7..f29c23fe 100644 --- a/core/stdio.onyx +++ b/core/stdio.onyx @@ -34,6 +34,12 @@ printf :: (format: str, va: ..any) { print(conv.str_format_va(buffer, format, va)); } +aprintf :: (format: str, va: ..any) -> str { + buffer: [8196] u8; + out := conv.str_format_va(buffer, format, va); + return string.alloc_copy(out); +} + // This works on both slices and arrays print_array :: #match { (arr: [$N] $T, sep := " ") { diff --git a/misc/onyx.sublime-syntax b/misc/onyx.sublime-syntax index 735c96e1..54a08a3e 100644 --- a/misc/onyx.sublime-syntax +++ b/misc/onyx.sublime-syntax @@ -85,7 +85,7 @@ contexts: - match: '([a-zA-Z_][a-zA-Z0-9_\.]+)\s*\(' captures: - 1: meta.function-call.onyx + 1: variable.function.onyx # - match: '([a-zA-Z_][a-zA-Z0-9_]*)(,\s*([a-zA-Z_][a-zA-Z0-9_]*))*\s*:' # captures: diff --git a/src/wasm_type_table.h b/src/wasm_type_table.h index 9fc5aa03..27514284 100644 --- a/src/wasm_type_table.h +++ b/src/wasm_type_table.h @@ -384,7 +384,7 @@ u64 build_type_table(OnyxWasmModule* module) { if (struct_scope == NULL) goto no_methods; fori (i, 0, shlen(struct_scope->symbols)) { - AstFunction* node = (AstFunction *) struct_scope->symbols[i].value; + AstFunction* node = (AstFunction *) strip_aliases(struct_scope->symbols[i].value); if (node->kind != Ast_Kind_Function) continue; assert(node->entity); assert(node->entity->function == node); diff --git a/tests/struct_use_pointer_member b/tests/struct_use_pointer_member index 2960ea4f..e8005b2e 100644 --- a/tests/struct_use_pointer_member +++ b/tests/struct_use_pointer_member @@ -1,2 +1,2 @@ Hello, I am Billy! -Go away!! func[16] +Go away!! func[51] -- 2.25.1