MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / db_getlocal

Function db_getlocal

3rd/lua-5.4.3/src/ldblib.c:203–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202
203static int db_getlocal (lua_State *L) {
204 int arg;
205 lua_State *L1 = getthread(L, &arg);
206 int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */
207 if (lua_isfunction(L, arg + 1)) { /* function argument? */
208 lua_pushvalue(L, arg + 1); /* push function */
209 lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
210 return 1; /* return only name (there is no value) */
211 }
212 else { /* stack-level argument */
213 lua_Debug ar;
214 const char *name;
215 int level = (int)luaL_checkinteger(L, arg + 1);
216 if (l_unlikely(!lua_getstack(L1, level, &ar))) /* out of range? */
217 return luaL_argerror(L, arg+1, "level out of range");
218 checkstack(L, L1, 1);
219 name = lua_getlocal(L1, &ar, nvar);
220 if (name) {
221 lua_xmove(L1, L, 1); /* move local value */
222 lua_pushstring(L, name); /* push name */
223 lua_rotate(L, -2, 1); /* re-order */
224 return 2;
225 }
226 else {
227 luaL_pushfail(L); /* no name (nor value) */
228 return 1;
229 }
230 }
231}
232
233
234static int db_setlocal (lua_State *L) {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected