aboutsummaryrefslogtreecommitdiff
path: root/src/lj_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_api.c')
-rw-r--r--src/lj_api.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index 7a759e5f..4bac5024 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -227,7 +227,7 @@ LUA_API int lua_isnumber(lua_State *L, int idx)
227{ 227{
228 cTValue *o = index2adr(L, idx); 228 cTValue *o = index2adr(L, idx);
229 TValue tmp; 229 TValue tmp;
230 return (tvisnum(o) || (tvisstr(o) && lj_str_numconv(strVdata(o), &tmp))); 230 return (tvisnum(o) || (tvisstr(o) && lj_str_tonum(strV(o), &tmp)));
231} 231}
232 232
233LUA_API int lua_isstring(lua_State *L, int idx) 233LUA_API int lua_isstring(lua_State *L, int idx)
@@ -307,7 +307,7 @@ LUA_API lua_Number lua_tonumber(lua_State *L, int idx)
307 TValue tmp; 307 TValue tmp;
308 if (LJ_LIKELY(tvisnum(o))) 308 if (LJ_LIKELY(tvisnum(o)))
309 return numV(o); 309 return numV(o);
310 else if (tvisstr(o) && lj_str_numconv(strVdata(o), &tmp)) 310 else if (tvisstr(o) && lj_str_tonum(strV(o), &tmp))
311 return numV(&tmp); 311 return numV(&tmp);
312 else 312 else
313 return 0; 313 return 0;
@@ -319,7 +319,7 @@ LUALIB_API lua_Number luaL_checknumber(lua_State *L, int idx)
319 TValue tmp; 319 TValue tmp;
320 if (tvisnum(o)) 320 if (tvisnum(o))
321 return numV(o); 321 return numV(o);
322 else if (!(tvisstr(o) && lj_str_numconv(strVdata(o), &tmp))) 322 else if (!(tvisstr(o) && lj_str_tonum(strV(o), &tmp)))
323 lj_err_argt(L, idx, LUA_TNUMBER); 323 lj_err_argt(L, idx, LUA_TNUMBER);
324 return numV(&tmp); 324 return numV(&tmp);
325} 325}
@@ -332,7 +332,7 @@ LUALIB_API lua_Number luaL_optnumber(lua_State *L, int idx, lua_Number def)
332 return numV(o); 332 return numV(o);
333 else if (tvisnil(o)) 333 else if (tvisnil(o))
334 return def; 334 return def;
335 else if (!(tvisstr(o) && lj_str_numconv(strVdata(o), &tmp))) 335 else if (!(tvisstr(o) && lj_str_tonum(strV(o), &tmp)))
336 lj_err_argt(L, idx, LUA_TNUMBER); 336 lj_err_argt(L, idx, LUA_TNUMBER);
337 return numV(&tmp); 337 return numV(&tmp);
338} 338}
@@ -344,7 +344,7 @@ LUA_API lua_Integer lua_tointeger(lua_State *L, int idx)
344 lua_Number n; 344 lua_Number n;
345 if (LJ_LIKELY(tvisnum(o))) 345 if (LJ_LIKELY(tvisnum(o)))
346 n = numV(o); 346 n = numV(o);
347 else if (tvisstr(o) && lj_str_numconv(strVdata(o), &tmp)) 347 else if (tvisstr(o) && lj_str_tonum(strV(o), &tmp))
348 n = numV(&tmp); 348 n = numV(&tmp);
349 else 349 else
350 return 0; 350 return 0;
@@ -362,7 +362,7 @@ LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int idx)
362 lua_Number n; 362 lua_Number n;
363 if (LJ_LIKELY(tvisnum(o))) 363 if (LJ_LIKELY(tvisnum(o)))
364 n = numV(o); 364 n = numV(o);
365 else if (tvisstr(o) && lj_str_numconv(strVdata(o), &tmp)) 365 else if (tvisstr(o) && lj_str_tonum(strV(o), &tmp))
366 n = numV(&tmp); 366 n = numV(&tmp);
367 else 367 else
368 lj_err_argt(L, idx, LUA_TNUMBER); 368 lj_err_argt(L, idx, LUA_TNUMBER);
@@ -382,7 +382,7 @@ LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int idx, lua_Integer def)
382 n = numV(o); 382 n = numV(o);
383 else if (tvisnil(o)) 383 else if (tvisnil(o))
384 return def; 384 return def;
385 else if (tvisstr(o) && lj_str_numconv(strVdata(o), &tmp)) 385 else if (tvisstr(o) && lj_str_tonum(strV(o), &tmp))
386 n = numV(&tmp); 386 n = numV(&tmp);
387 else 387 else
388 lj_err_argt(L, idx, LUA_TNUMBER); 388 lj_err_argt(L, idx, LUA_TNUMBER);
@@ -753,7 +753,7 @@ LUA_API int lua_getmetatable(lua_State *L, int idx)
753 else if (tvisudata(o)) 753 else if (tvisudata(o))
754 mt = tabref(udataV(o)->metatable); 754 mt = tabref(udataV(o)->metatable);
755 else 755 else
756 mt = tabref(G(L)->basemt[itypemap(o)]); 756 mt = tabref(basemt_obj(G(L), o));
757 if (mt == NULL) 757 if (mt == NULL)
758 return 0; 758 return 0;
759 settabV(L, L->top, mt); 759 settabV(L, L->top, mt);
@@ -941,12 +941,12 @@ LUA_API int lua_setmetatable(lua_State *L, int idx)
941 if (lj_trace_flushall(L)) 941 if (lj_trace_flushall(L))
942 lj_err_caller(L, LJ_ERR_NOGCMM); 942 lj_err_caller(L, LJ_ERR_NOGCMM);
943 if (tvisbool(o)) { 943 if (tvisbool(o)) {
944 /* NOBARRIER: g->basemt[] is a GC root. */ 944 /* NOBARRIER: basemt is a GC root. */
945 setgcref(g->basemt[~LJ_TTRUE], obj2gco(mt)); 945 setgcref(basemt_it(g, LJ_TTRUE), obj2gco(mt));
946 setgcref(g->basemt[~LJ_TFALSE], obj2gco(mt)); 946 setgcref(basemt_it(g, LJ_TFALSE), obj2gco(mt));
947 } else { 947 } else {
948 /* NOBARRIER: g->basemt[] is a GC root. */ 948 /* NOBARRIER: basemt is a GC root. */
949 setgcref(g->basemt[itypemap(o)], obj2gco(mt)); 949 setgcref(basemt_obj(g, o), obj2gco(mt));
950 } 950 }
951 } 951 }
952 L->top--; 952 L->top--;