diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-29 12:06:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-29 12:06:44 -0300 |
commit | f96497397addca22f22a6ba6eeabc906be43f16b (patch) | |
tree | af8d27b9af36dfe0b0b6e0f765ea90b95b110efc /ldebug.c | |
parent | 5a1c8d8ef343bf0157851a4832c2c937b812b64f (diff) | |
download | lua-f96497397addca22f22a6ba6eeabc906be43f16b.tar.gz lua-f96497397addca22f22a6ba6eeabc906be43f16b.tar.bz2 lua-f96497397addca22f22a6ba6eeabc906be43f16b.zip |
new type 'StackValue' for stack elements
(we may want to put extra info there in the future)
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.126 2017/05/13 13:54:47 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.127 2017/06/27 11:35:31 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | 36 | ||
37 | /* Active Lua function (given call info) */ | 37 | /* Active Lua function (given call info) */ |
38 | #define ci_func(ci) (clLvalue((ci)->func)) | 38 | #define ci_func(ci) (clLvalue(s2v((ci)->func))) |
39 | 39 | ||
40 | 40 | ||
41 | static const char *funcnamefromcode (lua_State *L, CallInfo *ci, | 41 | static const char *funcnamefromcode (lua_State *L, CallInfo *ci, |
@@ -211,16 +211,16 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
211 | lua_lock(L); | 211 | lua_lock(L); |
212 | swapextra(L); | 212 | swapextra(L); |
213 | if (ar == NULL) { /* information about non-active function? */ | 213 | if (ar == NULL) { /* information about non-active function? */ |
214 | if (!isLfunction(L->top - 1)) /* not a Lua function? */ | 214 | if (!isLfunction(s2v(L->top - 1))) /* not a Lua function? */ |
215 | name = NULL; | 215 | name = NULL; |
216 | else /* consider live variables at function start (parameters) */ | 216 | else /* consider live variables at function start (parameters) */ |
217 | name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0); | 217 | name = luaF_getlocalname(clLvalue(s2v(L->top - 1))->p, n, 0); |
218 | } | 218 | } |
219 | else { /* active function; get information through 'ar' */ | 219 | else { /* active function; get information through 'ar' */ |
220 | StkId pos = NULL; /* to avoid warnings */ | 220 | StkId pos = NULL; /* to avoid warnings */ |
221 | name = findlocal(L, ar->i_ci, n, &pos); | 221 | name = findlocal(L, ar->i_ci, n, &pos); |
222 | if (name) { | 222 | if (name) { |
223 | setobj2s(L, L->top, pos); | 223 | setobjs2s(L, L->top, pos); |
224 | api_incr_top(L); | 224 | api_incr_top(L); |
225 | } | 225 | } |
226 | } | 226 | } |
@@ -274,7 +274,7 @@ static int nextline (Proto *p, int currentline, int pc) { | |||
274 | 274 | ||
275 | static void collectvalidlines (lua_State *L, Closure *f) { | 275 | static void collectvalidlines (lua_State *L, Closure *f) { |
276 | if (noLuaClosure(f)) { | 276 | if (noLuaClosure(f)) { |
277 | setnilvalue(L->top); | 277 | setnilvalue(s2v(L->top)); |
278 | api_incr_top(L); | 278 | api_incr_top(L); |
279 | } | 279 | } |
280 | else { | 280 | else { |
@@ -283,7 +283,7 @@ static void collectvalidlines (lua_State *L, Closure *f) { | |||
283 | Proto *p = f->l.p; | 283 | Proto *p = f->l.p; |
284 | int currentline = p->linedefined; | 284 | int currentline = p->linedefined; |
285 | Table *t = luaH_new(L); /* new table to store active lines */ | 285 | Table *t = luaH_new(L); /* new table to store active lines */ |
286 | sethvalue(L, L->top, t); /* push it on stack */ | 286 | sethvalue2s(L, L->top, t); /* push it on stack */ |
287 | api_incr_top(L); | 287 | api_incr_top(L); |
288 | setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ | 288 | setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ |
289 | for (i = 0; i < p->sizelineinfo; i++) { /* for all lines with code */ | 289 | for (i = 0; i < p->sizelineinfo; i++) { /* for all lines with code */ |
@@ -359,25 +359,25 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
359 | int status; | 359 | int status; |
360 | Closure *cl; | 360 | Closure *cl; |
361 | CallInfo *ci; | 361 | CallInfo *ci; |
362 | StkId func; | 362 | TValue *func; |
363 | lua_lock(L); | 363 | lua_lock(L); |
364 | swapextra(L); | 364 | swapextra(L); |
365 | if (*what == '>') { | 365 | if (*what == '>') { |
366 | ci = NULL; | 366 | ci = NULL; |
367 | func = L->top - 1; | 367 | func = s2v(L->top - 1); |
368 | api_check(L, ttisfunction(func), "function expected"); | 368 | api_check(L, ttisfunction(func), "function expected"); |
369 | what++; /* skip the '>' */ | 369 | what++; /* skip the '>' */ |
370 | L->top--; /* pop function */ | 370 | L->top--; /* pop function */ |
371 | } | 371 | } |
372 | else { | 372 | else { |
373 | ci = ar->i_ci; | 373 | ci = ar->i_ci; |
374 | func = ci->func; | 374 | func = s2v(ci->func); |
375 | lua_assert(ttisfunction(ci->func)); | 375 | lua_assert(ttisfunction(func)); |
376 | } | 376 | } |
377 | cl = ttisclosure(func) ? clvalue(func) : NULL; | 377 | cl = ttisclosure(func) ? clvalue(func) : NULL; |
378 | status = auxgetinfo(L, what, ar, cl, ci); | 378 | status = auxgetinfo(L, what, ar, cl, ci); |
379 | if (strchr(what, 'f')) { | 379 | if (strchr(what, 'f')) { |
380 | setobjs2s(L, L->top, func); | 380 | setobj2s(L, L->top, func); |
381 | api_incr_top(L); | 381 | api_incr_top(L); |
382 | } | 382 | } |
383 | swapextra(L); /* correct before option 'L', which can raise a mem. error */ | 383 | swapextra(L); /* correct before option 'L', which can raise a mem. error */ |
@@ -627,8 +627,8 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci, | |||
627 | */ | 627 | */ |
628 | static int isinstack (CallInfo *ci, const TValue *o) { | 628 | static int isinstack (CallInfo *ci, const TValue *o) { |
629 | StkId base = ci->func + 1; | 629 | StkId base = ci->func + 1; |
630 | ptrdiff_t i = o - base; | 630 | ptrdiff_t i = cast(StkId, o) - base; |
631 | return (0 <= i && i < (ci->top - base) && base + i == o); | 631 | return (0 <= i && i < (ci->top - base) && s2v(base + i) == o); |
632 | } | 632 | } |
633 | 633 | ||
634 | 634 | ||
@@ -659,7 +659,7 @@ static const char *varinfo (lua_State *L, const TValue *o) { | |||
659 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ | 659 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ |
660 | if (!kind && isinstack(ci, o)) /* no? try a register */ | 660 | if (!kind && isinstack(ci, o)) /* no? try a register */ |
661 | kind = getobjname(ci_func(ci)->p, currentpc(ci), | 661 | kind = getobjname(ci_func(ci)->p, currentpc(ci), |
662 | cast_int(o - (ci->func + 1)), &name); | 662 | cast_int(cast(StkId, o) - (ci->func + 1)), &name); |
663 | } | 663 | } |
664 | return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : ""; | 664 | return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : ""; |
665 | } | 665 | } |