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