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

Function pack

third-party/lua-5.2.4/src/ltablib.c:120–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118*/
119
120static int pack (lua_State *L) {
121 int n = lua_gettop(L); /* number of elements to pack */
122 lua_createtable(L, n, 1); /* create result table */
123 lua_pushinteger(L, n);
124 lua_setfield(L, -2, "n"); /* t.n = number of elements */
125 if (n > 0) { /* at least one element? */
126 int i;
127 lua_pushvalue(L, 1);
128 lua_rawseti(L, -2, 1); /* insert first element */
129 lua_replace(L, 1); /* move table into index 1 */
130 for (i = n; i >= 2; i--) /* assign other elements */
131 lua_rawseti(L, 1, i);
132 }
133 return 1; /* return table */
134}
135
136
137static int unpack (lua_State *L) {

Callers

nothing calls this directly

Calls 7

lua_gettopFunction · 0.70
lua_createtableFunction · 0.70
lua_pushintegerFunction · 0.70
lua_setfieldFunction · 0.70
lua_pushvalueFunction · 0.70
lua_rawsetiFunction · 0.70
lua_replaceFunction · 0.70

Tested by

no test coverage detected