MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaL_ref

Function luaL_ref

third-party/lua-5.2.4/src/lauxlib.c:522–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

520
521
522LUALIB_API int luaL_ref (lua_State *L, int t) {
523 int ref;
524 if (lua_isnil(L, -1)) {
525 lua_pop(L, 1); /* remove from stack */
526 return LUA_REFNIL; /* `nil' has a unique fixed reference */
527 }
528 t = lua_absindex(L, t);
529 lua_rawgeti(L, t, freelist); /* get first free element */
530 ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */
531 lua_pop(L, 1); /* remove it from stack */
532 if (ref != 0) { /* any free element? */
533 lua_rawgeti(L, t, ref); /* remove it from list */
534 lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */
535 }
536 else /* no free elements */
537 ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */
538 lua_rawseti(L, t, ref);
539 return ref;
540}
541
542
543LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {

Callers

nothing calls this directly

Calls 5

lua_absindexFunction · 0.70
lua_rawgetiFunction · 0.70
lua_rawsetiFunction · 0.70
lua_rawlenFunction · 0.70
lua_tointegerFunction · 0.50

Tested by

no test coverage detected