aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib_ffi.c4
-rw-r--r--src/lj_cparse.c2
-rw-r--r--src/lj_ctype.c8
-rw-r--r--src/lj_ctype.h1
4 files changed, 12 insertions, 3 deletions
diff --git a/src/lib_ffi.c b/src/lib_ffi.c
index ac2b2742..2295cf15 100644
--- a/src/lib_ffi.c
+++ b/src/lib_ffi.c
@@ -639,7 +639,7 @@ LJLIB_CF(ffi_alignof) LJLIB_REC(ffi_xof FF_ffi_alignof)
639 CTState *cts = ctype_cts(L); 639 CTState *cts = ctype_cts(L);
640 CTypeID id = ffi_checkctype(L, cts, NULL); 640 CTypeID id = ffi_checkctype(L, cts, NULL);
641 CTSize sz = 0; 641 CTSize sz = 0;
642 CTInfo info = lj_ctype_info(cts, id, &sz); 642 CTInfo info = lj_ctype_info_raw(cts, id, &sz);
643 setintV(L->top-1, 1 << ctype_align(info)); 643 setintV(L->top-1, 1 << ctype_align(info));
644 return 1; 644 return 1;
645} 645}
@@ -770,7 +770,7 @@ LJLIB_CF(ffi_metatype)
770 CTypeID id = ffi_checkctype(L, cts, NULL); 770 CTypeID id = ffi_checkctype(L, cts, NULL);
771 GCtab *mt = lj_lib_checktab(L, 2); 771 GCtab *mt = lj_lib_checktab(L, 2);
772 GCtab *t = cts->miscmap; 772 GCtab *t = cts->miscmap;
773 CType *ct = ctype_get(cts, id); /* Only allow raw types. */ 773 CType *ct = ctype_raw(cts, id);
774 TValue *tv; 774 TValue *tv;
775 GCcdata *cd; 775 GCcdata *cd;
776 if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) || 776 if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) ||
diff --git a/src/lj_cparse.c b/src/lj_cparse.c
index e364939d..7fd83997 100644
--- a/src/lj_cparse.c
+++ b/src/lj_cparse.c
@@ -468,7 +468,7 @@ static void cp_expr_sizeof(CPState *cp, CPValue *k, int wantsz)
468 } else { 468 } else {
469 cp_expr_unary(cp, k); 469 cp_expr_unary(cp, k);
470 } 470 }
471 info = lj_ctype_info(cp->cts, k->id, &sz); 471 info = lj_ctype_info_raw(cp->cts, k->id, &sz);
472 if (wantsz) { 472 if (wantsz) {
473 if (sz != CTSIZE_INVALID) 473 if (sz != CTSIZE_INVALID)
474 k->u32 = sz; 474 k->u32 = sz;
diff --git a/src/lj_ctype.c b/src/lj_ctype.c
index 4655eee7..204be034 100644
--- a/src/lj_ctype.c
+++ b/src/lj_ctype.c
@@ -333,6 +333,14 @@ CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp)
333 return qual; 333 return qual;
334} 334}
335 335
336/* Ditto, but follow a reference. */
337CTInfo lj_ctype_info_raw(CTState *cts, CTypeID id, CTSize *szp)
338{
339 CType *ct = ctype_get(cts, id);
340 if (ctype_isref(ct->info)) id = ctype_cid(ct->info);
341 return lj_ctype_info(cts, id, szp);
342}
343
336/* Get ctype metamethod. */ 344/* Get ctype metamethod. */
337cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm) 345cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm)
338{ 346{
diff --git a/src/lj_ctype.h b/src/lj_ctype.h
index 2473b57e..3dbcdbfb 100644
--- a/src/lj_ctype.h
+++ b/src/lj_ctype.h
@@ -468,6 +468,7 @@ LJ_FUNC CType *lj_ctype_rawref(CTState *cts, CTypeID id);
468LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id); 468LJ_FUNC CTSize lj_ctype_size(CTState *cts, CTypeID id);
469LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem); 469LJ_FUNC CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem);
470LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp); 470LJ_FUNC CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp);
471LJ_FUNC CTInfo lj_ctype_info_raw(CTState *cts, CTypeID id, CTSize *szp);
471LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm); 472LJ_FUNC cTValue *lj_ctype_meta(CTState *cts, CTypeID id, MMS mm);
472LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name); 473LJ_FUNC GCstr *lj_ctype_repr(lua_State *L, CTypeID id, GCstr *name);
473LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned); 474LJ_FUNC GCstr *lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned);