aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/lua/lvm.c
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-11-02 11:17:58 +0800
committerLi Jin <dragon-fly@qq.com>2021-11-02 11:17:58 +0800
commit827c3736f357e09168fc108e8e740c6425d37d9b (patch)
tree259f977bf7f4ebe0e397fe5e1b74e7fbb1b75e8e /src/3rdParty/lua/lvm.c
parentaed806476fe50899c0f01750175531ac41267b9d (diff)
downloadyuescript-827c3736f357e09168fc108e8e740c6425d37d9b.tar.gz
yuescript-827c3736f357e09168fc108e8e740c6425d37d9b.tar.bz2
yuescript-827c3736f357e09168fc108e8e740c6425d37d9b.zip
fix a wrong code generating issue, update builtin Lua.
Diffstat (limited to 'src/3rdParty/lua/lvm.c')
-rw-r--r--src/3rdParty/lua/lvm.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/3rdParty/lua/lvm.c b/src/3rdParty/lua/lvm.c
index c84a665..49ed3dd 100644
--- a/src/3rdParty/lua/lvm.c
+++ b/src/3rdParty/lua/lvm.c
@@ -406,7 +406,7 @@ static int l_strcmp (const TString *ls, const TString *rs) {
406** from float to int.) 406** from float to int.)
407** When 'f' is NaN, comparisons must result in false. 407** When 'f' is NaN, comparisons must result in false.
408*/ 408*/
409static int LTintfloat (lua_Integer i, lua_Number f) { 409l_sinline int LTintfloat (lua_Integer i, lua_Number f) {
410 if (l_intfitsf(i)) 410 if (l_intfitsf(i))
411 return luai_numlt(cast_num(i), f); /* compare them as floats */ 411 return luai_numlt(cast_num(i), f); /* compare them as floats */
412 else { /* i < f <=> i < ceil(f) */ 412 else { /* i < f <=> i < ceil(f) */
@@ -423,7 +423,7 @@ static int LTintfloat (lua_Integer i, lua_Number f) {
423** Check whether integer 'i' is less than or equal to float 'f'. 423** Check whether integer 'i' is less than or equal to float 'f'.
424** See comments on previous function. 424** See comments on previous function.
425*/ 425*/
426static int LEintfloat (lua_Integer i, lua_Number f) { 426l_sinline int LEintfloat (lua_Integer i, lua_Number f) {
427 if (l_intfitsf(i)) 427 if (l_intfitsf(i))
428 return luai_numle(cast_num(i), f); /* compare them as floats */ 428 return luai_numle(cast_num(i), f); /* compare them as floats */
429 else { /* i <= f <=> i <= floor(f) */ 429 else { /* i <= f <=> i <= floor(f) */
@@ -440,7 +440,7 @@ static int LEintfloat (lua_Integer i, lua_Number f) {
440** Check whether float 'f' is less than integer 'i'. 440** Check whether float 'f' is less than integer 'i'.
441** See comments on previous function. 441** See comments on previous function.
442*/ 442*/
443static int LTfloatint (lua_Number f, lua_Integer i) { 443l_sinline int LTfloatint (lua_Number f, lua_Integer i) {
444 if (l_intfitsf(i)) 444 if (l_intfitsf(i))
445 return luai_numlt(f, cast_num(i)); /* compare them as floats */ 445 return luai_numlt(f, cast_num(i)); /* compare them as floats */
446 else { /* f < i <=> floor(f) < i */ 446 else { /* f < i <=> floor(f) < i */
@@ -457,7 +457,7 @@ static int LTfloatint (lua_Number f, lua_Integer i) {
457** Check whether float 'f' is less than or equal to integer 'i'. 457** Check whether float 'f' is less than or equal to integer 'i'.
458** See comments on previous function. 458** See comments on previous function.
459*/ 459*/
460static int LEfloatint (lua_Number f, lua_Integer i) { 460l_sinline int LEfloatint (lua_Number f, lua_Integer i) {
461 if (l_intfitsf(i)) 461 if (l_intfitsf(i))
462 return luai_numle(f, cast_num(i)); /* compare them as floats */ 462 return luai_numle(f, cast_num(i)); /* compare them as floats */
463 else { /* f <= i <=> ceil(f) <= i */ 463 else { /* f <= i <=> ceil(f) <= i */
@@ -473,7 +473,7 @@ static int LEfloatint (lua_Number f, lua_Integer i) {
473/* 473/*
474** Return 'l < r', for numbers. 474** Return 'l < r', for numbers.
475*/ 475*/
476static int LTnum (const TValue *l, const TValue *r) { 476l_sinline int LTnum (const TValue *l, const TValue *r) {
477 lua_assert(ttisnumber(l) && ttisnumber(r)); 477 lua_assert(ttisnumber(l) && ttisnumber(r));
478 if (ttisinteger(l)) { 478 if (ttisinteger(l)) {
479 lua_Integer li = ivalue(l); 479 lua_Integer li = ivalue(l);
@@ -495,7 +495,7 @@ static int LTnum (const TValue *l, const TValue *r) {
495/* 495/*
496** Return 'l <= r', for numbers. 496** Return 'l <= r', for numbers.
497*/ 497*/
498static int LEnum (const TValue *l, const TValue *r) { 498l_sinline int LEnum (const TValue *l, const TValue *r) {
499 lua_assert(ttisnumber(l) && ttisnumber(r)); 499 lua_assert(ttisnumber(l) && ttisnumber(r));
500 if (ttisinteger(l)) { 500 if (ttisinteger(l)) {
501 lua_Integer li = ivalue(l); 501 lua_Integer li = ivalue(l);
@@ -768,6 +768,7 @@ lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) {
768*/ 768*/
769#define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y)) 769#define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y))
770 770
771
771lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { 772lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) {
772 if (y < 0) { /* shift right? */ 773 if (y < 0) { /* shift right? */
773 if (y <= -NBITS) return 0; 774 if (y <= -NBITS) return 0;
@@ -1108,7 +1109,7 @@ void luaV_finishOp (lua_State *L) {
1108#define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci)) 1109#define ProtectNT(exp) (savepc(L), (exp), updatetrap(ci))
1109 1110
1110/* 1111/*
1111** Protect code that can only raise errors. (That is, it cannnot change 1112** Protect code that can only raise errors. (That is, it cannot change
1112** the stack or hooks.) 1113** the stack or hooks.)
1113*/ 1114*/
1114#define halfProtect(exp) (savestate(L,ci), (exp)) 1115#define halfProtect(exp) (savestate(L,ci), (exp))
@@ -1647,19 +1648,32 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1647 int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; 1648 int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
1648 if (b != 0) 1649 if (b != 0)
1649 L->top = ra + b; 1650 L->top = ra + b;
1650 /* else previous instruction set top */ 1651 else /* previous instruction set top */
1652 b = cast_int(L->top - ra);
1651 savepc(ci); /* several calls here can raise errors */ 1653 savepc(ci); /* several calls here can raise errors */
1652 if (TESTARG_k(i)) { 1654 if (TESTARG_k(i)) {
1653 luaF_closeupval(L, base); /* close upvalues from current call */ 1655 luaF_closeupval(L, base); /* close upvalues from current call */
1654 lua_assert(L->tbclist < base); /* no pending tbc variables */ 1656 lua_assert(L->tbclist < base); /* no pending tbc variables */
1655 lua_assert(base == ci->func + 1); 1657 lua_assert(base == ci->func + 1);
1656 } 1658 }
1657 if (luaD_precall(L, ra, delta2retdel(delta))) /* Lua function? */ 1659 while (!ttisfunction(s2v(ra))) { /* not a function? */
1658 goto startfunc; /* execute the callee */ 1660 ra = luaD_tryfuncTM(L, ra); /* try '__call' metamethod */
1659 else { /* C function */ 1661 b++; /* there is now one extra argument */
1662 }
1663 if (!ttisLclosure(s2v(ra))) { /* C function? */
1664 luaD_precall(L, ra, LUA_MULTRET); /* call it */
1660 updatetrap(ci); 1665 updatetrap(ci);
1666 updatestack(ci); /* stack may have been relocated */
1667 ci->func -= delta; /* restore 'func' (if vararg) */
1668 luaD_poscall(L, ci, cast_int(L->top - ra)); /* finish caller */
1669 updatetrap(ci); /* 'luaD_poscall' can change hooks */
1661 goto ret; /* caller returns after the tail call */ 1670 goto ret; /* caller returns after the tail call */
1662 } 1671 }
1672 else { /* Lua function */
1673 ci->func -= delta; /* restore 'func' (if vararg) */
1674 luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
1675 goto startfunc; /* execute the callee */
1676 }
1663 } 1677 }
1664 vmcase(OP_RETURN) { 1678 vmcase(OP_RETURN) {
1665 int n = GETARG_B(i) - 1; /* number of results */ 1679 int n = GETARG_B(i) - 1; /* number of results */