FFI: Record conversions from bool ctype.

This commit is contained in:
Mike Pall 2011-01-17 01:21:57 +01:00
parent 66ba1e68aa
commit 83d8c86bbb
2 changed files with 8 additions and 3 deletions

View File

@ -371,7 +371,9 @@ int lj_cconv_tv_ct(CTState *cts, CType *s, CTypeID sid,
/* Numbers are NOT canonicalized here! Beware of uninitialized data. */ /* Numbers are NOT canonicalized here! Beware of uninitialized data. */
lua_assert(tvisnum(o)); lua_assert(tvisnum(o));
} else { } else {
setboolV(o, (*sp & 1)); uint32_t b = ((*sp) & 1);
setboolV(o, b);
setboolV(&cts->g->tmptv2, b); /* Remember for trace recorder. */
} }
return 0; return 0;
} else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) { } else if (ctype_isrefarray(sinfo) || ctype_isstruct(sinfo)) {

View File

@ -301,8 +301,6 @@ static TRef crec_tv_ct(jit_State *J, CType *s, CTypeID sid, TRef sp)
if (ctype_isnum(sinfo)) { if (ctype_isnum(sinfo)) {
IRType t = crec_ct2irt(s); IRType t = crec_ct2irt(s);
TRef tr; TRef tr;
if ((sinfo & CTF_BOOL))
goto err_nyi; /* NYI: specialize to the result. */
if (t == IRT_CDATA) if (t == IRT_CDATA)
goto err_nyi; /* NYI: copyval of >64 bit integers. */ goto err_nyi; /* NYI: copyval of >64 bit integers. */
tr = emitir(IRT(IR_XLOAD, t), sp, 0); tr = emitir(IRT(IR_XLOAD, t), sp, 0);
@ -314,6 +312,11 @@ static TRef crec_tv_ct(jit_State *J, CType *s, CTypeID sid, TRef sp)
lj_ir_kintp(J, sizeof(GCcdata))); lj_ir_kintp(J, sizeof(GCcdata)));
emitir(IRT(IR_XSTORE, t), ptr, tr); emitir(IRT(IR_XSTORE, t), ptr, tr);
return dp; return dp;
} else if ((sinfo & CTF_BOOL)) {
/* Assume not equal to zero. Fixup and emit pending guard later. */
lj_ir_set(J, IRTGI(IR_NE), tr, lj_ir_kint(J, 0));
J->postproc = LJ_POST_FIXGUARD;
tr = TREF_TRUE;
} }
return tr; return tr;
} else if (ctype_isptr(sinfo)) { } else if (ctype_isptr(sinfo)) {