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

Function index2addr

third-party/lua-5.2.4/src/lapi.c:55–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

lua_removeFunction · 0.70
lua_insertFunction · 0.70
movetoFunction · 0.70
lua_copyFunction · 0.70
lua_pushvalueFunction · 0.70
lua_typeFunction · 0.70
lua_iscfunctionFunction · 0.70
lua_isnumberFunction · 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