diff options
| author | gingerBill <bill@gingerbill.org> | 2018-10-13 11:07:56 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-10-13 11:07:56 +0100 |
| commit | 73e9dbbf8c4a68dc6c512eb2de568d59df046494 (patch) | |
| tree | bb2806ad8b6b078ff3b901cd2e5dba857dc23f32 /src/ir.cpp | |
| parent | 0971a59493d601458ccb386a3752a75f6d880b8f (diff) | |
switch on typeid with type cases
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index ffd9f4f67..b51b9c184 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7145,7 +7145,14 @@ void ir_build_stmt_internal(irProcedure *proc, Ast *node) { irValue *cond_rhs = ir_emit_comp(proc, op, tag, rhs); cond = ir_emit_arith(proc, Token_And, cond_lhs, cond_rhs, t_bool); } else { - cond = ir_emit_comp(proc, Token_CmpEq, tag, ir_build_expr(proc, expr)); + if (expr->tav.mode == Addressing_Type) { + GB_ASSERT(is_type_typeid(ir_type(tag))); + irValue *e = ir_typeid(proc->module, expr->tav.type); + e = ir_emit_conv(proc, e, ir_type(tag)); + cond = ir_emit_comp(proc, Token_CmpEq, tag, e); + } else { + cond = ir_emit_comp(proc, Token_CmpEq, tag, ir_build_expr(proc, expr)); + } } ir_emit_if(proc, cond, body, next_cond); ir_start_block(proc, next_cond); |