mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 07:34:07 +00:00
FFI: Compile assignments from enums.
Thanks to Robert G. Jakabosky.
This commit is contained in:
parent
5e227865bc
commit
e2373c1538
@ -422,6 +422,7 @@ static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval)
|
|||||||
if (ctype_isref(s->info)) {
|
if (ctype_isref(s->info)) {
|
||||||
svisnz = *(void **)svisnz;
|
svisnz = *(void **)svisnz;
|
||||||
s = ctype_rawchild(cts, s);
|
s = ctype_rawchild(cts, s);
|
||||||
|
if (ctype_isenum(s->info)) s = ctype_child(cts, s);
|
||||||
t = crec_ct2irt(cts, s);
|
t = crec_ct2irt(cts, s);
|
||||||
} else {
|
} else {
|
||||||
goto doconv;
|
goto doconv;
|
||||||
@ -431,6 +432,7 @@ static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval)
|
|||||||
lj_needsplit(J);
|
lj_needsplit(J);
|
||||||
goto doconv;
|
goto doconv;
|
||||||
} else if (t == IRT_INT || t == IRT_U32) {
|
} else if (t == IRT_INT || t == IRT_U32) {
|
||||||
|
if (ctype_isenum(s->info)) s = ctype_child(cts, s);
|
||||||
sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT);
|
sp = emitir(IRT(IR_FLOAD, t), sp, IRFL_CDATA_INT);
|
||||||
goto doconv;
|
goto doconv;
|
||||||
} else {
|
} else {
|
||||||
@ -691,14 +693,15 @@ static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id)
|
|||||||
setintV(&tv, 0);
|
setintV(&tv, 0);
|
||||||
if (!gcref(df->name)) continue; /* Ignore unnamed fields. */
|
if (!gcref(df->name)) continue; /* Ignore unnamed fields. */
|
||||||
dc = ctype_rawchild(cts, df); /* Field type. */
|
dc = ctype_rawchild(cts, df); /* Field type. */
|
||||||
if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info)))
|
if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) ||
|
||||||
|
ctype_isenum(dc->info)))
|
||||||
lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init aggregates. */
|
lj_trace_err(J, LJ_TRERR_NYICONV); /* NYI: init aggregates. */
|
||||||
if (J->base[i]) {
|
if (J->base[i]) {
|
||||||
sp = J->base[i];
|
sp = J->base[i];
|
||||||
sval = &rd->argv[i];
|
sval = &rd->argv[i];
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
sp = ctype_isnum(dc->info) ? lj_ir_kint(J, 0) : TREF_NIL;
|
sp = ctype_isptr(dc->info) ? TREF_NIL : lj_ir_kint(J, 0);
|
||||||
}
|
}
|
||||||
dp = emitir(IRT(IR_ADD, IRT_PTR), trcd,
|
dp = emitir(IRT(IR_ADD, IRT_PTR), trcd,
|
||||||
lj_ir_kintp(J, df->size + sizeof(GCcdata)));
|
lj_ir_kintp(J, df->size + sizeof(GCcdata)));
|
||||||
|
Loading…
Reference in New Issue
Block a user