FFI: Fix auto-deref of pointers to structs.

This commit is contained in:
Mike Pall
2010-12-15 19:47:01 +01:00
parent badff4ed0a
commit fbcc925a2d
2 changed files with 15 additions and 9 deletions

View File

@@ -363,9 +363,17 @@ void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd)
GCstr *name = strV(&rd->argv[1]);
/* Always specialize to the field name. */
emitir(IRTG(IR_EQ, IRT_STR), idx, lj_ir_kstr(J, name));
if (ctype_isstruct(ct->info)) {
if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */
CType *cct = ctype_rawchild(cts, ct);
if (ctype_isstruct(cct->info)) {
ct = cct;
goto index_struct;
}
} else if (ctype_isstruct(ct->info)) {
CTSize fofs;
CType *fct = lj_ctype_getfield(cts, ct, name, &fofs);
CType *fct;
index_struct:
fct = lj_ctype_getfield(cts, ct, name, &fofs);
if (fct) {
if (ctype_isconstval(fct->info)) {
if (fct->size >= 0x80000000u &&