#!/bin/sh
+print_check() {
+ if [ ! -z "$TERM " ]; then
+ printf "%-$((($(tput cols) - 8)))s" "⏲ Checking $1.onyx" ;
+ else
+ printf "%s ... " "⏲ Checking $1.onyx" ;
+ fi
+}
+
+
failed=0
for test_file in $(find tests/ -name '*.onyx'); do
filename=$(basename -- "$test_file")
dirname="$(dirname -- "$test_file")"
name="${filename%.*}"
- printf "%-$((($(tput cols) - 8)))s" "⏲ Checking $name.onyx"
+ print_check "$name"
if ! ./bin/onyx "$test_file" -o "./tests/$name.wasm" >/dev/null; then
print "\n❌ Failed to compile $name.onyx.\n"
bh_arr_each(AstPolySolution, sln, sd->known_polyvars) {
AstPolySolution new_sln;
+ new_sln.kind = sln->kind;
new_sln.poly_sym = (AstNode *) ast_clone(a, (AstNode *) sln->poly_sym);
new_sln.ast_type = (AstType *) ast_clone(a, (AstNode *) sln->ast_type);
bh_arr_push(dd->known_polyvars, new_sln);
break;
}
+ if (elem.kind != PSK_Type) continue;
+
switch (elem.type_expr->kind) {
case Ast_Kind_Pointer_Type: {
if (elem.actual->kind != Type_Kind_Pointer) break;
new_pp->flags = pp->flags;
new_pp->poly_params = pp->poly_params;
+ // POTENTIAL BUG: Copying this doesn't feel right...
+ if (pp->concrete_funcs == NULL) {
+ bh_table_init(global_heap_allocator, pp->concrete_funcs, 8);
+ }
+ new_pp->concrete_funcs = pp->concrete_funcs;
+
new_pp->known_slns = NULL;
bh_arr_new(global_heap_allocator, new_pp->known_slns, bh_arr_length(pp->known_slns) + bh_arr_length(slns));
--- /dev/null
+1 2 3 4 5 0.0
+1.0
+1.4142
+1.7320
+2.0
+2.2360
+2.4494
+2.6457
+2.8284
+3.0
+3.1622
+3.3166
+3.4641
+3.6055
+3.7416
+3.8729
+4.0
+4.1231
+4.2426
+4.3588
--- /dev/null
+#load "core/std/js"
+
+use package core
+
+main :: proc (args: [] cstr) {
+ arr := u32.[ 1, 2, 3, 4, 5 ];
+ for elem: array_to_slice(arr) do printf("%i ", elem);
+
+ roots : [20] f32;
+ compute_roots(roots);
+
+ for root: roots do println(root);
+
+ array_to_slice :: proc (arr: [$N] $T) -> [] T {
+ return (#type [] T).{ ~~arr, N };
+ }
+
+ compute_roots :: proc (arr: [$N] f32) {
+ for i: 0 .. N {
+ arr[i] = math.sqrt(cast(f32) i);
+ }
+ }
+}
\ No newline at end of file