| 166 | |
| 167 | |
| 168 | static const char *findlocal(lua_State *L, CallInfo *ci, int n, |
| 169 | StkId *pos) { |
| 170 | const char *name = nullptr; |
| 171 | StkId base; |
| 172 | if (isLua(ci)) { |
| 173 | if (n < 0) /* access to vararg values? */ |
| 174 | return findvararg(ci, -n, pos); |
| 175 | else { |
| 176 | base = ci->u.l.base; |
| 177 | name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); |
| 178 | } |
| 179 | } |
| 180 | else |
| 181 | base = ci->func + 1; |
| 182 | if (name == nullptr) { /* no 'standard' name? */ |
| 183 | StkId limit = (ci == L->ci) ? L->top : ci->next->func; |
| 184 | if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ |
| 185 | name = "(*temporary)"; /* generic name for any valid slot */ |
| 186 | else |
| 187 | return nullptr; /* no name */ |
| 188 | } |
| 189 | *pos = base + (n - 1); |
| 190 | return name; |
| 191 | } |
| 192 | |
| 193 | |
| 194 | LUA_API const char *lua_getlocal(lua_State *L, const lua_Debug *ar, int n) { |
no test coverage detected