mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Merge branch 'master' into v2.1
This commit is contained in:
commit
bb2cc1dcaf
@ -134,8 +134,8 @@ LJLIB_CF(table_concat) LJLIB_REC(.)
|
||||
GCtab *t = lj_lib_checktab(L, 1);
|
||||
GCstr *sep = lj_lib_optstr(L, 2);
|
||||
int32_t i = lj_lib_optint(L, 3, 1);
|
||||
int32_t e = L->base+3 < L->top ? lj_lib_checkint(L, 4) :
|
||||
(int32_t)lj_tab_len(t);
|
||||
int32_t e = (L->base+3 < L->top && !tvisnil(L->base+3)) ?
|
||||
lj_lib_checkint(L, 4) : (int32_t)lj_tab_len(t);
|
||||
SBuf *sb = lj_buf_tmp_(L);
|
||||
SBuf *sbx = lj_buf_puttab(sb, t, sep, i, e);
|
||||
if (LJ_UNLIKELY(!sbx)) { /* Error: bad element type. */
|
||||
|
@ -895,23 +895,16 @@ 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),
|
||||
TRef sep = !tref_isnil(J->base[1]) ?
|
||||
lj_ir_tostr(J, J->base[1]) : lj_ir_knull(J, IRT_STR);
|
||||
TRef tri = (J->base[1] && !tref_isnil(J->base[2])) ?
|
||||
lj_opt_narrow_toint(J, J->base[2]) : lj_ir_kint(J, 1);
|
||||
TRef tre = (J->base[1] && J->base[2] && !tref_isnil(J->base[3])) ?
|
||||
lj_opt_narrow_toint(J, J->base[3]) :
|
||||
lj_ir_call(J, IRCALL_lj_tab_len, tab);
|
||||
TRef 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);
|
||||
TRef 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. */
|
||||
|
Loading…
Reference in New Issue
Block a user