mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-13 01:30:30 +00:00
backport math.type from 5.3
This commit is contained in:
parent
78f5f1cef1
commit
636aaed7cc
@ -94,6 +94,21 @@ LJLIB_ASM(math_min) LJLIB_REC(math_minmax IR_MIN)
|
||||
}
|
||||
LJLIB_ASM_(math_max) LJLIB_REC(math_minmax IR_MAX)
|
||||
|
||||
LJLIB_CF(math_type)
|
||||
{
|
||||
if (lua_type(L, 1) == LUA_TNUMBER) {
|
||||
if (lua_isinteger(L, 1))
|
||||
lua_pushliteral(L, "integer");
|
||||
else
|
||||
lua_pushliteral(L, "float");
|
||||
}
|
||||
else {
|
||||
luaL_checkany(L, 1);
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
LJLIB_PUSH(3.14159265358979323846) LJLIB_SET(pi)
|
||||
LJLIB_PUSH(1e310) LJLIB_SET(huge)
|
||||
|
||||
|
@ -231,6 +231,12 @@ LUA_API int lua_iscfunction(lua_State *L, int idx)
|
||||
return tvisfunc(o) && !isluafunc(funcV(o));
|
||||
}
|
||||
|
||||
LUA_API int lua_isinteger (lua_State *L, int idx) {
|
||||
cTValue *o = index2adr(L, idx);
|
||||
return tvisint(o) ||
|
||||
(tvisnumber(o) && ((lua_Number)(lua_Integer)numV(o) == numV(o)));
|
||||
}
|
||||
|
||||
LUA_API int lua_isnumber(lua_State *L, int idx)
|
||||
{
|
||||
cTValue *o = index2adr(L, idx);
|
||||
|
@ -347,6 +347,8 @@ LUA_API void *lua_upvalueid (lua_State *L, int idx, int n);
|
||||
LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2);
|
||||
LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt,
|
||||
const char *chunkname, const char *mode);
|
||||
/* From Lua 5.3. */
|
||||
LUA_API int lua_isinteger (lua_State *L, int idx);
|
||||
|
||||
|
||||
struct lua_Debug {
|
||||
|
Loading…
Reference in New Issue
Block a user