diff options
| author | gingerBill <bill@gingerbill.org> | 2018-11-22 20:59:24 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-11-22 20:59:24 +0000 |
| commit | 52dcaeb1e975a020cf38451d8a20b5fb75a4aa85 (patch) | |
| tree | 9f632857c4baa4a77c0f6eea37b6fd328218cce1 | |
| parent | f96fbc94c85ab5195fb6bc008f18336ea9a9b13e (diff) | |
Fix transmute with `cstring` and `integers`
| -rw-r--r-- | src/ir.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 613083a29..7ee3c9600 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4684,6 +4684,14 @@ irValue *ir_emit_transmute(irProcedure *proc, irValue *value, Type *t) { return ir_emit_ptr_to_uintptr(proc, value, t); } + if (is_type_integer(src) && (is_type_pointer(dst) || is_type_cstring(dst))) { + Type *vt = core_type(ir_type(value)); + return ir_emit(proc, ir_instr_conv(proc, irConv_inttoptr, value, vt, t)); + }else if ((is_type_pointer(src) || is_type_cstring(src)) && is_type_integer(dst)) { + Type *vt = core_type(ir_type(value)); + return ir_emit(proc, ir_instr_conv(proc, irConv_ptrtoint, value, vt, t)); + } + if (ir_is_type_aggregate(src) || ir_is_type_aggregate(dst)) { irValue *s = ir_address_from_load_or_generate_local(proc, value); irValue *d = ir_emit_bitcast(proc, s, alloc_type_pointer(t)); |