MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / index2value

Function index2value

3rd/lua-5.4.3/src/lapi.c:56–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

lua_copyFunction · 0.85
lua_pushvalueFunction · 0.85
lua_typeFunction · 0.85
lua_iscfunctionFunction · 0.85
lua_isintegerFunction · 0.85
lua_isnumberFunction · 0.85
lua_isstringFunction · 0.85
lua_isuserdataFunction · 0.85
lua_rawequalFunction · 0.85
lua_compareFunction · 0.85
lua_tonumberxFunction · 0.85
lua_tointegerxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected