Improve assertions.
This commit is contained in:
@@ -153,7 +153,7 @@ CTypeID lj_ctype_new(CTState *cts, CType **ctp)
|
||||
{
|
||||
CTypeID id = cts->top;
|
||||
CType *ct;
|
||||
lua_assert(cts->L);
|
||||
lj_assertCTS(cts->L, "uninitialized cts->L");
|
||||
if (LJ_UNLIKELY(id >= cts->sizetab)) {
|
||||
if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV);
|
||||
#ifdef LUAJIT_CTYPE_CHECK_ANCHOR
|
||||
@@ -182,7 +182,7 @@ CTypeID lj_ctype_intern(CTState *cts, CTInfo info, CTSize size)
|
||||
{
|
||||
uint32_t h = ct_hashtype(info, size);
|
||||
CTypeID id = cts->hash[h];
|
||||
lua_assert(cts->L);
|
||||
lj_assertCTS(cts->L, "uninitialized cts->L");
|
||||
while (id) {
|
||||
CType *ct = ctype_get(cts, id);
|
||||
if (ct->info == info && ct->size == size)
|
||||
@@ -298,9 +298,9 @@ CTSize lj_ctype_vlsize(CTState *cts, CType *ct, CTSize nelem)
|
||||
}
|
||||
ct = ctype_raw(cts, arrid);
|
||||
}
|
||||
lua_assert(ctype_isvlarray(ct->info)); /* Must be a VLA. */
|
||||
lj_assertCTS(ctype_isvlarray(ct->info), "VLA expected");
|
||||
ct = ctype_rawchild(cts, ct); /* Get array element. */
|
||||
lua_assert(ctype_hassize(ct->info));
|
||||
lj_assertCTS(ctype_hassize(ct->info), "bad VLA without size");
|
||||
/* Calculate actual size of VLA and check for overflow. */
|
||||
xsz += (uint64_t)ct->size * nelem;
|
||||
return xsz < 0x80000000u ? (CTSize)xsz : CTSIZE_INVALID;
|
||||
@@ -323,7 +323,8 @@ CTInfo lj_ctype_info(CTState *cts, CTypeID id, CTSize *szp)
|
||||
} else {
|
||||
if (!(qual & CTFP_ALIGNED)) qual |= (info & CTF_ALIGN);
|
||||
qual |= (info & ~(CTF_ALIGN|CTMASK_CID));
|
||||
lua_assert(ctype_hassize(info) || ctype_isfunc(info));
|
||||
lj_assertCTS(ctype_hassize(info) || ctype_isfunc(info),
|
||||
"ctype without size");
|
||||
*szp = ctype_isfunc(info) ? CTSIZE_INVALID : ct->size;
|
||||
break;
|
||||
}
|
||||
@@ -528,7 +529,7 @@ static void ctype_repr(CTRepr *ctr, CTypeID id)
|
||||
ctype_appc(ctr, ')');
|
||||
break;
|
||||
default:
|
||||
lua_assert(0);
|
||||
lj_assertG_(ctr->cts->g, 0, "bad ctype %08x", info);
|
||||
break;
|
||||
}
|
||||
ct = ctype_get(ctr->cts, ctype_cid(info));
|
||||
|
||||
Reference in New Issue
Block a user