| 194 | |
| 195 | |
| 196 | const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { |
| 197 | StkId base = ci->func.p + 1; |
| 198 | const char *name = NULL; |
| 199 | if (isLua(ci)) { |
| 200 | if (n < 0) /* access to vararg values? */ |
| 201 | return findvararg(ci, n, pos); |
| 202 | else |
| 203 | name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); |
| 204 | } |
| 205 | if (name == NULL) { /* no 'standard' name? */ |
| 206 | StkId limit = (ci == L->ci) ? L->top.p : ci->next->func.p; |
| 207 | if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */ |
| 208 | /* generic name for any valid slot */ |
| 209 | name = isLua(ci) ? "(temporary)" : "(C temporary)"; |
| 210 | } |
| 211 | else |
| 212 | return NULL; /* no name */ |
| 213 | } |
| 214 | if (pos) |
| 215 | *pos = base + (n - 1); |
| 216 | return name; |
| 217 | } |
| 218 | |
| 219 | |
| 220 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { |
no test coverage detected