From: Brendan Hansen Date: Thu, 14 Jan 2021 18:41:52 +0000 (-0600) Subject: added pool allocator to core library X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=508f42e524449c9fabe65d05702d70bcdf011424;p=onyx.git added pool allocator to core library --- diff --git a/bin/onyx b/bin/onyx index 4ceb4990..6bc20b20 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/core/alloc.onyx b/core/alloc.onyx index 792e497c..9950f9a4 100644 --- a/core/alloc.onyx +++ b/core/alloc.onyx @@ -4,6 +4,7 @@ package core.alloc #load "core/alloc/fixed" #load "core/alloc/heap" #load "core/alloc/ring" +#load "core/alloc/pool" TEMPORARY_ALLOCATOR_SIZE :: 1 << 12; // 4Kb diff --git a/core/stdio.onyx b/core/stdio.onyx index c3e67fda..c0a235e7 100644 --- a/core/stdio.onyx +++ b/core/stdio.onyx @@ -40,13 +40,24 @@ printf :: proc (format: str, va: ...) { } // This works on both slices and arrays -print_array :: proc (arr: $T, sep := " ") { - for i: 0 .. arr.count { - print(arr.data[i]); - if i != arr.count - 1 do print(sep); - } +print_array :: proc { + proc (arr: [$N] $T, sep := " ") { + for i: 0 .. N { + print(arr[i]); + if i != N - 1 do print(sep); + } - print("\n"); + print("\n"); + }, + + proc (arr: $T, sep := " ") { + for i: 0 .. arr.count { + print(arr.data[i]); + if i != arr.count - 1 do print(sep); + } + + print("\n"); + } } print_stream_flush :: proc () { diff --git a/onyx.exe b/onyx.exe index b8a51481..b54fafb6 100644 Binary files a/onyx.exe and b/onyx.exe differ diff --git a/src/onyxutils.c b/src/onyxutils.c index cfdd13e5..0fd12a08 100644 --- a/src/onyxutils.c +++ b/src/onyxutils.c @@ -395,7 +395,7 @@ static bh_arr(AstPolySolution) find_polymorphic_slns(AstPolyProc* pp, PolyProcLo else if (pp_lookup == PPLM_By_Function_Type) { Type* ft = (Type*) actual; if (param->idx >= ft->Function.param_count) { - if (err_msg) *err_msg = "Incompatible polymorphic argument to function paramter."; + if (err_msg) *err_msg = "Incompatible polymorphic argument to function parameter."; goto sln_not_found; }