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

Function index2addr

third-party/lua-5.3.5/src/lapi.c:60–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60static TValue *index2addr (lua_State *L, int idx) {
61 CallInfo *ci = L->ci;
62 if (idx > 0) {
63 TValue *o = ci->func + idx;
64 api_check(L, idx <= ci->top - (ci->func + 1), "unacceptable index");
65 if (o >= L->top) return NONVALIDVALUE;
66 else return o;
67 }
68 else if (!ispseudo(idx)) { /* negative index */
69 api_check(L, idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index");
70 return L->top + idx;
71 }
72 else if (idx == LUA_REGISTRYINDEX)
73 return &G(L)->l_registry;
74 else { /* upvalues */
75 idx = LUA_REGISTRYINDEX - idx;
76 api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large");
77 if (ttislcf(ci->func)) /* light C function? */
78 return NONVALIDVALUE; /* it has no upvalues */
79 else {
80 CClosure *func = clCvalue(ci->func);
81 return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE;
82 }
83 }
84}
85
86
87/*

Callers 15

lua_rotateFunction · 0.70
lua_copyFunction · 0.70
lua_pushvalueFunction · 0.70
lua_typeFunction · 0.70
lua_iscfunctionFunction · 0.70
lua_isintegerFunction · 0.70
lua_isnumberFunction · 0.70
lua_isstringFunction · 0.70
lua_isuserdataFunction · 0.70
lua_rawequalFunction · 0.70
lua_compareFunction · 0.70
lua_tonumberxFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected