DUALNUM: Add integer type to core VM.
This commit is contained in:
14
src/lj_lib.c
14
src/lj_lib.c
@@ -135,8 +135,8 @@ GCstr *lj_lib_checkstr(lua_State *L, int narg)
|
||||
if (o < L->top) {
|
||||
if (LJ_LIKELY(tvisstr(o))) {
|
||||
return strV(o);
|
||||
} else if (tvisnum(o)) {
|
||||
GCstr *s = lj_str_fromnum(L, &o->n);
|
||||
} else if (tvisnumber(o)) {
|
||||
GCstr *s = lj_str_fromnumber(L, o);
|
||||
setstrV(L, o, s);
|
||||
return s;
|
||||
}
|
||||
@@ -155,14 +155,18 @@ lua_Number lj_lib_checknum(lua_State *L, int narg)
|
||||
{
|
||||
TValue *o = L->base + narg-1;
|
||||
if (!(o < L->top &&
|
||||
(tvisnum(o) || (tvisstr(o) && lj_str_tonum(strV(o), o)))))
|
||||
(tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o)))))
|
||||
lj_err_argt(L, narg, LUA_TNUMBER);
|
||||
return numV(o);
|
||||
return numberVnum(o);
|
||||
}
|
||||
|
||||
int32_t lj_lib_checkint(lua_State *L, int narg)
|
||||
{
|
||||
return lj_num2int(lj_lib_checknum(L, narg));
|
||||
TValue *o = L->base + narg-1;
|
||||
if (!(o < L->top &&
|
||||
(tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o)))))
|
||||
lj_err_argt(L, narg, LUA_TNUMBER);
|
||||
return numberVint(o);
|
||||
}
|
||||
|
||||
int32_t lj_lib_optint(lua_State *L, int narg, int32_t def)
|
||||
|
||||
Reference in New Issue
Block a user