MCPcopy Create free account
hub / github.com/DFHack/dfhack / findlocal

Function findlocal

depends/lua/src/ldebug.c:146–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144
145
146static 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
172LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {

Callers 2

lua_getlocalFunction · 0.85
lua_setlocalFunction · 0.85

Calls 3

findvarargFunction · 0.85
luaF_getlocalnameFunction · 0.85
currentpcFunction · 0.85

Tested by

no test coverage detected