From: Brendan Hansen Date: Fri, 18 Aug 2023 17:21:00 +0000 (-0500) Subject: fixed: miscellaneous things X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=cfa8c44f081fb9b5f31344d043cf094f7850c5dd;p=onyx.git fixed: miscellaneous things --- diff --git a/compiler/src/polymorph.h b/compiler/src/polymorph.h index 0cc0d5a0..bd97a95d 100644 --- a/compiler/src/polymorph.h +++ b/compiler/src/polymorph.h @@ -587,7 +587,7 @@ static void solve_for_polymorphic_param_type(PolySolveResult* resolved, AstFunct PolySolveResult res = solve_poly_type(param->poly_sym, param->type_expr, actual_type); // If we are trying to match against an "address of" node that was - // placed because of a method call, there's a small change that the + // placed because of a method call, there's a small chance that the // address of is unnecessary and can be removed. This happens in // unify_node_and_type, but because that relies on knowning the type, // it cannot happen until after polymorphic arguments are determined. diff --git a/core/onyx/cbindgen.onyx b/core/onyx/cbindgen.onyx index 0e7dc118..b2678a88 100644 --- a/core/onyx/cbindgen.onyx +++ b/core/onyx/cbindgen.onyx @@ -56,6 +56,9 @@ use simd {*} } +customize :: struct { + symbol_name: str; +} Cast_Mapping :: struct { type: type_expr; @@ -212,7 +215,10 @@ compile_c_file :: ( io.write(writer, type_encoding(method_info.return_type)); io.write(writer, ")) {\n"); - method_name := ff.name; + method_name := slice.find_opt(ff.tags, [it](it.type == customize)) + ->transform(x => misc.any_as(x, customize).symbol_name) + ?? ff.name; + if name_map != null_proc { method_name = name_map(method_name); } diff --git a/interpreter/src/debug/debug_runtime_values.c b/interpreter/src/debug/debug_runtime_values.c index e0106195..88f05765 100644 --- a/interpreter/src/debug/debug_runtime_values.c +++ b/interpreter/src/debug/debug_runtime_values.c @@ -184,11 +184,11 @@ static void append_value_from_memory_with_type(debug_runtime_value_builder_t *bu case debug_type_kind_union: { u32 variant = *(u32 *) base; - if (variant == 0) { + if (variant >= type->onion.variant_count) { WRITE("unknown_variant"); } else { - debug_type_union_variant_t *uv = &type->onion.variants[variant - 1]; + debug_type_union_variant_t *uv = &type->onion.variants[variant]; WRITE_FORMAT("%s(", uv->name); append_value_from_memory_with_type(builder, bh_pointer_add(base, type->onion.tag_size), uv->type); diff --git a/scripts/onyx-pkg.onyx b/scripts/onyx-pkg.onyx index c88003ac..1fd21907 100644 --- a/scripts/onyx-pkg.onyx +++ b/scripts/onyx-pkg.onyx @@ -770,7 +770,7 @@ run_command_and_forward_output :: (cmd: str) => { run_proc := os.process_spawn(prog, args); r := io.reader_make(&run_proc); - while !(r->empty()) { + while !r->empty() { line := r->read_line(consume_newline=true); print(line); }