MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / db_getlocal

Function db_getlocal

extlibs/lua/src/ldblib.c:202–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected