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

Function db_getlocal

depends/lua/src/ldblib.c:193–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191
192
193static int db_getlocal (lua_State *L) {
194 int arg;
195 lua_State *L1 = getthread(L, &arg);
196 lua_Debug ar;
197 const char *name;
198 int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */
199 if (lua_isfunction(L, arg + 1)) { /* function argument? */
200 lua_pushvalue(L, arg + 1); /* push function */
201 lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
202 return 1; /* return only name (there is no value) */
203 }
204 else { /* stack-level argument */
205 int level = (int)luaL_checkinteger(L, arg + 1);
206 if (!lua_getstack(L1, level, &ar)) /* out of range? */
207 return luaL_argerror(L, arg+1, "level out of range");
208 checkstack(L, L1, 1);
209 name = lua_getlocal(L1, &ar, nvar);
210 if (name) {
211 lua_xmove(L1, L, 1); /* move local value */
212 lua_pushstring(L, name); /* push name */
213 lua_rotate(L, -2, 1); /* re-order */
214 return 2;
215 }
216 else {
217 lua_pushnil(L); /* no name (nor value) */
218 return 1;
219 }
220 }
221}
222
223
224static int db_setlocal (lua_State *L) {

Callers

nothing calls this directly

Calls 11

getthreadFunction · 0.85
luaL_checkintegerFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushstringFunction · 0.85
lua_getlocalFunction · 0.85
lua_getstackFunction · 0.85
luaL_argerrorFunction · 0.85
checkstackFunction · 0.85
lua_xmoveFunction · 0.85
lua_rotateFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected