mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Fix case: in type switch issue
This commit is contained in:
@@ -1110,7 +1110,7 @@ gb_internal lbValue lb_emit_load(lbProcedure *p, lbValue value) {
|
|||||||
return lb_addr_load(p, addr);
|
return lb_addr_load(p, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
GB_ASSERT(is_type_pointer(value.type));
|
GB_ASSERT_MSG(is_type_pointer(value.type), "%s", type_to_string(value.type));
|
||||||
Type *t = type_deref(value.type);
|
Type *t = type_deref(value.type);
|
||||||
LLVMValueRef v = LLVMBuildLoad2(p->builder, lb_type(p->module, t), value.value, "");
|
LLVMValueRef v = LLVMBuildLoad2(p->builder, lb_type(p->module, t), value.value, "");
|
||||||
|
|
||||||
|
|||||||
@@ -1736,10 +1736,17 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss
|
|||||||
|
|
||||||
for (Ast *clause : body->stmts) {
|
for (Ast *clause : body->stmts) {
|
||||||
ast_node(cc, CaseClause, clause);
|
ast_node(cc, CaseClause, clause);
|
||||||
|
|
||||||
|
Entity *case_entity = implicit_entity_of_node(clause);
|
||||||
lb_open_scope(p, cc->scope);
|
lb_open_scope(p, cc->scope);
|
||||||
|
|
||||||
if (cc->list.count == 0) {
|
if (cc->list.count == 0) {
|
||||||
lb_start_block(p, default_block);
|
lb_start_block(p, default_block);
|
||||||
|
if (case_entity->flags & EntityFlag_Value) {
|
||||||
lb_store_type_case_implicit(p, clause, parent_value, true);
|
lb_store_type_case_implicit(p, clause, parent_value, true);
|
||||||
|
} else {
|
||||||
|
lb_store_type_case_implicit(p, clause, parent_ptr, true);
|
||||||
|
}
|
||||||
lb_type_case_body(p, ss->label, clause, p->curr_block, done);
|
lb_type_case_body(p, ss->label, clause, p->curr_block, done);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1769,7 +1776,6 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss
|
|||||||
LLVMAddCase(switch_instr, on_val.value, body->block);
|
LLVMAddCase(switch_instr, on_val.value, body->block);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *case_entity = implicit_entity_of_node(clause);
|
|
||||||
|
|
||||||
lb_start_block(p, body);
|
lb_start_block(p, body);
|
||||||
|
|
||||||
@@ -1782,6 +1788,7 @@ gb_internal void lb_build_type_switch_stmt(lbProcedure *p, AstTypeSwitchStmt *ss
|
|||||||
} else if (switch_kind == TypeSwitch_Any) {
|
} else if (switch_kind == TypeSwitch_Any) {
|
||||||
data = lb_emit_load(p, lb_emit_struct_ep(p, parent_ptr, 0));
|
data = lb_emit_load(p, lb_emit_struct_ep(p, parent_ptr, 0));
|
||||||
}
|
}
|
||||||
|
GB_ASSERT(is_type_pointer(data.type));
|
||||||
|
|
||||||
Type *ct = case_entity->type;
|
Type *ct = case_entity->type;
|
||||||
Type *ct_ptr = alloc_type_pointer(ct);
|
Type *ct_ptr = alloc_type_pointer(ct);
|
||||||
|
|||||||
Reference in New Issue
Block a user