aboutsummaryrefslogtreecommitdiff
path: root/src/tilde_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-07-19 20:44:37 +0100
committergingerBill <bill@gingerbill.org>2023-07-19 20:44:37 +0100
commitf32d71eca05983520fb5e39cd9c7802200353adb (patch)
tree2e1f43b3ead3e0c5c04a38bae3ade64a38abe86c /src/tilde_stmt.cpp
parent5fb98609cd9d5d7efea6d54a722181ff46413333 (diff)
Mock out `any` type `switch` statement
Diffstat (limited to 'src/tilde_stmt.cpp')
-rw-r--r--src/tilde_stmt.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/tilde_stmt.cpp b/src/tilde_stmt.cpp
index a2dfa0257..c5aaa9161 100644
--- a/src/tilde_stmt.cpp
+++ b/src/tilde_stmt.cpp
@@ -1323,7 +1323,6 @@ gb_internal void cg_build_type_switch_stmt(cgProcedure *p, Ast *node) {
tag = cg_emit_load(p, tag_ptr);
}
} else if (switch_kind == TypeSwitch_Any) {
- GB_PANIC("TODO(bill): type switch any");
tag = cg_emit_load(p, cg_emit_struct_ep(p, parent_ptr, 1));
} else {
GB_PANIC("Unknown switch kind");
@@ -1406,13 +1405,11 @@ gb_internal void cg_build_type_switch_stmt(cgProcedure *p, Ast *node) {
key = union_variant_index(ut, case_type);
}
} else if (switch_kind == TypeSwitch_Any) {
- GB_PANIC("TODO(bill): any");
- // if (is_type_untyped_nil(case_type)) {
- // saw_nil = true;
- // on_val = lb_const_nil(m, t_typeid);
- // } else {
- // on_val = lb_typeid(m, case_type);
- // }
+ if (is_type_untyped_nil(case_type)) {
+ key = 0;
+ } else {
+ key = cast(i64)cg_typeid_as_u64(p->module, case_type);
+ }
}
GB_ASSERT(key >= 0);