• Home
  • Raw
  • Download

Lines Matching +full:- +full:l

25 static int db_getregistry (lua_State *L) {  in db_getregistry()  argument
26 lua_pushvalue(L, LUA_REGISTRYINDEX); in db_getregistry()
31 static int db_getmetatable (lua_State *L) { in db_getmetatable() argument
32 luaL_checkany(L, 1); in db_getmetatable()
33 if (!lua_getmetatable(L, 1)) { in db_getmetatable()
34 lua_pushnil(L); /* no metatable */ in db_getmetatable()
40 static int db_setmetatable (lua_State *L) { in db_setmetatable() argument
41 int t = lua_type(L, 2); in db_setmetatable()
42 luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, in db_setmetatable()
44 lua_settop(L, 2); in db_setmetatable()
45 lua_setmetatable(L, 1); in db_setmetatable()
50 static int db_getuservalue (lua_State *L) { in db_getuservalue() argument
51 if (lua_type(L, 1) != LUA_TUSERDATA) in db_getuservalue()
52 lua_pushnil(L); in db_getuservalue()
54 lua_getuservalue(L, 1); in db_getuservalue()
59 static int db_setuservalue (lua_State *L) { in db_setuservalue() argument
60 if (lua_type(L, 1) == LUA_TLIGHTUSERDATA) in db_setuservalue()
61 luaL_argerror(L, 1, "full userdata expected, got light userdata"); in db_setuservalue()
62 luaL_checktype(L, 1, LUA_TUSERDATA); in db_setuservalue()
63 if (!lua_isnoneornil(L, 2)) in db_setuservalue()
64 luaL_checktype(L, 2, LUA_TTABLE); in db_setuservalue()
65 lua_settop(L, 2); in db_setuservalue()
66 lua_setuservalue(L, 1); in db_setuservalue()
71 static void settabss (lua_State *L, const char *i, const char *v) { in settabss() argument
72 lua_pushstring(L, v); in settabss()
73 lua_setfield(L, -2, i); in settabss()
77 static void settabsi (lua_State *L, const char *i, int v) { in settabsi() argument
78 lua_pushinteger(L, v); in settabsi()
79 lua_setfield(L, -2, i); in settabsi()
83 static void settabsb (lua_State *L, const char *i, int v) { in settabsb() argument
84 lua_pushboolean(L, v); in settabsb()
85 lua_setfield(L, -2, i); in settabsb()
89 static lua_State *getthread (lua_State *L, int *arg) { in getthread() argument
90 if (lua_isthread(L, 1)) { in getthread()
92 return lua_tothread(L, 1); in getthread()
96 return L; in getthread()
101 static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { in treatstackoption() argument
102 if (L == L1) { in treatstackoption()
103 lua_pushvalue(L, -2); in treatstackoption()
104 lua_remove(L, -3); in treatstackoption()
107 lua_xmove(L1, L, 1); in treatstackoption()
108 lua_setfield(L, -2, fname); in treatstackoption()
112 static int db_getinfo (lua_State *L) { in db_getinfo() argument
115 lua_State *L1 = getthread(L, &arg); in db_getinfo()
116 const char *options = luaL_optstring(L, arg+2, "flnStu"); in db_getinfo()
117 if (lua_isnumber(L, arg+1)) { in db_getinfo()
118 if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { in db_getinfo()
119 lua_pushnil(L); /* level out of range */ in db_getinfo()
123 else if (lua_isfunction(L, arg+1)) { in db_getinfo()
124 lua_pushfstring(L, ">%s", options); in db_getinfo()
125 options = lua_tostring(L, -1); in db_getinfo()
126 lua_pushvalue(L, arg+1); in db_getinfo()
127 lua_xmove(L, L1, 1); in db_getinfo()
130 return luaL_argerror(L, arg+1, "function or level expected"); in db_getinfo()
132 return luaL_argerror(L, arg+2, "invalid option"); in db_getinfo()
133 lua_createtable(L, 0, 2); in db_getinfo()
135 settabss(L, "source", ar.source); in db_getinfo()
136 settabss(L, "short_src", ar.short_src); in db_getinfo()
137 settabsi(L, "linedefined", ar.linedefined); in db_getinfo()
138 settabsi(L, "lastlinedefined", ar.lastlinedefined); in db_getinfo()
139 settabss(L, "what", ar.what); in db_getinfo()
141 if (strchr(options, 'l')) in db_getinfo()
142 settabsi(L, "currentline", ar.currentline); in db_getinfo()
144 settabsi(L, "nups", ar.nups); in db_getinfo()
145 settabsi(L, "nparams", ar.nparams); in db_getinfo()
146 settabsb(L, "isvararg", ar.isvararg); in db_getinfo()
149 settabss(L, "name", ar.name); in db_getinfo()
150 settabss(L, "namewhat", ar.namewhat); in db_getinfo()
153 settabsb(L, "istailcall", ar.istailcall); in db_getinfo()
154 if (strchr(options, 'L')) in db_getinfo()
155 treatstackoption(L, L1, "activelines"); in db_getinfo()
157 treatstackoption(L, L1, "func"); in db_getinfo()
162 static int db_getlocal (lua_State *L) { in db_getlocal() argument
164 lua_State *L1 = getthread(L, &arg); in db_getlocal()
167 int nvar = luaL_checkint(L, arg+2); /* local-variable index */ in db_getlocal()
168 if (lua_isfunction(L, arg + 1)) { /* function argument? */ in db_getlocal()
169 lua_pushvalue(L, arg + 1); /* push function */ in db_getlocal()
170 lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ in db_getlocal()
173 else { /* stack-level argument */ in db_getlocal()
174 if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ in db_getlocal()
175 return luaL_argerror(L, arg+1, "level out of range"); in db_getlocal()
178 lua_xmove(L1, L, 1); /* push local value */ in db_getlocal()
179 lua_pushstring(L, name); /* push name */ in db_getlocal()
180 lua_pushvalue(L, -2); /* re-order */ in db_getlocal()
184 lua_pushnil(L); /* no name (nor value) */ in db_getlocal()
191 static int db_setlocal (lua_State *L) { in db_setlocal() argument
193 lua_State *L1 = getthread(L, &arg); in db_setlocal()
195 if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ in db_setlocal()
196 return luaL_argerror(L, arg+1, "level out of range"); in db_setlocal()
197 luaL_checkany(L, arg+3); in db_setlocal()
198 lua_settop(L, arg+3); in db_setlocal()
199 lua_xmove(L, L1, 1); in db_setlocal()
200 lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); in db_setlocal()
205 static int auxupvalue (lua_State *L, int get) { in auxupvalue() argument
207 int n = luaL_checkint(L, 2); in auxupvalue()
208 luaL_checktype(L, 1, LUA_TFUNCTION); in auxupvalue()
209 name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); in auxupvalue()
211 lua_pushstring(L, name); in auxupvalue()
212 lua_insert(L, -(get+1)); in auxupvalue()
217 static int db_getupvalue (lua_State *L) { in db_getupvalue() argument
218 return auxupvalue(L, 1); in db_getupvalue()
222 static int db_setupvalue (lua_State *L) { in db_setupvalue() argument
223 luaL_checkany(L, 3); in db_setupvalue()
224 return auxupvalue(L, 0); in db_setupvalue()
228 static int checkupval (lua_State *L, int argf, int argnup) { in checkupval() argument
230 int nup = luaL_checkint(L, argnup); in checkupval()
231 luaL_checktype(L, argf, LUA_TFUNCTION); in checkupval()
232 lua_pushvalue(L, argf); in checkupval()
233 lua_getinfo(L, ">u", &ar); in checkupval()
234 luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index"); in checkupval()
239 static int db_upvalueid (lua_State *L) { in db_upvalueid() argument
240 int n = checkupval(L, 1, 2); in db_upvalueid()
241 lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); in db_upvalueid()
246 static int db_upvaluejoin (lua_State *L) { in db_upvaluejoin() argument
247 int n1 = checkupval(L, 1, 2); in db_upvaluejoin()
248 int n2 = checkupval(L, 3, 4); in db_upvaluejoin()
249 luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); in db_upvaluejoin()
250 luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); in db_upvaluejoin()
251 lua_upvaluejoin(L, 1, n1, 3, n2); in db_upvaluejoin()
256 #define gethooktable(L) luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY) argument
259 static void hookf (lua_State *L, lua_Debug *ar) { in hookf() argument
262 gethooktable(L); in hookf()
263 lua_pushthread(L); in hookf()
264 lua_rawget(L, -2); in hookf()
265 if (lua_isfunction(L, -1)) { in hookf()
266 lua_pushstring(L, hooknames[(int)ar->event]); in hookf()
267 if (ar->currentline >= 0) in hookf()
268 lua_pushinteger(L, ar->currentline); in hookf()
269 else lua_pushnil(L); in hookf()
270 lua_assert(lua_getinfo(L, "lS", ar)); in hookf()
271 lua_call(L, 2, 0); in hookf()
280 if (strchr(smask, 'l')) mask |= LUA_MASKLINE; in makemask()
290 if (mask & LUA_MASKLINE) smask[i++] = 'l'; in unmakemask()
296 static int db_sethook (lua_State *L) { in db_sethook() argument
299 lua_State *L1 = getthread(L, &arg); in db_sethook()
300 if (lua_isnoneornil(L, arg+1)) { in db_sethook()
301 lua_settop(L, arg+1); in db_sethook()
305 const char *smask = luaL_checkstring(L, arg+2); in db_sethook()
306 luaL_checktype(L, arg+1, LUA_TFUNCTION); in db_sethook()
307 count = luaL_optint(L, arg+3, 0); in db_sethook()
310 if (gethooktable(L) == 0) { /* creating hook table? */ in db_sethook()
311 lua_pushstring(L, "k"); in db_sethook()
312 lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */ in db_sethook()
313 lua_pushvalue(L, -1); in db_sethook()
314 lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ in db_sethook()
316 lua_pushthread(L1); lua_xmove(L1, L, 1); in db_sethook()
317 lua_pushvalue(L, arg+1); in db_sethook()
318 lua_rawset(L, -3); /* set new hook */ in db_sethook()
324 static int db_gethook (lua_State *L) { in db_gethook() argument
326 lua_State *L1 = getthread(L, &arg); in db_gethook()
331 lua_pushliteral(L, "external hook"); in db_gethook()
333 gethooktable(L); in db_gethook()
334 lua_pushthread(L1); lua_xmove(L1, L, 1); in db_gethook()
335 lua_rawget(L, -2); /* get hook */ in db_gethook()
336 lua_remove(L, -2); /* remove hook table */ in db_gethook()
338 lua_pushstring(L, unmakemask(mask, buff)); in db_gethook()
339 lua_pushinteger(L, lua_gethookcount(L1)); in db_gethook()
344 static int db_debug (lua_State *L) { in db_debug() argument
351 if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || in db_debug()
352 lua_pcall(L, 0, 0, 0)) in db_debug()
353 luai_writestringerror("%s\n", lua_tostring(L, -1)); in db_debug()
354 lua_settop(L, 0); /* remove eventual returns */ in db_debug()
359 static int db_traceback (lua_State *L) { in db_traceback() argument
361 lua_State *L1 = getthread(L, &arg); in db_traceback()
362 const char *msg = lua_tostring(L, arg + 1); in db_traceback()
363 if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ in db_traceback()
364 lua_pushvalue(L, arg + 1); /* return it untouched */ in db_traceback()
366 int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0); in db_traceback()
367 luaL_traceback(L, L1, msg, level); in db_traceback()
394 LUAMOD_API int luaopen_debug (lua_State *L) { in luaopen_debug() argument
395 luaL_newlib(L, dblib); in luaopen_debug()