Improve assertions.

This commit is contained in:
Mike Pall
2020-06-13 00:52:54 +02:00
parent 8b55054473
commit 8ae5170cdc
71 changed files with 1363 additions and 927 deletions

View File

@@ -47,7 +47,7 @@ void lj_meta_init(lua_State *L)
cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name)
{
cTValue *mo = lj_tab_getstr(mt, name);
lua_assert(mm <= MM_FAST);
lj_assertX(mm <= MM_FAST, "bad metamethod %d", mm);
if (!mo || tvisnil(mo)) { /* No metamethod? */
mt->nomm |= (uint8_t)(1u<<mm); /* Set negative cache flag. */
return NULL;
@@ -363,7 +363,7 @@ TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins)
} else if (op == BC_ISEQN) {
o2 = &mref(curr_proto(L)->k, cTValue)[bc_d(ins)];
} else {
lua_assert(op == BC_ISEQP);
lj_assertL(op == BC_ISEQP, "bad bytecode op %d", op);
setpriV(&tv, ~bc_d(ins));
o2 = &tv;
}
@@ -426,7 +426,7 @@ void lj_meta_istype(lua_State *L, BCReg ra, BCReg tp)
{
L->top = curr_topL(L);
ra++; tp--;
lua_assert(LJ_DUALNUM || tp != ~LJ_TNUMX); /* ISTYPE -> ISNUM broken. */
lj_assertL(LJ_DUALNUM || tp != ~LJ_TNUMX, "bad type for ISTYPE");
if (LJ_DUALNUM && tp == ~LJ_TNUMX) lj_lib_checkint(L, ra);
else if (tp == ~LJ_TNUMX+1) lj_lib_checknum(L, ra);
else if (tp == ~LJ_TSTR) lj_lib_checkstr(L, ra);