summaryrefslogtreecommitdiff
path: root/src/lj_crecord.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_crecord.c')
-rw-r--r--src/lj_crecord.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 8373faaa..743137de 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -1138,10 +1138,18 @@ void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd)
1138void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd) 1138void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd)
1139{ 1139{
1140 CTState *cts = ctype_ctsG(J2G(J)); 1140 CTState *cts = ctype_ctsG(J2G(J));
1141 IRType st = crec_ct2irt(ctype_raw(cts, cdataV(&rd->argv[0])->typeid)); 1141 CType *d, *ct = lj_ctype_rawref(cts, cdataV(&rd->argv[0])->typeid);
1142 CTypeID did = (st >= IRT_I8 && st <= IRT_INT) ? CTID_INT32 : CTID_DOUBLE; 1142 if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct);
1143 CType *d = ctype_get(cts, did); 1143 if (ctype_isnum(ct->info) || ctype_iscomplex(ct->info)) {
1144 J->base[0] = crec_ct_tv(J, d, 0, J->base[0], &rd->argv[0]); 1144 if (ctype_isinteger_or_bool(ct->info) && ct->size <= 4 &&
1145 !(ct->size == 4 && (ct->info & CTF_UNSIGNED)))
1146 d = ctype_get(cts, CTID_INT32);
1147 else
1148 d = ctype_get(cts, CTID_DOUBLE);
1149 J->base[0] = crec_ct_tv(J, d, 0, J->base[0], &rd->argv[0]);
1150 } else {
1151 J->base[0] = TREF_NIL;
1152 }
1145} 1153}
1146 1154
1147#undef IR 1155#undef IR