DUALNUM: Add integer type to core VM.

This commit is contained in:
Mike Pall
2011-02-17 00:44:14 +01:00
parent 963f05c7e1
commit 03946ac978
23 changed files with 403 additions and 189 deletions

View File

@@ -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)