aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib_table.c4
-rw-r--r--src/lj_ffrecord.c27
2 files changed, 12 insertions, 19 deletions
diff --git a/src/lib_table.c b/src/lib_table.c
index 4f5d9d0d..80c7c8dc 100644
--- a/src/lib_table.c
+++ b/src/lib_table.c
@@ -134,8 +134,8 @@ LJLIB_CF(table_concat) LJLIB_REC(.)
134 GCtab *t = lj_lib_checktab(L, 1); 134 GCtab *t = lj_lib_checktab(L, 1);
135 GCstr *sep = lj_lib_optstr(L, 2); 135 GCstr *sep = lj_lib_optstr(L, 2);
136 int32_t i = lj_lib_optint(L, 3, 1); 136 int32_t i = lj_lib_optint(L, 3, 1);
137 int32_t e = L->base+3 < L->top ? lj_lib_checkint(L, 4) : 137 int32_t e = (L->base+3 < L->top && !tvisnil(L->base+3)) ?
138 (int32_t)lj_tab_len(t); 138 lj_lib_checkint(L, 4) : (int32_t)lj_tab_len(t);
139 SBuf *sb = lj_buf_tmp_(L); 139 SBuf *sb = lj_buf_tmp_(L);
140 SBuf *sbx = lj_buf_puttab(sb, t, sep, i, e); 140 SBuf *sbx = lj_buf_puttab(sb, t, sep, i, e);
141 if (LJ_UNLIKELY(!sbx)) { /* Error: bad element type. */ 141 if (LJ_UNLIKELY(!sbx)) { /* Error: bad element type. */
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index 289c5775..d1aa65c0 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -895,23 +895,16 @@ static void LJ_FASTCALL recff_table_concat(jit_State *J, RecordFFData *rd)
895{ 895{
896 TRef tab = J->base[0]; 896 TRef tab = J->base[0];
897 if (tref_istab(tab)) { 897 if (tref_istab(tab)) {
898 TRef sep = 0, tri = 0, tre = 0; 898 TRef sep = !tref_isnil(J->base[1]) ?
899 TRef hdr, tr; 899 lj_ir_tostr(J, J->base[1]) : lj_ir_knull(J, IRT_STR);
900 if (J->base[1]) { 900 TRef tri = (J->base[1] && !tref_isnil(J->base[2])) ?
901 sep = lj_ir_tostr(J, J->base[1]); 901 lj_opt_narrow_toint(J, J->base[2]) : lj_ir_kint(J, 1);
902 if (J->base[2]) { 902 TRef tre = (J->base[1] && J->base[2] && !tref_isnil(J->base[3])) ?
903 tri = lj_opt_narrow_toint(J, J->base[2]); 903 lj_opt_narrow_toint(J, J->base[3]) :
904 if (J->base[3]) 904 lj_ir_call(J, IRCALL_lj_tab_len, tab);
905 tre = lj_opt_narrow_toint(J, J->base[3]); 905 TRef hdr = emitir(IRT(IR_BUFHDR, IRT_P32),
906 } 906 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
907 } else { 907 TRef tr = lj_ir_call(J, IRCALL_lj_buf_puttab, hdr, tab, sep, tri, tre);
908 sep = lj_ir_knull(J, IRT_STR);
909 }
910 if (!tri) tri = lj_ir_kint(J, 1);
911 if (!tre) tre = lj_ir_call(J, IRCALL_lj_tab_len, tab);
912 hdr = emitir(IRT(IR_BUFHDR, IRT_P32),
913 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
914 tr = lj_ir_call(J, IRCALL_lj_buf_puttab, hdr, tab, sep, tri, tre);
915 emitir(IRTG(IR_NE, IRT_PTR), tr, lj_ir_kptr(J, NULL)); 908 emitir(IRTG(IR_NE, IRT_PTR), tr, lj_ir_kptr(J, NULL));
916 J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr); 909 J->base[0] = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
917 } /* else: Interpreter will throw. */ 910 } /* else: Interpreter will throw. */