mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fix boolean casting
This commit is contained in:
+2
-9
@@ -3053,10 +3053,8 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
|
|||||||
return ir_emit(proc, ir_instr_conv(proc, kind, value, src_type, t));
|
return ir_emit(proc, ir_instr_conv(proc, kind, value, src_type, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// boolean -> boolean
|
// boolean -> boolean/integer
|
||||||
if (is_type_boolean(src) && is_type_boolean(dst)) {
|
if (is_type_boolean(src) && (is_type_boolean(dst) || is_type_integer(dst))) {
|
||||||
GB_ASSERT(src->kind == Type_Basic &&
|
|
||||||
dst->kind == Type_Basic);
|
|
||||||
GB_ASSERT(src != t_llvm_bool);
|
GB_ASSERT(src != t_llvm_bool);
|
||||||
|
|
||||||
irValue *b = ir_emit(proc, ir_instr_binary_op(proc, Token_NotEq, value, v_zero, t_llvm_bool));
|
irValue *b = ir_emit(proc, ir_instr_binary_op(proc, Token_NotEq, value, v_zero, t_llvm_bool));
|
||||||
@@ -3064,11 +3062,6 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// boolean -> integer
|
|
||||||
if (is_type_boolean(src) && is_type_integer(dst)) {
|
|
||||||
return ir_emit(proc, ir_instr_conv(proc, irConv_zext, value, src_type, t));
|
|
||||||
}
|
|
||||||
|
|
||||||
// integer -> boolean
|
// integer -> boolean
|
||||||
if (is_type_integer(src) && is_type_boolean(dst)) {
|
if (is_type_integer(src) && is_type_boolean(dst)) {
|
||||||
return ir_emit_comp(proc, Token_NotEq, value, v_zero);
|
return ir_emit_comp(proc, Token_NotEq, value, v_zero);
|
||||||
|
|||||||
Reference in New Issue
Block a user