The Battle for Wesnoth  1.15.1+dev
ldblib.cpp
Go to the documentation of this file.
1 /*
2 ** $Id: ldblib.c,v 1.151.1.1 2017/04/19 17:20:42 roberto Exp $
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. (We only need the unique address of 'HOOKKEY'.)
26 */
27 static const int HOOKKEY = 0;
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_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
59  "nil or table expected");
60  lua_settop(L, 2);
61  lua_setmetatable(L, 1);
62  return 1; /* return 1st argument */
63 }
64 
65 
66 static int db_getuservalue (lua_State *L) {
67  if (lua_type(L, 1) != LUA_TUSERDATA)
68  lua_pushnil(L);
69  else
70  lua_getuservalue(L, 1);
71  return 1;
72 }
73 
74 
75 static int db_setuservalue (lua_State *L) {
77  luaL_checkany(L, 2);
78  lua_settop(L, 2);
79  lua_setuservalue(L, 1);
80  return 1;
81 }
82 
83 
84 /*
85 ** Auxiliary function used by several library functions: check for
86 ** an optional thread as function's first argument and set 'arg' with
87 ** 1 if this argument is present (so that functions can skip it to
88 ** access their other arguments)
89 */
90 static lua_State *getthread (lua_State *L, int *arg) {
91  if (lua_isthread(L, 1)) {
92  *arg = 1;
93  return lua_tothread(L, 1);
94  }
95  else {
96  *arg = 0;
97  return L; /* function will operate over current thread */
98  }
99 }
100 
101 
102 /*
103 ** Variations of 'lua_settable', used by 'db_getinfo' to put results
104 ** from 'lua_getinfo' into result table. Key is always a string;
105 ** value can be a string, an int, or a boolean.
106 */
107 static void settabss (lua_State *L, const char *k, const char *v) {
108  lua_pushstring(L, v);
109  lua_setfield(L, -2, k);
110 }
111 
112 static void settabsi (lua_State *L, const char *k, int v) {
113  lua_pushinteger(L, v);
114  lua_setfield(L, -2, k);
115 }
116 
117 static void settabsb (lua_State *L, const char *k, int v) {
118  lua_pushboolean(L, v);
119  lua_setfield(L, -2, k);
120 }
121 
122 
123 /*
124 ** In function 'db_getinfo', the call to 'lua_getinfo' may push
125 ** results on the stack; later it creates the result table to put
126 ** these objects. Function 'treatstackoption' puts the result from
127 ** 'lua_getinfo' on top of the result table so that it can call
128 ** 'lua_setfield'.
129 */
130 static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) {
131  if (L == L1)
132  lua_rotate(L, -2, 1); /* exchange object and table */
133  else
134  lua_xmove(L1, L, 1); /* move object to the "main" stack */
135  lua_setfield(L, -2, fname); /* put object into table */
136 }
137 
138 
139 /*
140 ** Calls 'lua_getinfo' and collects all results in a new table.
141 ** L1 needs stack space for an optional input (function) plus
142 ** two optional outputs (function and line table) from function
143 ** 'lua_getinfo'.
144 */
145 static int db_getinfo (lua_State *L) {
146  lua_Debug ar;
147  int arg;
148  lua_State *L1 = getthread(L, &arg);
149  const char *options = luaL_optstring(L, arg+2, "flnStu");
150  checkstack(L, L1, 3);
151  if (lua_isfunction(L, arg + 1)) { /* info about a function? */
152  options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */
153  lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */
154  lua_xmove(L, L1, 1);
155  }
156  else { /* stack level */
157  if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) {
158  lua_pushnil(L); /* level out of range */
159  return 1;
160  }
161  }
162  if (!lua_getinfo(L1, options, &ar))
163  return luaL_argerror(L, arg+2, "invalid option");
164  lua_newtable(L); /* table to collect results */
165  if (strchr(options, 'S')) {
166  settabss(L, "source", ar.source);
167  settabss(L, "short_src", ar.short_src);
168  settabsi(L, "linedefined", ar.linedefined);
169  settabsi(L, "lastlinedefined", ar.lastlinedefined);
170  settabss(L, "what", ar.what);
171  }
172  if (strchr(options, 'l'))
173  settabsi(L, "currentline", ar.currentline);
174  if (strchr(options, 'u')) {
175  settabsi(L, "nups", ar.nups);
176  settabsi(L, "nparams", ar.nparams);
177  settabsb(L, "isvararg", ar.isvararg);
178  }
179  if (strchr(options, 'n')) {
180  settabss(L, "name", ar.name);
181  settabss(L, "namewhat", ar.namewhat);
182  }
183  if (strchr(options, 't'))
184  settabsb(L, "istailcall", ar.istailcall);
185  if (strchr(options, 'L'))
186  treatstackoption(L, L1, "activelines");
187  if (strchr(options, 'f'))
188  treatstackoption(L, L1, "func");
189  return 1; /* return table */
190 }
191 
192 
193 static int db_getlocal (lua_State *L) {
194  int arg;
195  lua_State *L1 = getthread(L, &arg);
196  lua_Debug ar;
197  const char *name;
198  int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */
199  if (lua_isfunction(L, arg + 1)) { /* function argument? */
200  lua_pushvalue(L, arg + 1); /* push function */
201  lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
202  return 1; /* return only name (there is no value) */
203  }
204  else { /* stack-level argument */
205  int level = (int)luaL_checkinteger(L, arg + 1);
206  if (!lua_getstack(L1, level, &ar)) /* out of range? */
207  return luaL_argerror(L, arg+1, "level out of range");
208  checkstack(L, L1, 1);
209  name = lua_getlocal(L1, &ar, nvar);
210  if (name) {
211  lua_xmove(L1, L, 1); /* move local value */
212  lua_pushstring(L, name); /* push name */
213  lua_rotate(L, -2, 1); /* re-order */
214  return 2;
215  }
216  else {
217  lua_pushnil(L); /* no name (nor value) */
218  return 1;
219  }
220  }
221 }
222 
223 
224 static int db_setlocal (lua_State *L) {
225  int arg;
226  const char *name;
227  lua_State *L1 = getthread(L, &arg);
228  lua_Debug ar;
229  int level = (int)luaL_checkinteger(L, arg + 1);
230  int nvar = (int)luaL_checkinteger(L, arg + 2);
231  if (!lua_getstack(L1, level, &ar)) /* out of range? */
232  return luaL_argerror(L, arg+1, "level out of range");
233  luaL_checkany(L, arg+3);
234  lua_settop(L, arg+3);
235  checkstack(L, L1, 1);
236  lua_xmove(L, L1, 1);
237  name = lua_setlocal(L1, &ar, nvar);
238  if (name == NULL)
239  lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */
240  lua_pushstring(L, name);
241  return 1;
242 }
243 
244 
245 /*
246 ** get (if 'get' is true) or set an upvalue from a closure
247 */
248 static int auxupvalue (lua_State *L, int get) {
249  const char *name;
250  int n = (int)luaL_checkinteger(L, 2); /* upvalue index */
251  luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */
252  name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
253  if (name == NULL) return 0;
254  lua_pushstring(L, name);
255  lua_insert(L, -(get+1)); /* no-op if get is false */
256  return get + 1;
257 }
258 
259 
260 static int db_getupvalue (lua_State *L) {
261  return auxupvalue(L, 1);
262 }
263 
264 
265 static int db_setupvalue (lua_State *L) {
266  luaL_checkany(L, 3);
267  return auxupvalue(L, 0);
268 }
269 
270 
271 /*
272 ** Check whether a given upvalue from a given closure exists and
273 ** returns its index
274 */
275 static int checkupval (lua_State *L, int argf, int argnup) {
276  int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */
277  luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */
278  luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup,
279  "invalid upvalue index");
280  return nup;
281 }
282 
283 
284 static int db_upvalueid (lua_State *L) {
285  int n = checkupval(L, 1, 2);
287  return 1;
288 }
289 
290 
291 static int db_upvaluejoin (lua_State *L) {
292  int n1 = checkupval(L, 1, 2);
293  int n2 = checkupval(L, 3, 4);
294  luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected");
295  luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected");
296  lua_upvaluejoin(L, 1, n1, 3, n2);
297  return 0;
298 }
299 
300 
301 /*
302 ** Call hook function registered at hook table for the current
303 ** thread (if there is one)
304 */
305 static void hookf (lua_State *L, lua_Debug *ar) {
306  static const char *const hooknames[] =
307  {"call", "return", "line", "count", "tail call"};
309  lua_pushthread(L);
310  if (lua_rawget(L, -2) == LUA_TFUNCTION) { /* is there a hook function? */
311  lua_pushstring(L, hooknames[(int)ar->event]); /* push event name */
312  if (ar->currentline >= 0)
313  lua_pushinteger(L, ar->currentline); /* push current line */
314  else lua_pushnil(L);
315  lua_assert(lua_getinfo(L, "lS", ar));
316  lua_call(L, 2, 0); /* call hook function */
317  }
318 }
319 
320 
321 /*
322 ** Convert a string mask (for 'sethook') into a bit mask
323 */
324 static int makemask (const char *smask, int count) {
325  int mask = 0;
326  if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
327  if (strchr(smask, 'r')) mask |= LUA_MASKRET;
328  if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
329  if (count > 0) mask |= LUA_MASKCOUNT;
330  return mask;
331 }
332 
333 
334 /*
335 ** Convert a bit mask (for 'gethook') into a string mask
336 */
337 static char *unmakemask (int mask, char *smask) {
338  int i = 0;
339  if (mask & LUA_MASKCALL) smask[i++] = 'c';
340  if (mask & LUA_MASKRET) smask[i++] = 'r';
341  if (mask & LUA_MASKLINE) smask[i++] = 'l';
342  smask[i] = '\0';
343  return smask;
344 }
345 
346 
347 static int db_sethook (lua_State *L) {
348  int arg, mask, count;
349  lua_Hook func;
350  lua_State *L1 = getthread(L, &arg);
351  if (lua_isnoneornil(L, arg+1)) { /* no hook? */
352  lua_settop(L, arg+1);
353  func = NULL; mask = 0; count = 0; /* turn off hooks */
354  }
355  else {
356  const char *smask = luaL_checkstring(L, arg+2);
357  luaL_checktype(L, arg+1, LUA_TFUNCTION);
358  count = (int)luaL_optinteger(L, arg + 3, 0);
359  func = hookf; mask = makemask(smask, count);
360  }
362  lua_createtable(L, 0, 2); /* create a hook table */
363  lua_pushvalue(L, -1);
364  lua_rawsetp(L, LUA_REGISTRYINDEX, &HOOKKEY); /* set it in position */
365  lua_pushstring(L, "k");
366  lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */
367  lua_pushvalue(L, -1);
368  lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */
369  }
370  checkstack(L, L1, 1);
371  lua_pushthread(L1); lua_xmove(L1, L, 1); /* key (thread) */
372  lua_pushvalue(L, arg + 1); /* value (hook function) */
373  lua_rawset(L, -3); /* hooktable[L1] = new Lua hook */
374  lua_sethook(L1, func, mask, count);
375  return 0;
376 }
377 
378 
379 static int db_gethook (lua_State *L) {
380  int arg;
381  lua_State *L1 = getthread(L, &arg);
382  char buff[5];
383  int mask = lua_gethookmask(L1);
384  lua_Hook hook = lua_gethook(L1);
385  if (hook == NULL) /* no hook? */
386  lua_pushnil(L);
387  else if (hook != hookf) /* external hook? */
388  lua_pushliteral(L, "external hook");
389  else { /* hook table must exist */
391  checkstack(L, L1, 1);
392  lua_pushthread(L1); lua_xmove(L1, L, 1);
393  lua_rawget(L, -2); /* 1st result = hooktable[L1] */
394  lua_remove(L, -2); /* remove hook table */
395  }
396  lua_pushstring(L, unmakemask(mask, buff)); /* 2nd result = mask */
397  lua_pushinteger(L, lua_gethookcount(L1)); /* 3rd result = count */
398  return 3;
399 }
400 
401 
402 static int db_debug (lua_State *L) {
403  for (;;) {
404  char buffer[250];
405  lua_writestringerror("%s", "lua_debug> ");
406  if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
407  strcmp(buffer, "cont\n") == 0)
408  return 0;
409  if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
410  lua_pcall(L, 0, 0, 0))
411  lua_writestringerror("%s\n", lua_tostring(L, -1));
412  lua_settop(L, 0); /* remove eventual returns */
413  }
414 }
415 
416 
417 static int db_traceback (lua_State *L) {
418  int arg;
419  lua_State *L1 = getthread(L, &arg);
420  const char *msg = lua_tostring(L, arg + 1);
421  if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
422  lua_pushvalue(L, arg + 1); /* return it untouched */
423  else {
424  int level = (int)luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0);
425  luaL_traceback(L, L1, msg, level);
426  }
427  return 1;
428 }
429 
430 
431 static const luaL_Reg dblib[] = {
432  {"debug", db_debug},
433  {"getuservalue", db_getuservalue},
434  {"gethook", db_gethook},
435  {"getinfo", db_getinfo},
436  {"getlocal", db_getlocal},
437  {"getregistry", db_getregistry},
438  {"getmetatable", db_getmetatable},
439  {"getupvalue", db_getupvalue},
440  {"upvaluejoin", db_upvaluejoin},
441  {"upvalueid", db_upvalueid},
442  {"setuservalue", db_setuservalue},
443  {"sethook", db_sethook},
444  {"setlocal", db_setlocal},
445  {"setmetatable", db_setmetatable},
446  {"setupvalue", db_setupvalue},
447  {"traceback", db_traceback},
448  {NULL, NULL}
449 };
450 
451 
453  luaL_newlib(L, dblib);
454  return 1;
455 }
456 
const char * what
Definition: lua.h:445
unsigned char nparams
Definition: lua.h:451
#define lua_isnoneornil(L, n)
Definition: lua.h:359
Definition: lua.h:441
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
Definition: lapi.cpp:565
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
Definition: lapi.cpp:684
static int db_setmetatable(lua_State *L)
Definition: ldblib.cpp:56
LUAMOD_API int luaopen_debug(lua_State *L)
Definition: ldblib.cpp:452
LUA_API void lua_settop(lua_State *L, int idx)
Definition: lapi.cpp:172
static int db_setuservalue(lua_State *L)
Definition: ldblib.cpp:75
LUA_API int lua_type(lua_State *L, int idx)
Definition: lapi.cpp:251
static int makemask(const char *smask, int count)
Definition: ldblib.cpp:324
static void hookf(lua_State *L, lua_Debug *ar)
Definition: ldblib.cpp:305
#define LUA_TUSERDATA
Definition: lua.h:71
LUA_API void lua_pushboolean(lua_State *L, int b)
Definition: lapi.cpp:557
LUA_API lua_Hook lua_gethook(lua_State *L)
Definition: ldebug.cpp:95
static void settabsb(lua_State *L, const char *k, int v)
Definition: ldblib.cpp:117
unsigned char nups
Definition: lua.h:450
#define LUA_MASKRET
Definition: lua.h:413
static char * unmakemask(int mask, char *smask)
Definition: ldblib.cpp:337
#define LUA_MASKCOUNT
Definition: lua.h:415
const char * name
Definition: lua.h:443
#define LUA_MASKCALL
Definition: lua.h:412
LUA_API void lua_setuservalue(lua_State *L, int idx)
Definition: lapi.cpp:886
#define lua_remove(L, idx)
Definition: lua.h:371
const char * source
Definition: lua.h:446
LUA_API int lua_gethookmask(lua_State *L)
Definition: ldebug.cpp:100
int event
Definition: lua.h:442
LUA_API int lua_rawget(lua_State *L, int idx)
Definition: lapi.cpp:647
static int db_setupvalue(lua_State *L)
Definition: ldblib.cpp:265
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
Definition: lauxlib.cpp:440
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
char short_src[LUA_IDSIZE]
Definition: lua.h:454
LUA_API int lua_checkstack(lua_State *L, int n)
Definition: lapi.cpp:97
#define LUA_TFUNCTION
Definition: lua.h:70
const char * namewhat
Definition: lua.h:444
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
Definition: ldebug.cpp:110
#define lua_pop(L, n)
Definition: lua.h:344
#define luaL_loadbuffer(L, s, sz, n)
Definition: lauxlib.h:139
int lastlinedefined
Definition: lua.h:449
#define lua_isthread(L, n)
Definition: lua.h:357
LUA_API int lua_getuservalue(lua_State *L, int idx)
Definition: lapi.cpp:724
#define lua_pcall(L, n, r, f)
Definition: lua.h:278
const config & options()
Definition: game.cpp:579
LUALIB_API int luaL_argerror(lua_State *L, int arg, const char *extramsg)
Definition: lauxlib.cpp:164
static int db_getinfo(lua_State *L)
Definition: ldblib.cpp:145
static int db_traceback(lua_State *L)
Definition: ldblib.cpp:417
char istailcall
Definition: lua.h:453
#define LUA_TNIL
Definition: lua.h:64
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:1287
LUA_API lua_State * lua_tothread(lua_State *L, int idx)
Definition: lapi.cpp:423
LUA_API int lua_getmetatable(lua_State *L, int objindex)
Definition: lapi.cpp:697
LUA_API int lua_rawgetp(lua_State *L, int idx, const void *p)
Definition: lapi.cpp:670
LUA_API void * lua_upvalueid(lua_State *L, int fidx, int n)
Definition: lapi.cpp:1268
LUA_API const char * lua_setlocal(lua_State *L, const lua_Debug *ar, int n)
Definition: ldebug.cpp:195
LUA_API int lua_setmetatable(lua_State *L, int objindex)
Definition: lapi.cpp:846
static int db_gethook(lua_State *L)
Definition: ldblib.cpp:379
static int checkupval(lua_State *L, int argf, int argnup)
Definition: ldblib.cpp:275
char isvararg
Definition: lua.h:452
static int auxupvalue(lua_State *L, int get)
Definition: ldblib.cpp:248
LUALIB_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level)
Definition: lauxlib.cpp:125
static void settabsi(lua_State *L, const char *k, int v)
Definition: ldblib.cpp:112
#define lua_newtable(L)
Definition: lua.h:346
LUA_API void lua_pushnil(lua_State *L)
Definition: lapi.cpp:450
LUA_API const char * lua_setupvalue(lua_State *L, int funcindex, int n)
Definition: lapi.cpp:1236
#define lua_pushliteral(L, s)
Definition: lua.h:361
LUA_API int lua_pushthread(lua_State *L)
Definition: lapi.cpp:573
LUALIB_API void luaL_checktype(lua_State *L, int arg, int t)
Definition: lauxlib.cpp:378
#define lua_assert(c)
Definition: llimits.h:89
std::size_t i
Definition: function.cpp:933
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
Definition: lapi.cpp:118
static int db_debug(lua_State *L)
Definition: ldblib.cpp:402
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
Definition: lauxlib.cpp:430
LUA_API void lua_rawset(lua_State *L, int idx)
Definition: lapi.cpp:801
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
Definition: ldebug.cpp:309
static int db_upvaluejoin(lua_State *L)
Definition: ldblib.cpp:291
#define lua_isfunction(L, n)
Definition: lua.h:352
static int db_getuservalue(lua_State *L)
Definition: ldblib.cpp:66
#define LUAMOD_API
Definition: luaconf.h:261
static int db_getregistry(lua_State *L)
Definition: ldblib.cpp:41
static int db_upvalueid(lua_State *L)
Definition: ldblib.cpp:284
#define lua_tostring(L, i)
Definition: lua.h:366
LUA_API void lua_rawsetp(lua_State *L, int idx, const void *p)
Definition: lapi.cpp:830
static int db_sethook(lua_State *L)
Definition: ldblib.cpp:347
LUA_API int lua_iscfunction(lua_State *L, int idx)
Definition: lapi.cpp:264
LUA_API void lua_rotate(lua_State *L, int idx, int n)
Definition: lapi.cpp:207
LUA_API void lua_pushvalue(lua_State *L, int idx)
Definition: lapi.cpp:237
static int db_getmetatable(lua_State *L)
Definition: ldblib.cpp:47
#define luaL_newlib(L, l)
Definition: lauxlib.h:119
#define lua_call(L, n, r)
Definition: lua.h:274
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
Definition: lauxlib.cpp:223
static void treatstackoption(lua_State *L, lua_State *L1, const char *fname)
Definition: ldblib.cpp:130
LUA_API const char * lua_getlocal(lua_State *L, const lua_Debug *ar, int n)
Definition: ldebug.cpp:171
#define luaL_argcheck(L, cond, arg, extramsg)
Definition: lauxlib.h:122
LUALIB_API void luaL_checkany(lua_State *L, int arg)
Definition: lauxlib.cpp:384
static lua_State * getthread(lua_State *L, int *arg)
Definition: ldblib.cpp:90
LUA_API const char * lua_getupvalue(lua_State *L, int funcindex, int n)
Definition: lapi.cpp:1222
#define LUA_REGISTRYINDEX
Definition: lua.h:42
double t
Definition: astarsearch.cpp:64
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
Definition: lua.h:421
static int db_setlocal(lua_State *L)
Definition: ldblib.cpp:224
#define lua_writestringerror(s, p)
Definition: lauxlib.h:233
#define lua_insert(L, idx)
Definition: lua.h:369
LUA_API int lua_gethookcount(lua_State *L)
Definition: ldebug.cpp:105
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
Definition: lapi.cpp:519
static int db_getlocal(lua_State *L)
Definition: ldblib.cpp:193
int currentline
Definition: lua.h:447
#define LUA_TTABLE
Definition: lua.h:69
static map_location::DIRECTION n
static const luaL_Reg dblib[]
Definition: ldblib.cpp:431
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
Definition: lapi.cpp:466
#define luaL_optstring(L, n, d)
Definition: lauxlib.h:125
static void settabss(lua_State *L, const char *k, const char *v)
Definition: ldblib.cpp:107
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
Definition: lapi.cpp:491
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
Definition: lapi.cpp:777
#define LUA_MASKLINE
Definition: lua.h:414
static int db_getupvalue(lua_State *L)
Definition: ldblib.cpp:260
static const int HOOKKEY
Definition: ldblib.cpp:27
int linedefined
Definition: lua.h:448
LUA_API void lua_sethook(lua_State *L, lua_Hook func, int mask, int count)
Definition: ldebug.cpp:81
#define luaL_checkstring(L, n)
Definition: lauxlib.h:124