aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/lua/lvm.c
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-08-25 11:24:10 +0800
committerLi Jin <dragon-fly@qq.com>2022-08-26 10:10:19 +0800
commitdf85ad2e7f975026ca1e6bd84b26fff81c8d99c8 (patch)
tree2b9300041c291382b15da3c354de3640a1498c1b /src/3rdParty/lua/lvm.c
parent2f497477c984e576e9ba7e8f6cb92ee9f794e56b (diff)
downloadyuescript-df85ad2e7f975026ca1e6bd84b26fff81c8d99c8.tar.gz
yuescript-df85ad2e7f975026ca1e6bd84b26fff81c8d99c8.tar.bz2
yuescript-df85ad2e7f975026ca1e6bd84b26fff81c8d99c8.zip
update to Lua 5.4.5.
Diffstat (limited to 'src/3rdParty/lua/lvm.c')
-rw-r--r--src/3rdParty/lua/lvm.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/3rdParty/lua/lvm.c b/src/3rdParty/lua/lvm.c
index f3a5662..614df05 100644
--- a/src/3rdParty/lua/lvm.c
+++ b/src/3rdParty/lua/lvm.c
@@ -643,7 +643,7 @@ void luaV_concat (lua_State *L, int total) {
643 int n = 2; /* number of elements handled in this pass (at least 2) */ 643 int n = 2; /* number of elements handled in this pass (at least 2) */
644 if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) || 644 if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) ||
645 !tostring(L, s2v(top - 1))) 645 !tostring(L, s2v(top - 1)))
646 luaT_tryconcatTM(L); 646 luaT_tryconcatTM(L); /* may invalidate 'top' */
647 else if (isemptystr(s2v(top - 1))) /* second operand is empty? */ 647 else if (isemptystr(s2v(top - 1))) /* second operand is empty? */
648 cast_void(tostring(L, s2v(top - 2))); /* result is first operand */ 648 cast_void(tostring(L, s2v(top - 2))); /* result is first operand */
649 else if (isemptystr(s2v(top - 2))) { /* first operand is empty string? */ 649 else if (isemptystr(s2v(top - 2))) { /* first operand is empty string? */
@@ -656,8 +656,10 @@ void luaV_concat (lua_State *L, int total) {
656 /* collect total length and number of strings */ 656 /* collect total length and number of strings */
657 for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { 657 for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
658 size_t l = vslen(s2v(top - n - 1)); 658 size_t l = vslen(s2v(top - n - 1));
659 if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) 659 if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) {
660 L->top = top - total; /* pop strings to avoid wasting stack */
660 luaG_runerror(L, "string length overflow"); 661 luaG_runerror(L, "string length overflow");
662 }
661 tl += l; 663 tl += l;
662 } 664 }
663 if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */ 665 if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */
@@ -671,8 +673,8 @@ void luaV_concat (lua_State *L, int total) {
671 } 673 }
672 setsvalue2s(L, top - n, ts); /* create result */ 674 setsvalue2s(L, top - n, ts); /* create result */
673 } 675 }
674 total -= n-1; /* got 'n' strings to create 1 new */ 676 total -= n - 1; /* got 'n' strings to create one new */
675 L->top -= n-1; /* popped 'n' strings and pushed one */ 677 L->top -= n - 1; /* popped 'n' strings and pushed one */
676 } while (total > 1); /* repeat until only 1 result left */ 678 } while (total > 1); /* repeat until only 1 result left */
677} 679}
678 680
@@ -1177,7 +1179,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1177 printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); 1179 printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p)));
1178 #endif 1180 #endif
1179 lua_assert(base == ci->func + 1); 1181 lua_assert(base == ci->func + 1);
1180 lua_assert(base <= L->top && L->top < L->stack_last); 1182 lua_assert(base <= L->top && L->top <= L->stack_last);
1181 /* invalidate top for instructions not expecting it */ 1183 /* invalidate top for instructions not expecting it */
1182 lua_assert(isIT(i) || (cast_void(L->top = base), 1)); 1184 lua_assert(isIT(i) || (cast_void(L->top = base), 1));
1183 vmdispatch (GET_OPCODE(i)) { 1185 vmdispatch (GET_OPCODE(i)) {