aboutsummaryrefslogtreecommitdiff
path: root/ldblib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldblib.c')
-rw-r--r--ldblib.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/ldblib.c b/ldblib.c
index e067efac..5c1c57d0 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.112 2009/09/09 20:32:19 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.113 2009/11/05 16:48:31 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*/
@@ -199,23 +199,10 @@ static int db_setupvalue (lua_State *L) {
199} 199}
200 200
201 201
202static int db_upvaladdr (lua_State *L) {
203 void *addr;
204 int n = luaL_checkint(L, 2);
205 luaL_checktype(L, 1, LUA_TFUNCTION);
206 addr = lua_upvaladdr(L, 1, n);
207 if (addr == NULL) lua_pushnil(L);
208 else lua_pushlightuserdata(L, addr);
209 return 1;
210}
211
212
213static int checkupval (lua_State *L, int argf, int argnup) { 202static int checkupval (lua_State *L, int argf, int argnup) {
214 lua_Debug ar; 203 lua_Debug ar;
215 int nup = luaL_checkint(L, argnup); 204 int nup = luaL_checkint(L, argnup);
216 luaL_checktype(L, argf, LUA_TFUNCTION); 205 luaL_checktype(L, argf, LUA_TFUNCTION);
217 luaL_argcheck(L, !lua_iscfunction(L, argf), argf,
218 "cannot join upvalues of a C function");
219 lua_pushvalue(L, argf); 206 lua_pushvalue(L, argf);
220 lua_getinfo(L, ">u", &ar); 207 lua_getinfo(L, ">u", &ar);
221 luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index"); 208 luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index");
@@ -223,9 +210,18 @@ static int checkupval (lua_State *L, int argf, int argnup) {
223} 210}
224 211
225 212
213static int db_upvaladdr (lua_State *L) {
214 int n = checkupval(L, 1, 2);
215 lua_pushlightuserdata(L, lua_upvaladdr(L, 1, n));
216 return 1;
217}
218
219
226static int db_joinupval (lua_State *L) { 220static int db_joinupval (lua_State *L) {
227 int n1 = checkupval(L, 1, 2); 221 int n1 = checkupval(L, 1, 2);
228 int n2 = checkupval(L, 3, 4); 222 int n2 = checkupval(L, 3, 4);
223 luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected");
224 luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected");
229 lua_upvaljoin(L, 1, n1, 3, n2); 225 lua_upvaljoin(L, 1, n1, 3, n2);
230 return 0; 226 return 0;
231} 227}