diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-02 16:31:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-06-02 16:31:40 -0300 |
commit | 3b44821334a1aa387c13eaf3cd23a2344091cbc7 (patch) | |
tree | 7070ed226b6db26ae82f99d94138465a95b0d7fc /ldebug.c | |
parent | 0214dab989396de05567f293e6aa909ee2ffbac1 (diff) | |
download | lua-3b44821334a1aa387c13eaf3cd23a2344091cbc7.tar.gz lua-3b44821334a1aa387c13eaf3cd23a2344091cbc7.tar.bz2 lua-3b44821334a1aa387c13eaf3cd23a2344091cbc7.zip |
stricter control (using tag variants) over closure kinds (Lua x C)
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.80 2011/04/19 16:22:13 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.81 2011/04/28 14:00:11 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,12 +35,12 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); | |||
35 | 35 | ||
36 | static int currentpc (CallInfo *ci) { | 36 | static int currentpc (CallInfo *ci) { |
37 | lua_assert(isLua(ci)); | 37 | lua_assert(isLua(ci)); |
38 | return pcRel(ci->u.l.savedpc, ci_func(ci)->l.p); | 38 | return pcRel(ci->u.l.savedpc, ci_func(ci)->p); |
39 | } | 39 | } |
40 | 40 | ||
41 | 41 | ||
42 | static int currentline (CallInfo *ci) { | 42 | static int currentline (CallInfo *ci) { |
43 | return getfuncline(ci_func(ci)->l.p, currentpc(ci)); | 43 | return getfuncline(ci_func(ci)->p, currentpc(ci)); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
@@ -95,7 +95,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | |||
95 | 95 | ||
96 | 96 | ||
97 | static const char *findvararg (CallInfo *ci, int n, StkId *pos) { | 97 | static const char *findvararg (CallInfo *ci, int n, StkId *pos) { |
98 | int nparams = clvalue(ci->func)->l.p->numparams; | 98 | int nparams = clLvalue(ci->func)->p->numparams; |
99 | if (n >= ci->u.l.base - ci->func - nparams) | 99 | if (n >= ci->u.l.base - ci->func - nparams) |
100 | return NULL; /* no such vararg */ | 100 | return NULL; /* no such vararg */ |
101 | else { | 101 | else { |
@@ -114,7 +114,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n, | |||
114 | return findvararg(ci, -n, pos); | 114 | return findvararg(ci, -n, pos); |
115 | else { | 115 | else { |
116 | base = ci->u.l.base; | 116 | base = ci->u.l.base; |
117 | name = luaF_getlocalname(ci_func(ci)->l.p, n, currentpc(ci)); | 117 | name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | else | 120 | else |
@@ -138,7 +138,7 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
138 | if (!isLfunction(L->top - 1)) /* not a Lua function? */ | 138 | if (!isLfunction(L->top - 1)) /* not a Lua function? */ |
139 | name = NULL; | 139 | name = NULL; |
140 | else /* consider live variables at function start (parameters) */ | 140 | else /* consider live variables at function start (parameters) */ |
141 | name = luaF_getlocalname(clvalue(L->top - 1)->l.p, n, 0); | 141 | name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0); |
142 | } | 142 | } |
143 | else { /* active function; get information through 'ar' */ | 143 | else { /* active function; get information through 'ar' */ |
144 | StkId pos = 0; /* to avoid warnings */ | 144 | StkId pos = 0; /* to avoid warnings */ |
@@ -294,7 +294,7 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int reg, | |||
294 | static void kname (lua_State *L, CallInfo *ci, int c, int oreg, | 294 | static void kname (lua_State *L, CallInfo *ci, int c, int oreg, |
295 | const char *what, const char **name) { | 295 | const char *what, const char **name) { |
296 | if (ISK(c)) { /* is 'c' a constant? */ | 296 | if (ISK(c)) { /* is 'c' a constant? */ |
297 | TValue *kvalue = &ci_func(ci)->l.p->k[INDEXK(c)]; | 297 | TValue *kvalue = &ci_func(ci)->p->k[INDEXK(c)]; |
298 | if (ttisstring(kvalue)) { /* literal constant? */ | 298 | if (ttisstring(kvalue)) { /* literal constant? */ |
299 | *name = svalue(kvalue); /* it is its own name */ | 299 | *name = svalue(kvalue); /* it is its own name */ |
300 | return; | 300 | return; |
@@ -315,7 +315,7 @@ static void kname (lua_State *L, CallInfo *ci, int c, int oreg, | |||
315 | 315 | ||
316 | static const char *getobjname (lua_State *L, CallInfo *ci, int reg, | 316 | static const char *getobjname (lua_State *L, CallInfo *ci, int reg, |
317 | const char **name) { | 317 | const char **name) { |
318 | Proto *p = ci_func(ci)->l.p; | 318 | Proto *p = ci_func(ci)->p; |
319 | const char *what = NULL; | 319 | const char *what = NULL; |
320 | int lastpc = currentpc(ci); | 320 | int lastpc = currentpc(ci); |
321 | int pc; | 321 | int pc; |
@@ -421,9 +421,9 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { | |||
421 | if ((ci->callstatus & CIST_TAIL) || !isLua(ci->previous)) | 421 | if ((ci->callstatus & CIST_TAIL) || !isLua(ci->previous)) |
422 | return NULL; /* calling function is not Lua (or is unknown) */ | 422 | return NULL; /* calling function is not Lua (or is unknown) */ |
423 | ci = ci->previous; /* calling function */ | 423 | ci = ci->previous; /* calling function */ |
424 | i = ci_func(ci)->l.p->code[currentpc(ci)]; | 424 | i = ci_func(ci)->p->code[currentpc(ci)]; |
425 | if (GET_OPCODE(i) == OP_EXTRAARG) /* extra argument? */ | 425 | if (GET_OPCODE(i) == OP_EXTRAARG) /* extra argument? */ |
426 | i = ci_func(ci)->l.p->code[currentpc(ci) - 1]; /* get 'real' instruction */ | 426 | i = ci_func(ci)->p->code[currentpc(ci) - 1]; /* get 'real' instruction */ |
427 | switch (GET_OPCODE(i)) { | 427 | switch (GET_OPCODE(i)) { |
428 | case OP_CALL: | 428 | case OP_CALL: |
429 | case OP_TAILCALL: | 429 | case OP_TAILCALL: |
@@ -474,7 +474,7 @@ static int isinstack (CallInfo *ci, const TValue *o) { | |||
474 | 474 | ||
475 | static const char *getupvalname (CallInfo *ci, const TValue *o, | 475 | static const char *getupvalname (CallInfo *ci, const TValue *o, |
476 | const char **name) { | 476 | const char **name) { |
477 | LClosure *c = &ci_func(ci)->l; | 477 | LClosure *c = ci_func(ci); |
478 | int i; | 478 | int i; |
479 | for (i = 0; i < c->nupvalues; i++) { | 479 | for (i = 0; i < c->nupvalues; i++) { |
480 | if (c->upvals[i]->v == o) { | 480 | if (c->upvals[i]->v == o) { |
@@ -535,7 +535,7 @@ static void addinfo (lua_State *L, const char *msg) { | |||
535 | if (isLua(ci)) { /* is Lua code? */ | 535 | if (isLua(ci)) { /* is Lua code? */ |
536 | char buff[LUA_IDSIZE]; /* add file:line information */ | 536 | char buff[LUA_IDSIZE]; /* add file:line information */ |
537 | int line = currentline(ci); | 537 | int line = currentline(ci); |
538 | TString *src = ci_func(ci)->l.p->source; | 538 | TString *src = ci_func(ci)->p->source; |
539 | if (src) | 539 | if (src) |
540 | luaO_chunkid(buff, getstr(src), LUA_IDSIZE); | 540 | luaO_chunkid(buff, getstr(src), LUA_IDSIZE); |
541 | else { /* no source available; use "?" instead */ | 541 | else { /* no source available; use "?" instead */ |