MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / index2adr

Function index2adr

Source/Misc/lua/src/lua.c:1898–1925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1896
1897
1898static TValue *index2adr (lua_State *L, int idx) {
1899if (idx > 0) {
1900TValue *o = L->base + (idx - 1);
1901api_check(L, idx <= L->ci->top - L->base);
1902if (o >= L->top) return cast(TValue *, luaO_nilobject);
1903else return o;
1904}
1905else if (idx > LUA_REGISTRYINDEX) {
1906api_check(L, idx != 0 && -idx <= L->top - L->base);
1907return L->top + idx;
1908}
1909else switch (idx) { /* pseudo-indices */
1910case LUA_REGISTRYINDEX: return registry(L);
1911case LUA_ENVIRONINDEX: {
1912Closure *func = curr_func(L);
1913sethvalue(L, &L->env, func->c.env);
1914return &L->env;
1915}
1916case LUA_GLOBALSINDEX: return gt(L);
1917default: {
1918Closure *func = curr_func(L);
1919idx = LUA_GLOBALSINDEX - idx;
1920return (idx <= func->c.nupvalues)
1921? &func->c.upvalue[idx-1]
1922: cast(TValue *, luaO_nilobject);
1923}
1924}
1925}
1926
1927
1928static Table *getcurrenv (lua_State *L) {

Callers 15

lua_removeFunction · 0.85
lua_insertFunction · 0.85
lua_replaceFunction · 0.85
lua_pushvalueFunction · 0.85
lua_typeFunction · 0.85
lua_iscfunctionFunction · 0.85
lua_isnumberFunction · 0.85
lua_isuserdataFunction · 0.85
lua_rawequalFunction · 0.85
lua_equalFunction · 0.85
lua_lessthanFunction · 0.85
lua_tonumberFunction · 0.85

Calls 1

registryFunction · 0.85

Tested by

no test coverage detected