fixed: miscellaneous things
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 18 Aug 2023 17:21:00 +0000 (12:21 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 18 Aug 2023 17:21:00 +0000 (12:21 -0500)
compiler/src/polymorph.h
core/onyx/cbindgen.onyx
interpreter/src/debug/debug_runtime_values.c
scripts/onyx-pkg.onyx

index 0cc0d5a08ba756666770b052973e5022e528feb3..bd97a95d3e296532e5da7d6a81c506f27643bf16 100644 (file)
@@ -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.
index 0e7dc1181accbf33a95e6d0202391d8273bd521c..b2678a88d8dd804c3d3d92abc63685af1cb5e2bb 100644 (file)
@@ -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);
         }
index e0106195d4e3df931bacaa32024721361124bf97..88f05765cfc25c023a7444fbfda231bcd89a7a8d 100644 (file)
@@ -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);
index c88003acad4e3ee31cca236eb6d26ccb54bef317..1fd21907bc1600c95cda080343b4d3024b3f2ad6 100644 (file)
@@ -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);
     }