Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall 2022-07-13 00:37:14 +02:00
commit 50936d7844
4 changed files with 12 additions and 3 deletions

View File

@ -639,7 +639,7 @@ LJLIB_CF(ffi_alignof) LJLIB_REC(ffi_xof FF_ffi_alignof)
CTState *cts = ctype_cts(L); CTState *cts = ctype_cts(L);
CTypeID id = ffi_checkctype(L, cts, NULL); CTypeID id = ffi_checkctype(L, cts, NULL);
CTSize sz = 0; CTSize sz = 0;
CTInfo info = lj_ctype_info(cts, id, &sz); CTInfo info = lj_ctype_info_raw(cts, id, &sz);
setintV(L->top-1, 1 << ctype_align(info)); setintV(L->top-1, 1 << ctype_align(info));
return 1; return 1;
} }
@ -770,7 +770,7 @@ LJLIB_CF(ffi_metatype)
CTypeID id = ffi_checkctype(L, cts, NULL); CTypeID id = ffi_checkctype(L, cts, NULL);
GCtab *mt = lj_lib_checktab(L, 2); GCtab *mt = lj_lib_checktab(L, 2);
GCtab *t = cts->miscmap; GCtab *t = cts->miscmap;
CType *ct = ctype_get(cts, id); /* Only allow raw types. */ CType *ct = ctype_raw(cts, id);
TValue *tv; TValue *tv;
GCcdata *cd; GCcdata *cd;
if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) || if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) ||

View File

@ -468,7 +468,7 @@ static void cp_expr_sizeof(CPState *cp, CPValue *k, int wantsz)
} else { } else {
cp_expr_unary(cp, k); cp_expr_unary(cp, k);
} }
info = lj_ctype_info(cp->cts, k->id, &sz); info = lj_ctype_info_raw(cp->cts, k->id, &sz);
if (wantsz) { if (wantsz) {
if (sz != CTSIZE_INVALID) if (sz != CTSIZE_INVALID)
k->u32 = sz; k->u32 = sz;

View File

@ -333,6 +333,14 @@ CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp)
return qual; return qual;
} }
/* Ditto, but follow a reference. */
CTInfo lj_ctype_info_raw(CTState *cts, CTypeID id, CTSize *szp)
{
CType *ct = ctype_get(cts, id);
if (ctype_isref(ct->info)) id = ctype_cid(ct->info);
return lj_ctype_info(cts, id, szp);
}
/* Get ctype metamethod. */ /* Get ctype metamethod. */
cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm) cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm)
{ {

View File

@ -468,6 +468,7 @@ LJ_FUNC CType *lj_ctype_rawref(CTState *cts, CTypeID id);
LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id); LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id);
LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem); LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem);
LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp); LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp);
LJ_FUNC CTInfo lj_ctype_info_raw(CTState *cts, CTypeID id, CTSize *szp);
LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm); LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm);
LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name); LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name);
LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned); LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned);