diff options
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -192,15 +192,14 @@ static const char *findvararg (CallInfo *ci, int n, StkId *pos) { | |||
192 | int nextra = ci->u.l.nextraargs; | 192 | int nextra = ci->u.l.nextraargs; |
193 | if (n <= nextra) { | 193 | if (n <= nextra) { |
194 | *pos = ci->func - nextra + (n - 1); | 194 | *pos = ci->func - nextra + (n - 1); |
195 | return "(*vararg)"; /* generic name for any vararg */ | 195 | return "(vararg)"; /* generic name for any vararg */ |
196 | } | 196 | } |
197 | } | 197 | } |
198 | return NULL; /* no such vararg */ | 198 | return NULL; /* no such vararg */ |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | static const char *findlocal (lua_State *L, CallInfo *ci, int n, | 202 | const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { |
203 | StkId *pos) { | ||
204 | StkId base = ci->func + 1; | 203 | StkId base = ci->func + 1; |
205 | const char *name = NULL; | 204 | const char *name = NULL; |
206 | if (isLua(ci)) { | 205 | if (isLua(ci)) { |
@@ -211,12 +210,15 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n, | |||
211 | } | 210 | } |
212 | if (name == NULL) { /* no 'standard' name? */ | 211 | if (name == NULL) { /* no 'standard' name? */ |
213 | StkId limit = (ci == L->ci) ? L->top : ci->next->func; | 212 | StkId limit = (ci == L->ci) ? L->top : ci->next->func; |
214 | if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ | 213 | if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */ |
215 | name = "(*temporary)"; /* generic name for any valid slot */ | 214 | /* generic name for any valid slot */ |
215 | name = isLua(ci) ? "(temporary)" : "(C temporary)"; | ||
216 | } | ||
216 | else | 217 | else |
217 | return NULL; /* no name */ | 218 | return NULL; /* no name */ |
218 | } | 219 | } |
219 | *pos = base + (n - 1); | 220 | if (pos) |
221 | *pos = base + (n - 1); | ||
220 | return name; | 222 | return name; |
221 | } | 223 | } |
222 | 224 | ||
@@ -232,7 +234,7 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
232 | } | 234 | } |
233 | else { /* active function; get information through 'ar' */ | 235 | else { /* active function; get information through 'ar' */ |
234 | StkId pos = NULL; /* to avoid warnings */ | 236 | StkId pos = NULL; /* to avoid warnings */ |
235 | name = findlocal(L, ar->i_ci, n, &pos); | 237 | name = luaG_findlocal(L, ar->i_ci, n, &pos); |
236 | if (name) { | 238 | if (name) { |
237 | setobjs2s(L, L->top, pos); | 239 | setobjs2s(L, L->top, pos); |
238 | api_incr_top(L); | 240 | api_incr_top(L); |
@@ -247,7 +249,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
247 | StkId pos = NULL; /* to avoid warnings */ | 249 | StkId pos = NULL; /* to avoid warnings */ |
248 | const char *name; | 250 | const char *name; |
249 | lua_lock(L); | 251 | lua_lock(L); |
250 | name = findlocal(L, ar->i_ci, n, &pos); | 252 | name = luaG_findlocal(L, ar->i_ci, n, &pos); |
251 | if (name) { | 253 | if (name) { |
252 | setobjs2s(L, pos, L->top - 1); | 254 | setobjs2s(L, pos, L->top - 1); |
253 | L->top--; /* pop value */ | 255 | L->top--; /* pop value */ |