| 143 | |
| 144 | |
| 145 | static const char *findlocal (lua_State *L, CallInfo *ci, int n, |
| 146 | StkId *pos) { |
| 147 | const char *name = NULL; |
| 148 | StkId base; |
| 149 | if (isLua(ci)) { |
| 150 | if (n < 0) /* access to vararg values? */ |
| 151 | return findvararg(ci, -n, pos); |
| 152 | else { |
| 153 | base = ci->u.l.base; |
| 154 | name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); |
| 155 | } |
| 156 | } |
| 157 | else |
| 158 | base = ci->func + 1; |
| 159 | if (name == NULL) { /* no 'standard' name? */ |
| 160 | StkId limit = (ci == L->ci) ? L->top : ci->next->func; |
| 161 | if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ |
| 162 | name = "(*temporary)"; /* generic name for any valid slot */ |
| 163 | else |
| 164 | return NULL; /* no name */ |
| 165 | } |
| 166 | *pos = base + (n - 1); |
| 167 | return name; |
| 168 | } |
| 169 | |
| 170 | |
| 171 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { |
no test coverage detected