diff options
Diffstat (limited to 'src/tilde_proc.cpp')
| -rw-r--r-- | src/tilde_proc.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/tilde_proc.cpp b/src/tilde_proc.cpp index a9a69e415..7fc2dbdfe 100644 --- a/src/tilde_proc.cpp +++ b/src/tilde_proc.cpp @@ -305,13 +305,12 @@ gb_internal void cg_procedure_begin(cgProcedure *p) { param_ptr_to_use = dummy_param; param_debug_type = tb_debug_create_ptr(p->module->mod, param_debug_type); } - tb_node_append_attrib( + tb_function_attrib_variable( + p->func, param_ptr_to_use, - tb_function_attrib_variable( - p->func, - name.len, cast(char const *)name.text, - param_debug_type - ) + nullptr, // parent + name.len, cast(char const *)name.text, + param_debug_type ); } cgAddr addr = cg_addr(local); @@ -1097,8 +1096,25 @@ gb_internal cgProcedure *cg_equal_proc_for_type(cgModule *m, Type *type) { cg_emit_if(p, tag_eq, switch_region, false_region); size_t entry_count = type->Union.variants.count; + if (type->Union.kind != UnionType_no_nil) { + entry_count += 1; + } + + size_t entry_index = 0; + TB_SwitchEntry *keys = gb_alloc_array(temporary_allocator(), TB_SwitchEntry, entry_count); - for (size_t i = 0; i < entry_count; i++) { + if (type->Union.kind != UnionType_no_nil) { + TB_Node *region = cg_control_region(p, "bcase"); + keys[entry_index].key = 0; + keys[entry_index].value = region; + entry_index += 1; + + tb_inst_set_control(p->func, region); + cgValue ok = cg_const_bool(p, t_bool, true); + cg_build_return_stmt_internal_single(p, ok); + } + + for (size_t i = entry_index; i < entry_count; i++) { TB_Node *region = cg_control_region(p, "bcase"); Type *variant = type->Union.variants[i]; keys[i].key = union_variant_index(type, variant); |