bugfixes and added aprintf
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 4 Apr 2022 15:29:31 +0000 (10:29 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 4 Apr 2022 15:29:31 +0000 (10:29 -0500)
core/container/array.onyx
core/stdio.onyx
misc/onyx.sublime-syntax
src/wasm_type_table.h
tests/struct_use_pointer_member

index dfaac276493bfabf50bfd574717082a62dd2dab7..3fca8aaadab7e6c7a1296d1aa6ec34d42686ff45 100644 (file)
@@ -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;
 }
 
index e7af56a7f4cfd415c1496af8c15455ac2b18cd6b..f29c23fe7f4e00e2c34d68b39b4103b3d68840c0 100644 (file)
@@ -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 := " ") {
index 735c96e17effca62080526c486c2390d9494702b..54a08a3e46ff2c6ddfdab3cf0ff78604e879d66e 100644 (file)
@@ -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:
index 9fc5aa036805a78380f17a3f32853ea7b69bac0e..2751428409bc118484ff84235deadfc71ef690cd 100644 (file)
@@ -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);
index 2960ea4fff31e49111bbcea289a66bd4c681c9c4..e8005b2ec5fd331cc4e3242f2317386664f13aaf 100644 (file)
@@ -1,2 +1,2 @@
 Hello, I am Billy!
-Go away!! func[16]
+Go away!! func[51]