mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-12 09:24:07 +00:00
Compile table.concat().
This commit is contained in:
parent
64d2883ab4
commit
c77680824f
@ -129,7 +129,7 @@ LJLIB_LUA(table_remove) /*
|
||||
end
|
||||
*/
|
||||
|
||||
LJLIB_CF(table_concat)
|
||||
LJLIB_CF(table_concat) LJLIB_REC(.)
|
||||
{
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
GCstr *sep = lj_lib_optstr(L, 2);
|
||||
|
@ -825,6 +825,33 @@ static void LJ_FASTCALL recff_table_insert(jit_State *J, RecordFFData *rd)
|
||||
} /* else: Interpreter will throw. */
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_table_concat(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tab = J->base[0];
|
||||
if (tref_istab(tab)) {
|
||||
TRef sep = 0, tri = 0, tre = 0;
|
||||
TRef hdr, tr;
|
||||
if (J->base[1]) {
|
||||
sep = lj_ir_tostr(J, J->base[1]);
|
||||
if (J->base[2]) {
|
||||
tri = lj_opt_narrow_toint(J, J->base[2]);
|
||||
if (J->base[3])
|
||||
tre = lj_opt_narrow_toint(J, J->base[3]);
|
||||
}
|
||||
} else {
|
||||
sep = lj_ir_knull(J, IRT_STR);
|
||||
}
|
||||
if (!tri) tri = lj_ir_kint(J, 1);
|
||||
if (!tre) tre = lj_ir_call(J, IRCALL_lj_tab_len, tab);
|
||||
hdr = emitir(IRT(IR_BUFHDR, IRT_P32),
|
||||
lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
|
||||
tr = lj_ir_call(J, IRCALL_lj_buf_puttab, hdr, tab, sep, tri, tre);
|
||||
emitir(IRTG(IR_NE, IRT_PTR), tr, lj_ir_kptr(J, NULL));
|
||||
J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
|
||||
} /* else: Interpreter will throw. */
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
/* -- I/O library fast functions ------------------------------------------ */
|
||||
|
||||
/* Get FILE* for I/O function. Any I/O error aborts recording, so there's
|
||||
|
@ -115,6 +115,7 @@ typedef struct CCallInfo {
|
||||
_(ANY, lj_buf_putstr_lower, 2, FL, P32, 0) \
|
||||
_(ANY, lj_buf_putstr_upper, 2, FL, P32, 0) \
|
||||
_(ANY, lj_buf_putstr_rep, 3, L, P32, 0) \
|
||||
_(ANY, lj_buf_puttab, 5, L, P32, 0) \
|
||||
_(ANY, lj_buf_tostr, 1, FL, STR, 0) \
|
||||
_(ANY, lj_tab_new1, 2, FS, TAB, CCI_L) \
|
||||
_(ANY, lj_tab_dup, 2, FS, TAB, CCI_L) \
|
||||
|
Loading…
Reference in New Issue
Block a user