MCPcopy Create free account
hub / github.com/defold/defold / index2adr

Function index2adr

engine/lua/src/lua/lapi.c:49–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48
49static TValue *index2adr (lua_State *L, int idx) {
50 if (idx > 0) {
51 TValue *o = L->base + (idx - 1);
52 api_check(L, idx <= L->ci->top - L->base);
53 if (o >= L->top) return cast(TValue *, luaO_nilobject);
54 else return o;
55 }
56 else if (idx > LUA_REGISTRYINDEX) {
57 api_check(L, idx != 0 && -idx <= L->top - L->base);
58 return L->top + idx;
59 }
60 else switch (idx) { /* pseudo-indices */
61 case LUA_REGISTRYINDEX: return registry(L);
62 case LUA_ENVIRONINDEX: {
63 Closure *func = curr_func(L);
64 sethvalue(L, &L->env, func->c.env);
65 return &L->env;
66 }
67 case LUA_GLOBALSINDEX: return gt(L);
68 default: {
69 Closure *func = curr_func(L);
70 idx = LUA_GLOBALSINDEX - idx;
71 return (idx <= func->c.nupvalues)
72 ? &func->c.upvalue[idx-1]
73 : cast(TValue *, luaO_nilobject);
74 }
75 }
76}
77
78
79static 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

gtFunction · 0.85

Tested by

no test coverage detected