aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib_table.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib_table.c b/src/lib_table.c
index 25894eb0..00374c60 100644
--- a/src/lib_table.c
+++ b/src/lib_table.c
@@ -266,6 +266,24 @@ LJLIB_CF(table_sort)
266 return 0; 266 return 0;
267} 267}
268 268
269#if LJ_52
270LJLIB_PUSH("n")
271LJLIB_CF(table_pack)
272{
273 TValue *array, *base = L->base;
274 MSize i, n = (uint32_t)(L->top - base);
275 GCtab *t = lj_tab_new(L, n ? n+1 : 0, 1);
276 /* NOBARRIER: The table is new (marked white). */
277 setintV(lj_tab_setstr(L, t, strV(lj_lib_upvalue(L, 1))), (int32_t)n);
278 for (array = tvref(t->array) + 1, i = 0; i < n; i++)
279 copyTV(L, &array[i], &base[i]);
280 settabV(L, base, t);
281 L->top = base+1;
282 lj_gc_check(L);
283 return 1;
284}
285#endif
286
269/* ------------------------------------------------------------------------ */ 287/* ------------------------------------------------------------------------ */
270 288
271#include "lj_libdef.h" 289#include "lj_libdef.h"