The Battle for Wesnoth  1.17.0-dev
ldblib.cpp
Go to the documentation of this file.
1 /*
2 ** $Id: ldblib.c $
3 ** Interface from Lua to its debug API
4 ** See Copyright Notice in lua.h
5 */
6 
7 #define ldblib_c
8 #define LUA_LIB
9 
10 #include "lprefix.h"
11 
12 
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 
17 #include "lua.h"
18 
19 #include "lauxlib.h"
20 #include "lualib.h"
21 
22 
23 /*
24 ** The hook table at registry[HOOKKEY] maps threads to their current
25 ** hook function.
26 */
27 static const char *const HOOKKEY = "_HOOKKEY";
28 
29 
30 /*
31 ** If L1 != L, L1 can be in any state, and therefore there are no
32 ** guarantees about its stack space; any push in L1 must be
33 ** checked.
34 */
35 static void checkstack (lua_State *L, lua_State *L1, int n) {
36  if (L != L1 && !lua_checkstack(L1, n))
37  luaL_error(L, "stack overflow");
38 }
39 
40 
41 static int db_getregistry (lua_State *L) {
43  return 1;
44 }
45 
46 
47 static int db_getmetatable (lua_State *L) {
48  luaL_checkany(L, 1);
49  if (!lua_getmetatable(L, 1)) {
50  lua_pushnil(L); /* no metatable */
51  }
52  return 1;
53 }
54 
55 
56 static int db_setmetatable (lua_State *L) {
57  int t = lua_type(L, 2);
58  luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table");
59  lua_settop(L, 2);
60  lua_setmetatable(L, 1);
61  return 1; /* return 1st argument */
62 }
63 
64 
65 static int db_getuservalue (lua_State *L) {
66  int n = (int)luaL_optinteger(L, 2, 1);
67  if (lua_type(L, 1) != LUA_TUSERDATA)
68  luaL_pushfail(L);
69  else if (lua_getiuservalue(L, 1, n) != LUA_TNONE) {
70  lua_pushboolean(L, 1);
71  return 2;
72  }
73  return 1;
74 }
75 
76 
77 static int db_setuservalue (lua_State *L) {
78  int n = (int)luaL_optinteger(L, 3, 1);
80  luaL_checkany(L, 2);
81  lua_settop(L, 2);
82  if (!lua_setiuservalue(L, 1, n))
83  luaL_pushfail(L);
84  return 1;
85 }
86 
87 
88 /*
89 ** Auxiliary function used by several library functions: check for
90 ** an optional thread as function's first argument and set 'arg' with
91 ** 1 if this argument is present (so that functions can skip it to
92 ** access their other arguments)
93 */
94 static lua_State *getthread (lua_State *L, int *arg) {
95  if (lua_isthread(L, 1)) {
96  *arg = 1;
97  return lua_tothread(L, 1);
98  }
99  else {
100  *arg = 0;
101  return L; /* function will operate over current thread */
102  }
103 }
104 
105 
106 /*
107 ** Variations of 'lua_settable', used by 'db_getinfo' to put results
108 ** from 'lua_getinfo' into result table. Key is always a string;
109 ** value can be a string, an int, or a boolean.
110 */
111 static void settabss (lua_State *L, const char *k, const char *v) {
112  lua_pushstring(L, v);
113  lua_setfield(L, -2, k);
114 }
115 
116 static void settabsi (lua_State *L, const char *k, int v) {
117  lua_pushinteger(L, v);
118  lua_setfield(L, -2, k);
119 }
120 
121 static void settabsb (lua_State *L, const char *k, int v) {
122  lua_pushboolean(L, v);
123  lua_setfield(L, -2, k);
124 }
125 
126 
127 /*
128 ** In function 'db_getinfo', the call to 'lua_getinfo' may push
129 ** results on the stack; later it creates the result table to put
130 ** these objects. Function 'treatstackoption' puts the result from
131 ** 'lua_getinfo' on top of the result table so that it can call
132 ** 'lua_setfield'.
133 */
134 static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
135  if (L == L1)
136  lua_rotate(L, -2, 1); /* exchange object and table */
137  else
138  lua_xmove(L1, L, 1); /* move object to the "main" stack */
139  lua_setfield(L, -2, fname); /* put object into table */
140 }
141 
142 
143 /*
144 ** Calls 'lua_getinfo' and collects all results in a new table.
145 ** L1 needs stack space for an optional input (function) plus
146 ** two optional outputs (function and line table) from function
147 ** 'lua_getinfo'.
148 */
149 static int db_getinfo (lua_State *L) {
150  lua_Debug ar;
151  int arg;
152  lua_State *L1 = getthread(L, &arg);
153  const char *options = luaL_optstring(L, arg+2, "flnSrtu");
154  checkstack(L, L1, 3);
155  if (lua_isfunction(L, arg + 1)) { /* info about a function? */
156  options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */
157  lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */
158  lua_xmove(L, L1, 1);
159  }
160  else { /* stack level */
161  if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) {
162  luaL_pushfail(L); /* level out of range */
163  return 1;
164  }
165  }
166  if (!lua_getinfo(L1, options, &ar))
167  return luaL_argerror(L, arg+2, "invalid option");
168  lua_newtable(L); /* table to collect results */
169  if (strchr(options, 'S')) {
170  lua_pushlstring(L, ar.source, ar.srclen);
171  lua_setfield(L, -2, "source");
172  settabss(L, "short_src", ar.short_src);
173  settabsi(L, "linedefined", ar.linedefined);
174  settabsi(L, "lastlinedefined", ar.lastlinedefined);
175  settabss(L, "what", ar.what);
176  }
177  if (strchr(options, 'l'))
178  settabsi(L, "currentline", ar.currentline);
179  if (strchr(options, 'u')) {
180  settabsi(L, "nups", ar.nups);
181  settabsi(L, "nparams", ar.nparams);
182  settabsb(L, "isvararg", ar.isvararg);
183  }
184  if (strchr(options, 'n')) {
185  settabss(L, "name", ar.name);
186  settabss(L, "namewhat", ar.namewhat);
187  }
188  if (strchr(options, 'r')) {
189  settabsi(L, "ftransfer", ar.ftransfer);
190  settabsi(L, "ntransfer", ar.ntransfer);
191  }
192  if (strchr(options, 't'))
193  settabsb(L, "istailcall", ar.istailcall);
194  if (strchr(options, 'L'))
195  treatstackoption(L, L1, "activelines");
196  if (strchr(options, 'f'))
197  treatstackoption(L, L1, "func");
198  return 1; /* return table */
199 }
200 
201 
202 static int db_getlocal (lua_State *L) {
203  int arg;
204  lua_State *L1 = getthread(L, &arg);
205  int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */
206  if (lua_isfunction(L, arg + 1)) { /* function argument? */
207  lua_pushvalue(L, arg + 1); /* push function */
208  lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
209  return 1; /* return only name (there is no value) */
210  }
211  else { /* stack-level argument */
212  lua_Debug ar;
213  const char *name;
214  int level = (int)luaL_checkinteger(L, arg + 1);
215  if (!lua_getstack(L1, level, &ar)) /* out of range? */
216  return luaL_argerror(L, arg+1, "level out of range");
217  checkstack(L, L1, 1);
218  name = lua_getlocal(L1, &ar, nvar);
219  if (name) {
220  lua_xmove(L1, L, 1); /* move local value */
221  lua_pushstring(L, name); /* push name */
222  lua_rotate(L, -2, 1); /* re-order */
223  return 2;
224  }
225  else {
226  luaL_pushfail(L); /* no name (nor value) */
227  return 1;
228  }
229  }
230 }
231 
232 
233 static int db_setlocal (lua_State *L) {
234  int arg;
235  const char *name;
236  lua_State *L1 = getthread(L, &arg);
237  lua_Debug ar;
238  int level = (int)luaL_checkinteger(L, arg + 1);
239  int nvar = (int)luaL_checkinteger(L, arg + 2);
240  if (!lua_getstack(L1, level, &ar)) /* out of range? */
241  return luaL_argerror(L, arg+1, "level out of range");
242  luaL_checkany(L, arg+3);
243  lua_settop(L, arg+3);
244  checkstack(L, L1, 1);
245  lua_xmove(L, L1, 1);
246  name = lua_setlocal(L1, &ar, nvar);
247  if (name == NULL)
248  lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */
249  lua_pushstring(L, name);
250  return 1;
251 }
252 
253 
254 /*
255 ** get (if 'get' is true) or set an upvalue from a closure
256 */
257 static int auxupvalue (lua_State *L, int get) {
258  const char *name;
259  int n = (int)luaL_checkinteger(L, 2); /* upvalue index */
260  luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */
261  name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
262  if (name == NULL) return 0;
263  lua_pushstring(L, name);
264  lua_insert(L, -(get+1)); /* no-op if get is false */
265  return get + 1;
266 }
267 
268 
269 static int db_getupvalue (lua_State *L) {
270  return auxupvalue(L, 1);
271 }
272 
273 
274 static int db_setupvalue (lua_State *L) {
275  luaL_checkany(L, 3);
276  return auxupvalue(L, 0);
277 }
278 
279 
280 /*
281 ** Check whether a given upvalue from a given closure exists and
282 ** returns its index
283 */
284 static void *checkupval (lua_State *L, int argf, int argnup, int *pnup) {
285  void *id;
286  int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */
287  luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */
288  id = lua_upvalueid(L, argf, nup);
289  if (pnup) {
290  luaL_argcheck(L, id != NULL, argnup, "invalid upvalue index");
291  *pnup = nup;
292  }
293  return id;
294 }
295 
296 
297 static int db_upvalueid (lua_State *L) {
298  void *id = checkupval(L, 1, 2, NULL);
299  if (id != NULL)
300  lua_pushlightuserdata(L, id);
301  else
302  luaL_pushfail(L);
303  return 1;
304 }
305 
306 
307 static int db_upvaluejoin (lua_State *L) {
308  int n1, n2;
309  checkupval(L, 1, 2, &n1);
310  checkupval(L, 3, 4, &n2);
311  luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected");
312  luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected");
313  lua_upvaluejoin(L, 1, n1, 3, n2);
314  return 0;
315 }
316 
317 
318 /*
319 ** Call hook function registered at hook table for the current
320 ** thread (if there is one)
321 */
322 static void hookf (lua_State *L, lua_Debug *ar) {
323  static const char *const hooknames[] =
324  {"call", "return", "line", "count", "tail call"};
326  lua_pushthread(L);
327  if (lua_rawget(L, -2) == LUA_TFUNCTION) { /* is there a hook function? */
328  lua_pushstring(L, hooknames[(int)ar->event]); /* push event name */
329  if (ar->currentline >= 0)
330  lua_pushinteger(L, ar->currentline); /* push current line */
331  else lua_pushnil(L);
332  lua_assert(lua_getinfo(L, "lS", ar));
333  lua_call(L, 2, 0); /* call hook function */
334  }
335 }
336 
337 
338 /*
339 ** Convert a string mask (for 'sethook') into a bit mask
340 */
341 static int makemask (const char *smask, int count) {
342  int mask = 0;
343  if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
344  if (strchr(smask, 'r')) mask |= LUA_MASKRET;
345  if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
346  if (count > 0) mask |= LUA_MASKCOUNT;
347  return mask;
348 }
349 
350 
351 /*
352 ** Convert a bit mask (for 'gethook') into a string mask
353 */
354 static char *unmakemask (int mask, char *smask) {
355  int i = 0;
356  if (mask & LUA_MASKCALL) smask[i++] = 'c';
357  if (mask & LUA_MASKRET) smask[i++] = 'r';
358  if (mask & LUA_MASKLINE) smask[i++] = 'l';
359  smask[i] = '\0';
360  return smask;
361 }
362 
363 
364 static int db_sethook (lua_State *L) {
365  int arg, mask, count;
366  lua_Hook func;
367  lua_State *L1 = getthread(L, &arg);
368  if (lua_isnoneornil(L, arg+1)) { /* no hook? */
369  lua_settop(L, arg+1);
370  func = NULL; mask = 0; count = 0; /* turn off hooks */
371  }
372  else {
373  const char *smask = luaL_checkstring(L, arg+2);
374  luaL_checktype(L, arg+1, LUA_TFUNCTION);
375  count = (int)luaL_optinteger(L, arg + 3, 0);
376  func = hookf; mask = makemask(smask, count);
377  }
379  /* table just created; initialize it */
380  lua_pushstring(L, "k");
381  lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */
382  lua_pushvalue(L, -1);
383  lua_setmetatable(L, -2); /* metatable(hooktable) = hooktable */
384  }
385  checkstack(L, L1, 1);
386  lua_pushthread(L1); lua_xmove(L1, L, 1); /* key (thread) */
387  lua_pushvalue(L, arg + 1); /* value (hook function) */
388  lua_rawset(L, -3); /* hooktable[L1] = new Lua hook */
389  lua_sethook(L1, func, mask, count);
390  return 0;
391 }
392 
393 
394 static int db_gethook (lua_State *L) {
395  int arg;
396  lua_State *L1 = getthread(L, &arg);
397  char buff[5];
398  int mask = lua_gethookmask(L1);
399  lua_Hook hook = lua_gethook(L1);
400  if (hook == NULL) { /* no hook? */
401  luaL_pushfail(L);
402  return 1;
403  }
404  else if (hook != hookf) /* external hook? */
405  lua_pushliteral(L, "external hook");
406  else { /* hook table must exist */
408  checkstack(L, L1, 1);
409  lua_pushthread(L1); lua_xmove(L1, L, 1);
410  lua_rawget(L, -2); /* 1st result = hooktable[L1] */
411  lua_remove(L, -2); /* remove hook table */
412  }
413  lua_pushstring(L, unmakemask(mask, buff)); /* 2nd result = mask */
414  lua_pushinteger(L, lua_gethookcount(L1)); /* 3rd result = count */
415  return 3;
416 }
417 
418 
419 static int db_debug (lua_State *L) {
420  for (;;) {
421  char buffer[250];
422  lua_writestringerror("%s", "lua_debug> ");
423  if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
424  strcmp(buffer, "cont\n") == 0)
425  return 0;
426  if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
427  lua_pcall(L, 0, 0, 0))
428  lua_writestringerror("%s\n", luaL_tolstring(L, -1, NULL));
429  lua_settop(L, 0); /* remove eventual returns */
430  }
431 }
432 
433 
434 static int db_traceback (lua_State *L) {
435  int arg;
436  lua_State *L1 = getthread(L, &arg);
437  const char *msg = lua_tostring(L, arg + 1);
438  if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
439  lua_pushvalue(L, arg + 1); /* return it untouched */
440  else {
441  int level = (int)luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0);
442  luaL_traceback(L, L1, msg, level);
443  }
444  return 1;
445 }
446 
447 
448 static int db_setcstacklimit (lua_State *L) {
449  int limit = (int)luaL_checkinteger(L, 1);
450  int res = lua_setcstacklimit(L, limit);
451  lua_pushinteger(L, res);
452  return 1;
453 }
454 
455 
456 static const luaL_Reg dblib[] = {
457  {"debug", db_debug},
458  {"getuservalue", db_getuservalue},
459  {"gethook", db_gethook},
460  {"getinfo", db_getinfo},
461  {"getlocal", db_getlocal},
462  {"getregistry", db_getregistry},
463  {"getmetatable", db_getmetatable},
464  {"getupvalue", db_getupvalue},
465  {"upvaluejoin", db_upvaluejoin},
466  {"upvalueid", db_upvalueid},
467  {"setuservalue", db_setuservalue},
468  {"sethook", db_sethook},
469  {"setlocal", db_setlocal},
470  {"setmetatable", db_setmetatable},
471  {"setupvalue", db_setupvalue},
472  {"traceback", db_traceback},
473  {"setcstacklimit", db_setcstacklimit},
474  {NULL, NULL}
475 };
476 
477 
479  luaL_newlib(L, dblib);
480  return 1;
481 }
482 
const char * what
Definition: lua.h:473
unsigned char nparams
Definition: lua.h:480
#define lua_isnoneornil(L, n)
Definition: lua.h:379
Definition: lua.h:469
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
Definition: lapi.cpp:592
LUALIB_API const char * luaL_tolstring(lua_State *L, int idx, size_t *len)
Definition: lauxlib.cpp:861
static int db_setmetatable(lua_State *L)
Definition: ldblib.cpp:56
LUAMOD_API int luaopen_debug(lua_State *L)
Definition: ldblib.cpp:478
LUA_API void lua_settop(lua_State *L, int idx)
Definition: lapi.cpp:173
static int db_setuservalue(lua_State *L)
Definition: ldblib.cpp:77
static void * checkupval(lua_State *L, int argf, int argnup, int *pnup)
Definition: ldblib.cpp:284
LUA_API int lua_type(lua_State *L, int idx)
Definition: lapi.cpp:260
static int makemask(const char *smask, int count)
Definition: ldblib.cpp:341
static void hookf(lua_State *L, lua_Debug *ar)
Definition: ldblib.cpp:322
#define luaL_pushfail(L)
Definition: lauxlib.h:157
#define LUA_TUSERDATA
Definition: lua.h:72
LUA_API void lua_pushboolean(lua_State *L, int b)
Definition: lapi.cpp:581
LUA_API lua_Hook lua_gethook(lua_State *L)
Definition: ldebug.cpp:149
static void settabsb(lua_State *L, const char *k, int v)
Definition: ldblib.cpp:121
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
Definition: lauxlib.cpp:925
unsigned char nups
Definition: lua.h:479
#define LUA_MASKRET
Definition: lua.h:440
static char * unmakemask(int mask, char *smask)
Definition: ldblib.cpp:354
#define LUA_MASKCOUNT
Definition: lua.h:442
const char * name
Definition: lua.h:471
#define LUA_MASKCALL
Definition: lua.h:439
#define luaL_argexpected(L, cond, arg, tname)
Definition: lauxlib.h:135
#define lua_remove(L, idx)
Definition: lua.h:391
const char * source
Definition: lua.h:474
LUA_API int lua_gethookmask(lua_State *L)
Definition: ldebug.cpp:154
int event
Definition: lua.h:470
LUA_API int lua_rawget(lua_State *L, int idx)
Definition: lapi.cpp:698
static int db_setupvalue(lua_State *L)
Definition: ldblib.cpp:274
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
Definition: lauxlib.cpp:452
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:110
char short_src[LUA_IDSIZE]
Definition: lua.h:485
LUA_API int lua_checkstack(lua_State *L, int n)
Definition: lapi.cpp:98
#define LUA_TFUNCTION
Definition: lua.h:71
const char * namewhat
Definition: lua.h:472
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
Definition: ldebug.cpp:164
size_t srclen
Definition: lua.h:475
#define lua_pop(L, n)
Definition: lua.h:364
#define luaL_loadbuffer(L, s, sz, n)
Definition: lauxlib.h:153
int lastlinedefined
Definition: lua.h:478
#define lua_isthread(L, n)
Definition: lua.h:377
#define lua_pcall(L, n, r, f)
Definition: lua.h:287
const config & options()
Definition: game.cpp:569
LUALIB_API int luaL_argerror(lua_State *L, int arg, const char *extramsg)
Definition: lauxlib.cpp:175
static int db_getinfo(lua_State *L)
Definition: ldblib.cpp:149
#define LUA_TNONE
Definition: lua.h:63
static int db_traceback(lua_State *L)
Definition: ldblib.cpp:434
char istailcall
Definition: lua.h:482
#define LUA_TNIL
Definition: lua.h:65
unsigned short ntransfer
Definition: lua.h:484
static void checkstack(lua_State *L, lua_State *L1, int n)
Definition: ldblib.cpp:35
LUA_API void lua_upvaluejoin(lua_State *L, int fidx1, int n1, int fidx2, int n2)
Definition: lapi.cpp:1421
static const char *const HOOKKEY
Definition: ldblib.cpp:27
LUA_API lua_State * lua_tothread(lua_State *L, int idx)
Definition: lapi.cpp:438
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
Definition: lapi.cpp:502
LUA_API int lua_getmetatable(lua_State *L, int objindex)
Definition: lapi.cpp:741
LUA_API void * lua_upvalueid(lua_State *L, int fidx, int n)
Definition: lapi.cpp:1399
LUA_API const char * lua_setlocal(lua_State *L, const lua_Debug *ar, int n)
Definition: ldebug.cpp:246
LUA_API int lua_setmetatable(lua_State *L, int objindex)
Definition: lapi.cpp:901
static int db_gethook(lua_State *L)
Definition: ldblib.cpp:394
char isvararg
Definition: lua.h:481
LUA_API int lua_setiuservalue(lua_State *L, int idx, int n)
Definition: lapi.cpp:941
static int auxupvalue(lua_State *L, int get)
Definition: ldblib.cpp:257
LUALIB_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level)
Definition: lauxlib.cpp:131
static void settabsi(lua_State *L, const char *k, int v)
Definition: ldblib.cpp:116
#define lua_newtable(L)
Definition: lua.h:366
LUA_API void lua_pushnil(lua_State *L)
Definition: lapi.cpp:473
LUA_API const char * lua_setupvalue(lua_State *L, int funcindex, int n)
Definition: lapi.cpp:1366
#define lua_pushliteral(L, s)
Definition: lua.h:381
LUA_API int lua_pushthread(lua_State *L)
Definition: lapi.cpp:600
LUALIB_API void luaL_checktype(lua_State *L, int arg, int t)
Definition: lauxlib.cpp:390
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:215
#define lua_assert(c)
Definition: llimits.h:101
std::size_t i
Definition: function.cpp:967
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
Definition: lapi.cpp:120
static int db_debug(lua_State *L)
Definition: ldblib.cpp:419
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
Definition: lauxlib.cpp:442
LUA_API void lua_rawset(lua_State *L, int idx)
Definition: lapi.cpp:877
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
Definition: ldebug.cpp:386
static int db_upvaluejoin(lua_State *L)
Definition: ldblib.cpp:307
#define lua_isfunction(L, n)
Definition: lua.h:372
static int db_getuservalue(lua_State *L)
Definition: ldblib.cpp:65
#define LUAMOD_API
Definition: luaconf.h:286
static int db_getregistry(lua_State *L)
Definition: ldblib.cpp:41
static int db_upvalueid(lua_State *L)
Definition: ldblib.cpp:297
#define lua_tostring(L, i)
Definition: lua.h:386
static int db_sethook(lua_State *L)
Definition: ldblib.cpp:364
LUA_API int lua_iscfunction(lua_State *L, int idx)
Definition: lapi.cpp:273
LUA_API void lua_rotate(lua_State *L, int idx, int n)
Definition: lapi.cpp:217
LUA_API void lua_pushvalue(lua_State *L, int idx)
Definition: lapi.cpp:246
static int db_getmetatable(lua_State *L)
Definition: ldblib.cpp:47
#define luaL_newlib(L, l)
Definition: lauxlib.h:129
#define lua_call(L, n, r)
Definition: lua.h:283
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
Definition: lauxlib.cpp:234
static void treatstackoption(lua_State *L, lua_State *L1, const char *fname)
Definition: ldblib.cpp:134
LUA_API const char * lua_getlocal(lua_State *L, const lua_Debug *ar, int n)
Definition: ldebug.cpp:224
#define luaL_argcheck(L, cond, arg, extramsg)
Definition: lauxlib.h:132
LUALIB_API void luaL_checkany(lua_State *L, int arg)
Definition: lauxlib.cpp:396
static lua_State * getthread(lua_State *L, int *arg)
Definition: ldblib.cpp:94
static int db_setcstacklimit(lua_State *L)
Definition: ldblib.cpp:448
LUA_API const char * lua_getupvalue(lua_State *L, int funcindex, int n)
Definition: lapi.cpp:1352
LUA_API int lua_getiuservalue(lua_State *L, int idx, int n)
Definition: lapi.cpp:768
#define LUA_REGISTRYINDEX
Definition: lua.h:44
double t
Definition: astarsearch.cpp:65
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
Definition: lua.h:448
static int db_setlocal(lua_State *L)
Definition: ldblib.cpp:233
#define lua_writestringerror(s, p)
Definition: lauxlib.h:245
#define lua_insert(L, idx)
Definition: lua.h:389
LUA_API int lua_gethookcount(lua_State *L)
Definition: ldebug.cpp:159
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
Definition: lapi.cpp:542
static int db_getlocal(lua_State *L)
Definition: ldblib.cpp:202
int currentline
Definition: lua.h:476
LUA_API int lua_setcstacklimit(lua_State *L, unsigned int limit)
Definition: lstate.cpp:99
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
Definition: lapi.cpp:655
#define LUA_TTABLE
Definition: lua.h:70
unsigned short ftransfer
Definition: lua.h:483
static map_location::DIRECTION n
static const luaL_Reg dblib[]
Definition: ldblib.cpp:456
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
Definition: lapi.cpp:489
#define luaL_optstring(L, n, d)
Definition: lauxlib.h:139
static void settabss(lua_State *L, const char *k, const char *v)
Definition: ldblib.cpp:111
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
Definition: lapi.cpp:514
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
Definition: lapi.cpp:837
#define LUA_MASKLINE
Definition: lua.h:441
static int db_getupvalue(lua_State *L)
Definition: ldblib.cpp:269
int linedefined
Definition: lua.h:477
LUA_API void lua_sethook(lua_State *L, lua_Hook func, int mask, int count)
Definition: ldebug.cpp:135
#define luaL_checkstring(L, n)
Definition: lauxlib.h:138