| 122 | |
| 123 | |
| 124 | static const char *findlocal (lua_State *L, CallInfo *ci, int n, |
| 125 | StkId *pos) { |
| 126 | const char *name = NULL; |
| 127 | StkId base; |
| 128 | if (isLua(ci)) { |
| 129 | if (n < 0) /* access to vararg values? */ |
| 130 | return findvararg(ci, -n, pos); |
| 131 | else { |
| 132 | base = ci->u.l.base; |
| 133 | name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); |
| 134 | } |
| 135 | } |
| 136 | else |
| 137 | base = ci->func + 1; |
| 138 | if (name == NULL) { /* no 'standard' name? */ |
| 139 | StkId limit = (ci == L->ci) ? L->top : ci->next->func; |
| 140 | if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ |
| 141 | name = "(*temporary)"; /* generic name for any valid slot */ |
| 142 | else |
| 143 | return NULL; /* no name */ |
| 144 | } |
| 145 | *pos = base + (n - 1); |
| 146 | return name; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { |
no test coverage detected