diff options
Diffstat (limited to 'ldblib.c')
-rw-r--r-- | ldblib.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.140 2014/08/21 19:12:40 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.141 2014/08/22 16:22:42 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -160,7 +160,7 @@ static int db_getinfo (lua_State *L) { | |||
160 | lua_xmove(L, L1, 1); | 160 | lua_xmove(L, L1, 1); |
161 | } | 161 | } |
162 | else { /* stack level */ | 162 | else { /* stack level */ |
163 | if (!lua_getstack(L1, luaL_checkint(L, arg + 1), &ar)) { | 163 | if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) { |
164 | lua_pushnil(L); /* level out of range */ | 164 | lua_pushnil(L); /* level out of range */ |
165 | return 1; | 165 | return 1; |
166 | } | 166 | } |
@@ -201,14 +201,15 @@ static int db_getlocal (lua_State *L) { | |||
201 | lua_State *L1 = getthread(L, &arg); | 201 | lua_State *L1 = getthread(L, &arg); |
202 | lua_Debug ar; | 202 | lua_Debug ar; |
203 | const char *name; | 203 | const char *name; |
204 | int nvar = luaL_checkint(L, arg+2); /* local-variable index */ | 204 | int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */ |
205 | if (lua_isfunction(L, arg + 1)) { /* function argument? */ | 205 | if (lua_isfunction(L, arg + 1)) { /* function argument? */ |
206 | lua_pushvalue(L, arg + 1); /* push function */ | 206 | lua_pushvalue(L, arg + 1); /* push function */ |
207 | lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ | 207 | lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ |
208 | return 1; /* return only name (there is no value) */ | 208 | return 1; /* return only name (there is no value) */ |
209 | } | 209 | } |
210 | else { /* stack-level argument */ | 210 | else { /* stack-level argument */ |
211 | if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ | 211 | int level = (int)luaL_checkinteger(L, arg + 1); |
212 | if (!lua_getstack(L1, level, &ar)) /* out of range? */ | ||
212 | return luaL_argerror(L, arg+1, "level out of range"); | 213 | return luaL_argerror(L, arg+1, "level out of range"); |
213 | name = lua_getlocal(L1, &ar, nvar); | 214 | name = lua_getlocal(L1, &ar, nvar); |
214 | if (name) { | 215 | if (name) { |
@@ -229,12 +230,13 @@ static int db_setlocal (lua_State *L) { | |||
229 | int arg; | 230 | int arg; |
230 | lua_State *L1 = getthread(L, &arg); | 231 | lua_State *L1 = getthread(L, &arg); |
231 | lua_Debug ar; | 232 | lua_Debug ar; |
232 | if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ | 233 | int level = (int)luaL_checkinteger(L, arg + 1); |
234 | if (!lua_getstack(L1, level, &ar)) /* out of range? */ | ||
233 | return luaL_argerror(L, arg+1, "level out of range"); | 235 | return luaL_argerror(L, arg+1, "level out of range"); |
234 | luaL_checkany(L, arg+3); | 236 | luaL_checkany(L, arg+3); |
235 | lua_settop(L, arg+3); | 237 | lua_settop(L, arg+3); |
236 | lua_xmove(L, L1, 1); | 238 | lua_xmove(L, L1, 1); |
237 | lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); | 239 | lua_pushstring(L, lua_setlocal(L1, &ar, (int)luaL_checkinteger(L, arg+2))); |
238 | return 1; | 240 | return 1; |
239 | } | 241 | } |
240 | 242 | ||
@@ -244,7 +246,7 @@ static int db_setlocal (lua_State *L) { | |||
244 | */ | 246 | */ |
245 | static int auxupvalue (lua_State *L, int get) { | 247 | static int auxupvalue (lua_State *L, int get) { |
246 | const char *name; | 248 | const char *name; |
247 | int n = luaL_checkint(L, 2); /* upvalue index */ | 249 | int n = (int)luaL_checkinteger(L, 2); /* upvalue index */ |
248 | luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ | 250 | luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ |
249 | name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); | 251 | name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); |
250 | if (name == NULL) return 0; | 252 | if (name == NULL) return 0; |
@@ -270,7 +272,7 @@ static int db_setupvalue (lua_State *L) { | |||
270 | ** returns its index | 272 | ** returns its index |
271 | */ | 273 | */ |
272 | static int checkupval (lua_State *L, int argf, int argnup) { | 274 | static int checkupval (lua_State *L, int argf, int argnup) { |
273 | int nup = luaL_checkint(L, argnup); /* upvalue index */ | 275 | int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */ |
274 | luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ | 276 | luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ |
275 | luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup, | 277 | luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup, |
276 | "invalid upvalue index"); | 278 | "invalid upvalue index"); |
@@ -359,7 +361,7 @@ static int db_sethook (lua_State *L) { | |||
359 | else { | 361 | else { |
360 | const char *smask = luaL_checkstring(L, arg+2); | 362 | const char *smask = luaL_checkstring(L, arg+2); |
361 | luaL_checktype(L, arg+1, LUA_TFUNCTION); | 363 | luaL_checktype(L, arg+1, LUA_TFUNCTION); |
362 | count = luaL_optint(L, arg+3, 0); | 364 | count = (int)luaL_optinteger(L, arg + 3, 0); |
363 | func = hookf; mask = makemask(smask, count); | 365 | func = hookf; mask = makemask(smask, count); |
364 | } | 366 | } |
365 | if (gethooktable(L) == 0) { /* creating hook table? */ | 367 | if (gethooktable(L) == 0) { /* creating hook table? */ |
@@ -418,7 +420,7 @@ static int db_traceback (lua_State *L) { | |||
418 | if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ | 420 | if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ |
419 | lua_pushvalue(L, arg + 1); /* return it untouched */ | 421 | lua_pushvalue(L, arg + 1); /* return it untouched */ |
420 | else { | 422 | else { |
421 | int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0); | 423 | int level = (int)luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0); |
422 | luaL_traceback(L, L1, msg, level); | 424 | luaL_traceback(L, L1, msg, level); |
423 | } | 425 | } |
424 | return 1; | 426 | return 1; |