diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-08-17 23:09:27 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-08-17 23:09:27 +0800 |
| commit | 38908616d0e08b72e6b00d18490ed917fa643e4f (patch) | |
| tree | 4311b80a505f4c3819c8cb2c3c937296fef0356f | |
| parent | 792e942f5269655ee03c48400999f3604b84396c (diff) | |
| download | yuescript-38908616d0e08b72e6b00d18490ed917fa643e4f.tar.gz yuescript-38908616d0e08b72e6b00d18490ed917fa643e4f.tar.bz2 yuescript-38908616d0e08b72e6b00d18490ed917fa643e4f.zip | |
reset Yuescript version since it's a minor version with new feature. update Lua lib.
| -rw-r--r-- | src/3rdParty/lua/lapi.c | 18 | ||||
| -rw-r--r-- | src/3rdParty/lua/lauxlib.c | 1 | ||||
| -rw-r--r-- | src/3rdParty/lua/lbaselib.c | 7 | ||||
| -rw-r--r-- | src/3rdParty/lua/lcode.c | 34 | ||||
| -rw-r--r-- | src/3rdParty/lua/ldebug.c | 48 | ||||
| -rw-r--r-- | src/3rdParty/lua/ldo.c | 60 | ||||
| -rw-r--r-- | src/3rdParty/lua/ldo.h | 15 | ||||
| -rw-r--r-- | src/3rdParty/lua/lobject.h | 2 | ||||
| -rw-r--r-- | src/3rdParty/lua/lopcodes.h | 21 | ||||
| -rw-r--r-- | src/3rdParty/lua/lparser.c | 22 | ||||
| -rw-r--r-- | src/3rdParty/lua/lstate.c | 2 | ||||
| -rw-r--r-- | src/3rdParty/lua/lstate.h | 2 | ||||
| -rw-r--r-- | src/3rdParty/lua/lstrlib.c | 17 | ||||
| -rw-r--r-- | src/3rdParty/lua/ltable.c | 16 | ||||
| -rw-r--r-- | src/3rdParty/lua/ltablib.c | 2 | ||||
| -rw-r--r-- | src/3rdParty/lua/lua.h | 4 | ||||
| -rw-r--r-- | src/3rdParty/lua/luaconf.h | 4 | ||||
| -rw-r--r-- | src/3rdParty/lua/lvm.c | 41 | ||||
| -rw-r--r-- | src/yuescript/yue_compiler.cpp | 2 |
19 files changed, 210 insertions, 108 deletions
diff --git a/src/3rdParty/lua/lapi.c b/src/3rdParty/lua/lapi.c index f8f70cd..3467891 100644 --- a/src/3rdParty/lua/lapi.c +++ b/src/3rdParty/lua/lapi.c | |||
| @@ -53,6 +53,10 @@ const char lua_ident[] = | |||
| 53 | #define isupvalue(i) ((i) < LUA_REGISTRYINDEX) | 53 | #define isupvalue(i) ((i) < LUA_REGISTRYINDEX) |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | /* | ||
| 57 | ** Convert an acceptable index to a pointer to its respective value. | ||
| 58 | ** Non-valid indices return the special nil value 'G(L)->nilvalue'. | ||
| 59 | */ | ||
| 56 | static TValue *index2value (lua_State *L, int idx) { | 60 | static TValue *index2value (lua_State *L, int idx) { |
| 57 | CallInfo *ci = L->ci; | 61 | CallInfo *ci = L->ci; |
| 58 | if (idx > 0) { | 62 | if (idx > 0) { |
| @@ -70,22 +74,26 @@ static TValue *index2value (lua_State *L, int idx) { | |||
| 70 | else { /* upvalues */ | 74 | else { /* upvalues */ |
| 71 | idx = LUA_REGISTRYINDEX - idx; | 75 | idx = LUA_REGISTRYINDEX - idx; |
| 72 | api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); | 76 | api_check(L, idx <= MAXUPVAL + 1, "upvalue index too large"); |
| 73 | if (ttislcf(s2v(ci->func))) /* light C function? */ | 77 | if (ttisCclosure(s2v(ci->func))) { /* C closure? */ |
| 74 | return &G(L)->nilvalue; /* it has no upvalues */ | ||
| 75 | else { | ||
| 76 | CClosure *func = clCvalue(s2v(ci->func)); | 78 | CClosure *func = clCvalue(s2v(ci->func)); |
| 77 | return (idx <= func->nupvalues) ? &func->upvalue[idx-1] | 79 | return (idx <= func->nupvalues) ? &func->upvalue[idx-1] |
| 78 | : &G(L)->nilvalue; | 80 | : &G(L)->nilvalue; |
| 79 | } | 81 | } |
| 82 | else { /* light C function or Lua function (through a hook)?) */ | ||
| 83 | api_check(L, ttislcf(s2v(ci->func)), "caller not a C function"); | ||
| 84 | return &G(L)->nilvalue; /* no upvalues */ | ||
| 85 | } | ||
| 80 | } | 86 | } |
| 81 | } | 87 | } |
| 82 | 88 | ||
| 83 | 89 | /* | |
| 90 | ** Convert a valid actual index (not a pseudo-index) to its address. | ||
| 91 | */ | ||
| 84 | static StkId index2stack (lua_State *L, int idx) { | 92 | static StkId index2stack (lua_State *L, int idx) { |
| 85 | CallInfo *ci = L->ci; | 93 | CallInfo *ci = L->ci; |
| 86 | if (idx > 0) { | 94 | if (idx > 0) { |
| 87 | StkId o = ci->func + idx; | 95 | StkId o = ci->func + idx; |
| 88 | api_check(L, o < L->top, "unacceptable index"); | 96 | api_check(L, o < L->top, "invalid index"); |
| 89 | return o; | 97 | return o; |
| 90 | } | 98 | } |
| 91 | else { /* non-positive index */ | 99 | else { /* non-positive index */ |
diff --git a/src/3rdParty/lua/lauxlib.c b/src/3rdParty/lua/lauxlib.c index 94835ef..8ed1da1 100644 --- a/src/3rdParty/lua/lauxlib.c +++ b/src/3rdParty/lua/lauxlib.c | |||
| @@ -881,6 +881,7 @@ LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) { | |||
| 881 | 881 | ||
| 882 | 882 | ||
| 883 | LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { | 883 | LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { |
| 884 | idx = lua_absindex(L,idx); | ||
| 884 | if (luaL_callmeta(L, idx, "__tostring")) { /* metafield? */ | 885 | if (luaL_callmeta(L, idx, "__tostring")) { /* metafield? */ |
| 885 | if (!lua_isstring(L, -1)) | 886 | if (!lua_isstring(L, -1)) |
| 886 | luaL_error(L, "'__tostring' must return a string"); | 887 | luaL_error(L, "'__tostring' must return a string"); |
diff --git a/src/3rdParty/lua/lbaselib.c b/src/3rdParty/lua/lbaselib.c index 83ad306..fd6687e 100644 --- a/src/3rdParty/lua/lbaselib.c +++ b/src/3rdParty/lua/lbaselib.c | |||
| @@ -261,6 +261,11 @@ static int luaB_next (lua_State *L) { | |||
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | 263 | ||
| 264 | static int pairscont (lua_State *L, int status, lua_KContext k) { | ||
| 265 | (void)L; (void)status; (void)k; /* unused */ | ||
| 266 | return 3; | ||
| 267 | } | ||
| 268 | |||
| 264 | static int luaB_pairs (lua_State *L) { | 269 | static int luaB_pairs (lua_State *L) { |
| 265 | luaL_checkany(L, 1); | 270 | luaL_checkany(L, 1); |
| 266 | if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */ | 271 | if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */ |
| @@ -270,7 +275,7 @@ static int luaB_pairs (lua_State *L) { | |||
| 270 | } | 275 | } |
| 271 | else { | 276 | else { |
| 272 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ | 277 | lua_pushvalue(L, 1); /* argument 'self' to metamethod */ |
| 273 | lua_call(L, 1, 3); /* get 3 values from metamethod */ | 278 | lua_callk(L, 1, 3, 0, pairscont); /* get 3 values from metamethod */ |
| 274 | } | 279 | } |
| 275 | return 3; | 280 | return 3; |
| 276 | } | 281 | } |
diff --git a/src/3rdParty/lua/lcode.c b/src/3rdParty/lua/lcode.c index 80d975c..9cba24f 100644 --- a/src/3rdParty/lua/lcode.c +++ b/src/3rdParty/lua/lcode.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "lprefix.h" | 10 | #include "lprefix.h" |
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | #include <float.h> | ||
| 13 | #include <limits.h> | 14 | #include <limits.h> |
| 14 | #include <math.h> | 15 | #include <math.h> |
| 15 | #include <stdlib.h> | 16 | #include <stdlib.h> |
| @@ -580,24 +581,41 @@ static int stringK (FuncState *fs, TString *s) { | |||
| 580 | 581 | ||
| 581 | /* | 582 | /* |
| 582 | ** Add an integer to list of constants and return its index. | 583 | ** Add an integer to list of constants and return its index. |
| 583 | ** Integers use userdata as keys to avoid collision with floats with | ||
| 584 | ** same value; conversion to 'void*' is used only for hashing, so there | ||
| 585 | ** are no "precision" problems. | ||
| 586 | */ | 584 | */ |
| 587 | static int luaK_intK (FuncState *fs, lua_Integer n) { | 585 | static int luaK_intK (FuncState *fs, lua_Integer n) { |
| 588 | TValue k, o; | 586 | TValue o; |
| 589 | setpvalue(&k, cast_voidp(cast_sizet(n))); | ||
| 590 | setivalue(&o, n); | 587 | setivalue(&o, n); |
| 591 | return addk(fs, &k, &o); | 588 | return addk(fs, &o, &o); /* use integer itself as key */ |
| 592 | } | 589 | } |
| 593 | 590 | ||
| 594 | /* | 591 | /* |
| 595 | ** Add a float to list of constants and return its index. | 592 | ** Add a float to list of constants and return its index. Floats |
| 593 | ** with integral values need a different key, to avoid collision | ||
| 594 | ** with actual integers. To that, we add to the number its smaller | ||
| 595 | ** power-of-two fraction that is still significant in its scale. | ||
| 596 | ** For doubles, that would be 1/2^52. | ||
| 597 | ** (This method is not bulletproof: there may be another float | ||
| 598 | ** with that value, and for floats larger than 2^53 the result is | ||
| 599 | ** still an integer. At worst, this only wastes an entry with | ||
| 600 | ** a duplicate.) | ||
| 596 | */ | 601 | */ |
| 597 | static int luaK_numberK (FuncState *fs, lua_Number r) { | 602 | static int luaK_numberK (FuncState *fs, lua_Number r) { |
| 598 | TValue o; | 603 | TValue o; |
| 604 | lua_Integer ik; | ||
| 599 | setfltvalue(&o, r); | 605 | setfltvalue(&o, r); |
| 600 | return addk(fs, &o, &o); /* use number itself as key */ | 606 | if (!luaV_flttointeger(r, &ik, F2Ieq)) /* not an integral value? */ |
| 607 | return addk(fs, &o, &o); /* use number itself as key */ | ||
| 608 | else { /* must build an alternative key */ | ||
| 609 | const int nbm = l_floatatt(MANT_DIG); | ||
| 610 | const lua_Number q = l_mathop(ldexp)(1.0, -nbm + 1); | ||
| 611 | const lua_Number k = (ik == 0) ? q : r + r*q; /* new key */ | ||
| 612 | TValue kv; | ||
| 613 | setfltvalue(&kv, k); | ||
| 614 | /* result is not an integral value, unless value is too large */ | ||
| 615 | lua_assert(!luaV_flttointeger(k, &ik, F2Ieq) || | ||
| 616 | l_mathop(fabs)(r) >= l_mathop(1e6)); | ||
| 617 | return addk(fs, &kv, &o); | ||
| 618 | } | ||
| 601 | } | 619 | } |
| 602 | 620 | ||
| 603 | 621 | ||
diff --git a/src/3rdParty/lua/ldebug.c b/src/3rdParty/lua/ldebug.c index 1feaab2..433a875 100644 --- a/src/3rdParty/lua/ldebug.c +++ b/src/3rdParty/lua/ldebug.c | |||
| @@ -675,9 +675,21 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, | |||
| 675 | } | 675 | } |
| 676 | 676 | ||
| 677 | 677 | ||
| 678 | static const char *formatvarinfo (lua_State *L, const char *kind, | ||
| 679 | const char *name) { | ||
| 680 | if (kind == NULL) | ||
| 681 | return ""; /* no information */ | ||
| 682 | else | ||
| 683 | return luaO_pushfstring(L, " (%s '%s')", kind, name); | ||
| 684 | } | ||
| 685 | |||
| 686 | /* | ||
| 687 | ** Build a string with a "description" for the value 'o', such as | ||
| 688 | ** "variable 'x'" or "upvalue 'y'". | ||
| 689 | */ | ||
| 678 | static const char *varinfo (lua_State *L, const TValue *o) { | 690 | static const char *varinfo (lua_State *L, const TValue *o) { |
| 679 | const char *name = NULL; /* to avoid warnings */ | ||
| 680 | CallInfo *ci = L->ci; | 691 | CallInfo *ci = L->ci; |
| 692 | const char *name = NULL; /* to avoid warnings */ | ||
| 681 | const char *kind = NULL; | 693 | const char *kind = NULL; |
| 682 | if (isLua(ci)) { | 694 | if (isLua(ci)) { |
| 683 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ | 695 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ |
| @@ -685,26 +697,40 @@ static const char *varinfo (lua_State *L, const TValue *o) { | |||
| 685 | kind = getobjname(ci_func(ci)->p, currentpc(ci), | 697 | kind = getobjname(ci_func(ci)->p, currentpc(ci), |
| 686 | cast_int(cast(StkId, o) - (ci->func + 1)), &name); | 698 | cast_int(cast(StkId, o) - (ci->func + 1)), &name); |
| 687 | } | 699 | } |
| 688 | return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : ""; | 700 | return formatvarinfo(L, kind, name); |
| 689 | } | 701 | } |
| 690 | 702 | ||
| 691 | 703 | ||
| 692 | l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { | 704 | /* |
| 705 | ** Raise a type error | ||
| 706 | */ | ||
| 707 | static l_noret typeerror (lua_State *L, const TValue *o, const char *op, | ||
| 708 | const char *extra) { | ||
| 693 | const char *t = luaT_objtypename(L, o); | 709 | const char *t = luaT_objtypename(L, o); |
| 694 | luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o)); | 710 | luaG_runerror(L, "attempt to %s a %s value%s", op, t, extra); |
| 695 | } | 711 | } |
| 696 | 712 | ||
| 697 | 713 | ||
| 714 | /* | ||
| 715 | ** Raise a type error with "standard" information about the faulty | ||
| 716 | ** object 'o' (using 'varinfo'). | ||
| 717 | */ | ||
| 718 | l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { | ||
| 719 | typeerror(L, o, op, varinfo(L, o)); | ||
| 720 | } | ||
| 721 | |||
| 722 | |||
| 723 | /* | ||
| 724 | ** Raise an error for calling a non-callable object. Try to find | ||
| 725 | ** a name for the object based on the code that made the call | ||
| 726 | ** ('funcnamefromcode'); if it cannot get a name there, try 'varinfo'. | ||
| 727 | */ | ||
| 698 | l_noret luaG_callerror (lua_State *L, const TValue *o) { | 728 | l_noret luaG_callerror (lua_State *L, const TValue *o) { |
| 699 | CallInfo *ci = L->ci; | 729 | CallInfo *ci = L->ci; |
| 700 | const char *name = NULL; /* to avoid warnings */ | 730 | const char *name = NULL; /* to avoid warnings */ |
| 701 | const char *what = (isLua(ci)) ? funcnamefromcode(L, ci, &name) : NULL; | 731 | const char *kind = (isLua(ci)) ? funcnamefromcode(L, ci, &name) : NULL; |
| 702 | if (what != NULL) { | 732 | const char *extra = kind ? formatvarinfo(L, kind, name) : varinfo(L, o); |
| 703 | const char *t = luaT_objtypename(L, o); | 733 | typeerror(L, o, "call", extra); |
| 704 | luaG_runerror(L, "%s '%s' is not callable (a %s value)", what, name, t); | ||
| 705 | } | ||
| 706 | else | ||
| 707 | luaG_typeerror(L, o, "call"); | ||
| 708 | } | 734 | } |
| 709 | 735 | ||
| 710 | 736 | ||
diff --git a/src/3rdParty/lua/ldo.c b/src/3rdParty/lua/ldo.c index 7135079..93fcbb1 100644 --- a/src/3rdParty/lua/ldo.c +++ b/src/3rdParty/lua/ldo.c | |||
| @@ -474,26 +474,34 @@ void luaD_poscall (lua_State *L, CallInfo *ci, int nres) { | |||
| 474 | 474 | ||
| 475 | 475 | ||
| 476 | /* | 476 | /* |
| 477 | ** Prepare a function for a tail call, building its call info on top | 477 | ** In a tail call, move function and parameters to previous call frame. |
| 478 | ** of the current call info. 'narg1' is the number of arguments plus 1 | 478 | ** (This is done only when no more errors can occur before entering the |
| 479 | ** (so that it includes the function itself). | 479 | ** new function, to keep debug information always consistent.) |
| 480 | */ | 480 | */ |
| 481 | void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1) { | 481 | static void moveparams (lua_State *L, StkId prevf, StkId func) { |
| 482 | Proto *p = clLvalue(s2v(func))->p; | ||
| 483 | int fsize = p->maxstacksize; /* frame size */ | ||
| 484 | int nfixparams = p->numparams; | ||
| 485 | int i; | 482 | int i; |
| 486 | for (i = 0; i < narg1; i++) /* move down function and arguments */ | 483 | for (i = 0; func + i < L->top; i++) /* move down function and arguments */ |
| 487 | setobjs2s(L, ci->func + i, func + i); | 484 | setobjs2s(L, prevf + i, func + i); |
| 488 | checkstackGC(L, fsize); | 485 | L->top = prevf + i; /* correct top */ |
| 489 | func = ci->func; /* moved-down function */ | 486 | } |
| 490 | for (; narg1 <= nfixparams; narg1++) | 487 | |
| 491 | setnilvalue(s2v(func + narg1)); /* complete missing arguments */ | 488 | |
| 492 | ci->top = func + 1 + fsize; /* top for new function */ | 489 | static CallInfo *prepCallInfo (lua_State *L, StkId func, int retdel, |
| 493 | lua_assert(ci->top <= L->stack_last); | 490 | int mask) { |
| 494 | ci->u.l.savedpc = p->code; /* starting point */ | 491 | CallInfo *ci; |
| 495 | ci->callstatus |= CIST_TAIL; | 492 | if (isdelta(retdel)) { /* tail call? */ |
| 496 | L->top = func + narg1; /* set top */ | 493 | ci = L->ci; /* reuse stack frame */ |
| 494 | ci->func -= retdel2delta(retdel); /* correct 'func' */ | ||
| 495 | ci->callstatus |= mask | CIST_TAIL; | ||
| 496 | moveparams(L, ci->func, func); | ||
| 497 | } | ||
| 498 | else { /* regular call */ | ||
| 499 | ci = L->ci = next_ci(L); /* new frame */ | ||
| 500 | ci->func = func; | ||
| 501 | ci->nresults = retdel; | ||
| 502 | ci->callstatus = mask; | ||
| 503 | } | ||
| 504 | return ci; | ||
| 497 | } | 505 | } |
| 498 | 506 | ||
| 499 | 507 | ||
| @@ -504,8 +512,12 @@ void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1) { | |||
| 504 | ** to be executed, if it was a Lua function. Otherwise (a C function) | 512 | ** to be executed, if it was a Lua function. Otherwise (a C function) |
| 505 | ** returns NULL, with all the results on the stack, starting at the | 513 | ** returns NULL, with all the results on the stack, starting at the |
| 506 | ** original function position. | 514 | ** original function position. |
| 515 | ** For regular calls, 'delta1' is 0. For tail calls, 'delta1' is the | ||
| 516 | ** 'delta' (correction of base for vararg functions) plus 1, so that it | ||
| 517 | ** cannot be zero. Like 'moveparams', this correction can only be done | ||
| 518 | ** when no more errors can occur in the call. | ||
| 507 | */ | 519 | */ |
| 508 | CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | 520 | CallInfo *luaD_precall (lua_State *L, StkId func, int retdel) { |
| 509 | lua_CFunction f; | 521 | lua_CFunction f; |
| 510 | retry: | 522 | retry: |
| 511 | switch (ttypetag(s2v(func))) { | 523 | switch (ttypetag(s2v(func))) { |
| @@ -518,11 +530,8 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | |||
| 518 | int n; /* number of returns */ | 530 | int n; /* number of returns */ |
| 519 | CallInfo *ci; | 531 | CallInfo *ci; |
| 520 | checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ | 532 | checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ |
| 521 | L->ci = ci = next_ci(L); | 533 | ci = prepCallInfo(L, func, retdel, CIST_C); |
| 522 | ci->nresults = nresults; | ||
| 523 | ci->callstatus = CIST_C; | ||
| 524 | ci->top = L->top + LUA_MINSTACK; | 534 | ci->top = L->top + LUA_MINSTACK; |
| 525 | ci->func = func; | ||
| 526 | lua_assert(ci->top <= L->stack_last); | 535 | lua_assert(ci->top <= L->stack_last); |
| 527 | if (l_unlikely(L->hookmask & LUA_MASKCALL)) { | 536 | if (l_unlikely(L->hookmask & LUA_MASKCALL)) { |
| 528 | int narg = cast_int(L->top - func) - 1; | 537 | int narg = cast_int(L->top - func) - 1; |
| @@ -542,12 +551,9 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | |||
| 542 | int nfixparams = p->numparams; | 551 | int nfixparams = p->numparams; |
| 543 | int fsize = p->maxstacksize; /* frame size */ | 552 | int fsize = p->maxstacksize; /* frame size */ |
| 544 | checkstackGCp(L, fsize, func); | 553 | checkstackGCp(L, fsize, func); |
| 545 | L->ci = ci = next_ci(L); | 554 | ci = prepCallInfo(L, func, retdel, 0); |
| 546 | ci->nresults = nresults; | ||
| 547 | ci->u.l.savedpc = p->code; /* starting point */ | 555 | ci->u.l.savedpc = p->code; /* starting point */ |
| 548 | ci->top = func + 1 + fsize; | 556 | ci->top = func + 1 + fsize; |
| 549 | ci->func = func; | ||
| 550 | L->ci = ci; | ||
| 551 | for (; narg < nfixparams; narg++) | 557 | for (; narg < nfixparams; narg++) |
| 552 | setnilvalue(s2v(L->top++)); /* complete missing arguments */ | 558 | setnilvalue(s2v(L->top++)); /* complete missing arguments */ |
| 553 | lua_assert(ci->top <= L->stack_last); | 559 | lua_assert(ci->top <= L->stack_last); |
diff --git a/src/3rdParty/lua/ldo.h b/src/3rdParty/lua/ldo.h index 6bf0ed8..49fbb49 100644 --- a/src/3rdParty/lua/ldo.h +++ b/src/3rdParty/lua/ldo.h | |||
| @@ -49,6 +49,18 @@ | |||
| 49 | luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) | 49 | luaD_checkstackaux(L, (fsize), luaC_checkGC(L), (void)0) |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | /* | ||
| 53 | ** 'luaD_precall' is used for regular calls, when it needs the | ||
| 54 | ** number of results, and in tail calls, when it needs the 'delta' | ||
| 55 | ** (correction of base for vararg functions). The argument 'retdel' | ||
| 56 | ** codes these two options. A number of results is represented by | ||
| 57 | ** itself, while a delta is represented by 'delta2retdel(delta)' | ||
| 58 | */ | ||
| 59 | #define delta2retdel(d) (-(d) + LUA_MULTRET - 1) | ||
| 60 | #define retdel2delta(d) (-(d) + LUA_MULTRET - 1) | ||
| 61 | #define isdelta(rd) ((rd) < LUA_MULTRET) | ||
| 62 | |||
| 63 | |||
| 52 | /* type of protected functions, to be ran by 'runprotected' */ | 64 | /* type of protected functions, to be ran by 'runprotected' */ |
| 53 | typedef void (*Pfunc) (lua_State *L, void *ud); | 65 | typedef void (*Pfunc) (lua_State *L, void *ud); |
| 54 | 66 | ||
| @@ -58,8 +70,7 @@ LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, | |||
| 58 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, | 70 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, |
| 59 | int fTransfer, int nTransfer); | 71 | int fTransfer, int nTransfer); |
| 60 | LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); | 72 | LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); |
| 61 | LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n); | 73 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int retdel); |
| 62 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); | ||
| 63 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); | 74 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); |
| 64 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); | 75 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); |
| 65 | LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func); | 76 | LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func); |
diff --git a/src/3rdParty/lua/lobject.h b/src/3rdParty/lua/lobject.h index 950bebb..a1b4554 100644 --- a/src/3rdParty/lua/lobject.h +++ b/src/3rdParty/lua/lobject.h | |||
| @@ -112,7 +112,7 @@ typedef struct TValue { | |||
| 112 | #define settt_(o,t) ((o)->tt_=(t)) | 112 | #define settt_(o,t) ((o)->tt_=(t)) |
| 113 | 113 | ||
| 114 | 114 | ||
| 115 | /* main macro to copy values (from 'obj1' to 'obj2') */ | 115 | /* main macro to copy values (from 'obj2' to 'obj1') */ |
| 116 | #define setobj(L,obj1,obj2) \ | 116 | #define setobj(L,obj1,obj2) \ |
| 117 | { TValue *io1=(obj1); const TValue *io2=(obj2); \ | 117 | { TValue *io1=(obj1); const TValue *io2=(obj2); \ |
| 118 | io1->value_ = io2->value_; settt_(io1, io2->tt_); \ | 118 | io1->value_ = io2->value_; settt_(io1, io2->tt_); \ |
diff --git a/src/3rdParty/lua/lopcodes.h b/src/3rdParty/lua/lopcodes.h index d6a47e5..7c27451 100644 --- a/src/3rdParty/lua/lopcodes.h +++ b/src/3rdParty/lua/lopcodes.h | |||
| @@ -190,7 +190,8 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */ | |||
| 190 | 190 | ||
| 191 | 191 | ||
| 192 | /* | 192 | /* |
| 193 | ** grep "ORDER OP" if you change these enums | 193 | ** Grep "ORDER OP" if you change these enums. Opcodes marked with a (*) |
| 194 | ** has extra descriptions in the notes after the enumeration. | ||
| 194 | */ | 195 | */ |
| 195 | 196 | ||
| 196 | typedef enum { | 197 | typedef enum { |
| @@ -203,7 +204,7 @@ OP_LOADF,/* A sBx R[A] := (lua_Number)sBx */ | |||
| 203 | OP_LOADK,/* A Bx R[A] := K[Bx] */ | 204 | OP_LOADK,/* A Bx R[A] := K[Bx] */ |
| 204 | OP_LOADKX,/* A R[A] := K[extra arg] */ | 205 | OP_LOADKX,/* A R[A] := K[extra arg] */ |
| 205 | OP_LOADFALSE,/* A R[A] := false */ | 206 | OP_LOADFALSE,/* A R[A] := false */ |
| 206 | OP_LFALSESKIP,/*A R[A] := false; pc++ */ | 207 | OP_LFALSESKIP,/*A R[A] := false; pc++ (*) */ |
| 207 | OP_LOADTRUE,/* A R[A] := true */ | 208 | OP_LOADTRUE,/* A R[A] := true */ |
| 208 | OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */ | 209 | OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */ |
| 209 | OP_GETUPVAL,/* A B R[A] := UpValue[B] */ | 210 | OP_GETUPVAL,/* A B R[A] := UpValue[B] */ |
| @@ -254,7 +255,7 @@ OP_BXOR,/* A B C R[A] := R[B] ~ R[C] */ | |||
| 254 | OP_SHL,/* A B C R[A] := R[B] << R[C] */ | 255 | OP_SHL,/* A B C R[A] := R[B] << R[C] */ |
| 255 | OP_SHR,/* A B C R[A] := R[B] >> R[C] */ | 256 | OP_SHR,/* A B C R[A] := R[B] >> R[C] */ |
| 256 | 257 | ||
| 257 | OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] */ | 258 | OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] (*) */ |
| 258 | OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */ | 259 | OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */ |
| 259 | OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */ | 260 | OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */ |
| 260 | 261 | ||
| @@ -280,7 +281,7 @@ OP_GTI,/* A sB k if ((R[A] > sB) ~= k) then pc++ */ | |||
| 280 | OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */ | 281 | OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */ |
| 281 | 282 | ||
| 282 | OP_TEST,/* A k if (not R[A] == k) then pc++ */ | 283 | OP_TEST,/* A k if (not R[A] == k) then pc++ */ |
| 283 | OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] */ | 284 | OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] (*) */ |
| 284 | 285 | ||
| 285 | OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ | 286 | OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ |
| 286 | OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */ | 287 | OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */ |
| @@ -315,6 +316,18 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
| 315 | 316 | ||
| 316 | /*=========================================================================== | 317 | /*=========================================================================== |
| 317 | Notes: | 318 | Notes: |
| 319 | |||
| 320 | (*) Opcode OP_LFALSESKIP is used to convert a condition to a boolean | ||
| 321 | value, in a code equivalent to (not cond ? false : true). (It | ||
| 322 | produces false and skips the next instruction producing true.) | ||
| 323 | |||
| 324 | (*) Opcodes OP_MMBIN and variants follow each arithmetic and | ||
| 325 | bitwise opcode. If the operation succeeds, it skips this next | ||
| 326 | opcode. Otherwise, this opcode calls the corresponding metamethod. | ||
| 327 | |||
| 328 | (*) Opcode OP_TESTSET is used in short-circuit expressions that need | ||
| 329 | both to jump and to produce a value, such as (a = b or c). | ||
| 330 | |||
| 318 | (*) In OP_CALL, if (B == 0) then B = top - A. If (C == 0), then | 331 | (*) In OP_CALL, if (B == 0) then B = top - A. If (C == 0), then |
| 319 | 'top' is set to last_result+1, so next open instruction (OP_CALL, | 332 | 'top' is set to last_result+1, so next open instruction (OP_CALL, |
| 320 | OP_RETURN*, OP_SETLIST) may use 'top'. | 333 | OP_RETURN*, OP_SETLIST) may use 'top'. |
diff --git a/src/3rdParty/lua/lparser.c b/src/3rdParty/lua/lparser.c index 284ef1f..3abe3d7 100644 --- a/src/3rdParty/lua/lparser.c +++ b/src/3rdParty/lua/lparser.c | |||
| @@ -417,6 +417,17 @@ static void markupval (FuncState *fs, int level) { | |||
| 417 | 417 | ||
| 418 | 418 | ||
| 419 | /* | 419 | /* |
| 420 | ** Mark that current block has a to-be-closed variable. | ||
| 421 | */ | ||
| 422 | static void marktobeclosed (FuncState *fs) { | ||
| 423 | BlockCnt *bl = fs->bl; | ||
| 424 | bl->upval = 1; | ||
| 425 | bl->insidetbc = 1; | ||
| 426 | fs->needclose = 1; | ||
| 427 | } | ||
| 428 | |||
| 429 | |||
| 430 | /* | ||
| 420 | ** Find a variable with the given name 'n'. If it is an upvalue, add | 431 | ** Find a variable with the given name 'n'. If it is an upvalue, add |
| 421 | ** this upvalue into all intermediate functions. If it is a global, set | 432 | ** this upvalue into all intermediate functions. If it is a global, set |
| 422 | ** 'var' as 'void' as a flag. | 433 | ** 'var' as 'void' as a flag. |
| @@ -1599,7 +1610,7 @@ static void forlist (LexState *ls, TString *indexname) { | |||
| 1599 | line = ls->linenumber; | 1610 | line = ls->linenumber; |
| 1600 | adjust_assign(ls, 4, explist(ls, &e), &e); | 1611 | adjust_assign(ls, 4, explist(ls, &e), &e); |
| 1601 | adjustlocalvars(ls, 4); /* control variables */ | 1612 | adjustlocalvars(ls, 4); /* control variables */ |
| 1602 | markupval(fs, fs->nactvar); /* last control var. must be closed */ | 1613 | marktobeclosed(fs); /* last control var. must be closed */ |
| 1603 | luaK_checkstack(fs, 3); /* extra space to call generator */ | 1614 | luaK_checkstack(fs, 3); /* extra space to call generator */ |
| 1604 | forbody(ls, base, line, nvars - 4, 1); | 1615 | forbody(ls, base, line, nvars - 4, 1); |
| 1605 | } | 1616 | } |
| @@ -1703,11 +1714,9 @@ static int getlocalattribute (LexState *ls) { | |||
| 1703 | } | 1714 | } |
| 1704 | 1715 | ||
| 1705 | 1716 | ||
| 1706 | static void checktoclose (LexState *ls, int level) { | 1717 | static void checktoclose (FuncState *fs, int level) { |
| 1707 | if (level != -1) { /* is there a to-be-closed variable? */ | 1718 | if (level != -1) { /* is there a to-be-closed variable? */ |
| 1708 | FuncState *fs = ls->fs; | 1719 | marktobeclosed(fs); |
| 1709 | markupval(fs, level + 1); | ||
| 1710 | fs->bl->insidetbc = 1; /* in the scope of a to-be-closed variable */ | ||
| 1711 | luaK_codeABC(fs, OP_TBC, reglevel(fs, level), 0, 0); | 1720 | luaK_codeABC(fs, OP_TBC, reglevel(fs, level), 0, 0); |
| 1712 | } | 1721 | } |
| 1713 | } | 1722 | } |
| @@ -1751,7 +1760,7 @@ static void localstat (LexState *ls) { | |||
| 1751 | adjust_assign(ls, nvars, nexps, &e); | 1760 | adjust_assign(ls, nvars, nexps, &e); |
| 1752 | adjustlocalvars(ls, nvars); | 1761 | adjustlocalvars(ls, nvars); |
| 1753 | } | 1762 | } |
| 1754 | checktoclose(ls, toclose); | 1763 | checktoclose(fs, toclose); |
| 1755 | } | 1764 | } |
| 1756 | 1765 | ||
| 1757 | 1766 | ||
| @@ -1776,6 +1785,7 @@ static void funcstat (LexState *ls, int line) { | |||
| 1776 | luaX_next(ls); /* skip FUNCTION */ | 1785 | luaX_next(ls); /* skip FUNCTION */ |
| 1777 | ismethod = funcname(ls, &v); | 1786 | ismethod = funcname(ls, &v); |
| 1778 | body(ls, &b, ismethod, line); | 1787 | body(ls, &b, ismethod, line); |
| 1788 | check_readonly(ls, &v); | ||
| 1779 | luaK_storevar(ls->fs, &v, &b); | 1789 | luaK_storevar(ls->fs, &v, &b); |
| 1780 | luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ | 1790 | luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ |
| 1781 | } | 1791 | } |
diff --git a/src/3rdParty/lua/lstate.c b/src/3rdParty/lua/lstate.c index c5e3b43..bfc5902 100644 --- a/src/3rdParty/lua/lstate.c +++ b/src/3rdParty/lua/lstate.c | |||
| @@ -269,7 +269,7 @@ static void preinit_thread (lua_State *L, global_State *g) { | |||
| 269 | static void close_state (lua_State *L) { | 269 | static void close_state (lua_State *L) { |
| 270 | global_State *g = G(L); | 270 | global_State *g = G(L); |
| 271 | if (!completestate(g)) /* closing a partially built state? */ | 271 | if (!completestate(g)) /* closing a partially built state? */ |
| 272 | luaC_freeallobjects(L); /* jucst collect its objects */ | 272 | luaC_freeallobjects(L); /* just collect its objects */ |
| 273 | else { /* closing a fully built state */ | 273 | else { /* closing a fully built state */ |
| 274 | luaD_closeprotected(L, 1, LUA_OK); /* close all upvalues */ | 274 | luaD_closeprotected(L, 1, LUA_OK); /* close all upvalues */ |
| 275 | luaC_freeallobjects(L); /* collect all objects */ | 275 | luaC_freeallobjects(L); /* collect all objects */ |
diff --git a/src/3rdParty/lua/lstate.h b/src/3rdParty/lua/lstate.h index c1283bb..44cf939 100644 --- a/src/3rdParty/lua/lstate.h +++ b/src/3rdParty/lua/lstate.h | |||
| @@ -165,7 +165,7 @@ typedef struct stringtable { | |||
| 165 | ** - field 'nyield' is used only while a function is "doing" an | 165 | ** - field 'nyield' is used only while a function is "doing" an |
| 166 | ** yield (from the yield until the next resume); | 166 | ** yield (from the yield until the next resume); |
| 167 | ** - field 'nres' is used only while closing tbc variables when | 167 | ** - field 'nres' is used only while closing tbc variables when |
| 168 | ** returning from a C function; | 168 | ** returning from a function; |
| 169 | ** - field 'transferinfo' is used only during call/returnhooks, | 169 | ** - field 'transferinfo' is used only during call/returnhooks, |
| 170 | ** before the function starts or after it ends. | 170 | ** before the function starts or after it ends. |
| 171 | */ | 171 | */ |
diff --git a/src/3rdParty/lua/lstrlib.c b/src/3rdParty/lua/lstrlib.c index 47e5b27..74501f7 100644 --- a/src/3rdParty/lua/lstrlib.c +++ b/src/3rdParty/lua/lstrlib.c | |||
| @@ -1352,15 +1352,6 @@ static const union { | |||
| 1352 | } nativeendian = {1}; | 1352 | } nativeendian = {1}; |
| 1353 | 1353 | ||
| 1354 | 1354 | ||
| 1355 | /* dummy structure to get native alignment requirements */ | ||
| 1356 | struct cD { | ||
| 1357 | char c; | ||
| 1358 | union { double d; void *p; lua_Integer i; lua_Number n; } u; | ||
| 1359 | }; | ||
| 1360 | |||
| 1361 | #define MAXALIGN (offsetof(struct cD, u)) | ||
| 1362 | |||
| 1363 | |||
| 1364 | /* | 1355 | /* |
| 1365 | ** information to pack/unpack stuff | 1356 | ** information to pack/unpack stuff |
| 1366 | */ | 1357 | */ |
| @@ -1435,6 +1426,8 @@ static void initheader (lua_State *L, Header *h) { | |||
| 1435 | ** Read and classify next option. 'size' is filled with option's size. | 1426 | ** Read and classify next option. 'size' is filled with option's size. |
| 1436 | */ | 1427 | */ |
| 1437 | static KOption getoption (Header *h, const char **fmt, int *size) { | 1428 | static KOption getoption (Header *h, const char **fmt, int *size) { |
| 1429 | /* dummy structure to get native alignment requirements */ | ||
| 1430 | struct cD { char c; union { LUAI_MAXALIGN; } u; }; | ||
| 1438 | int opt = *((*fmt)++); | 1431 | int opt = *((*fmt)++); |
| 1439 | *size = 0; /* default */ | 1432 | *size = 0; /* default */ |
| 1440 | switch (opt) { | 1433 | switch (opt) { |
| @@ -1465,7 +1458,11 @@ static KOption getoption (Header *h, const char **fmt, int *size) { | |||
| 1465 | case '<': h->islittle = 1; break; | 1458 | case '<': h->islittle = 1; break; |
| 1466 | case '>': h->islittle = 0; break; | 1459 | case '>': h->islittle = 0; break; |
| 1467 | case '=': h->islittle = nativeendian.little; break; | 1460 | case '=': h->islittle = nativeendian.little; break; |
| 1468 | case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break; | 1461 | case '!': { |
| 1462 | const int maxalign = offsetof(struct cD, u); | ||
| 1463 | h->maxalign = getnumlimit(h, fmt, maxalign); | ||
| 1464 | break; | ||
| 1465 | } | ||
| 1469 | default: luaL_error(h->L, "invalid format option '%c'", opt); | 1466 | default: luaL_error(h->L, "invalid format option '%c'", opt); |
| 1470 | } | 1467 | } |
| 1471 | return Knop; | 1468 | return Knop; |
diff --git a/src/3rdParty/lua/ltable.c b/src/3rdParty/lua/ltable.c index 33c1ab3..af87836 100644 --- a/src/3rdParty/lua/ltable.c +++ b/src/3rdParty/lua/ltable.c | |||
| @@ -84,8 +84,6 @@ | |||
| 84 | #define hashstr(t,str) hashpow2(t, (str)->hash) | 84 | #define hashstr(t,str) hashpow2(t, (str)->hash) |
| 85 | #define hashboolean(t,p) hashpow2(t, p) | 85 | #define hashboolean(t,p) hashpow2(t, p) |
| 86 | 86 | ||
| 87 | #define hashint(t,i) hashpow2(t, i) | ||
| 88 | |||
| 89 | 87 | ||
| 90 | #define hashpointer(t,p) hashmod(t, point2uint(p)) | 88 | #define hashpointer(t,p) hashmod(t, point2uint(p)) |
| 91 | 89 | ||
| @@ -101,6 +99,20 @@ static const Node dummynode_ = { | |||
| 101 | static const TValue absentkey = {ABSTKEYCONSTANT}; | 99 | static const TValue absentkey = {ABSTKEYCONSTANT}; |
| 102 | 100 | ||
| 103 | 101 | ||
| 102 | /* | ||
| 103 | ** Hash for integers. To allow a good hash, use the remainder operator | ||
| 104 | ** ('%'). If integer fits as a non-negative int, compute an int | ||
| 105 | ** remainder, which is faster. Otherwise, use an unsigned-integer | ||
| 106 | ** remainder, which uses all bits and ensures a non-negative result. | ||
| 107 | */ | ||
| 108 | static Node *hashint (const Table *t, lua_Integer i) { | ||
| 109 | lua_Unsigned ui = l_castS2U(i); | ||
| 110 | if (ui <= (unsigned int)INT_MAX) | ||
| 111 | return hashmod(t, cast_int(ui)); | ||
| 112 | else | ||
| 113 | return hashmod(t, ui); | ||
| 114 | } | ||
| 115 | |||
| 104 | 116 | ||
| 105 | /* | 117 | /* |
| 106 | ** Hash for floating-point numbers. | 118 | ** Hash for floating-point numbers. |
diff --git a/src/3rdParty/lua/ltablib.c b/src/3rdParty/lua/ltablib.c index d80eb80..dbfe250 100644 --- a/src/3rdParty/lua/ltablib.c +++ b/src/3rdParty/lua/ltablib.c | |||
| @@ -147,7 +147,7 @@ static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { | |||
| 147 | lua_geti(L, 1, i); | 147 | lua_geti(L, 1, i); |
| 148 | if (l_unlikely(!lua_isstring(L, -1))) | 148 | if (l_unlikely(!lua_isstring(L, -1))) |
| 149 | luaL_error(L, "invalid value (%s) at index %I in table for 'concat'", | 149 | luaL_error(L, "invalid value (%s) at index %I in table for 'concat'", |
| 150 | luaL_typename(L, -1), i); | 150 | luaL_typename(L, -1), (LUAI_UACINT)i); |
| 151 | luaL_addvalue(b); | 151 | luaL_addvalue(b); |
| 152 | } | 152 | } |
| 153 | 153 | ||
diff --git a/src/3rdParty/lua/lua.h b/src/3rdParty/lua/lua.h index 820535b..c3dbce1 100644 --- a/src/3rdParty/lua/lua.h +++ b/src/3rdParty/lua/lua.h | |||
| @@ -18,10 +18,10 @@ | |||
| 18 | 18 | ||
| 19 | #define LUA_VERSION_MAJOR "5" | 19 | #define LUA_VERSION_MAJOR "5" |
| 20 | #define LUA_VERSION_MINOR "4" | 20 | #define LUA_VERSION_MINOR "4" |
| 21 | #define LUA_VERSION_RELEASE "3" | 21 | #define LUA_VERSION_RELEASE "4" |
| 22 | 22 | ||
| 23 | #define LUA_VERSION_NUM 504 | 23 | #define LUA_VERSION_NUM 504 |
| 24 | #define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 0) | 24 | #define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 4) |
| 25 | 25 | ||
| 26 | #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR | 26 | #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR |
| 27 | #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE | 27 | #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE |
diff --git a/src/3rdParty/lua/luaconf.h b/src/3rdParty/lua/luaconf.h index e64d2ee..d42d14b 100644 --- a/src/3rdParty/lua/luaconf.h +++ b/src/3rdParty/lua/luaconf.h | |||
| @@ -485,7 +485,6 @@ | |||
| 485 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. | 485 | @@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER. |
| 486 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. | 486 | @@ LUA_MININTEGER is the minimum value for a LUA_INTEGER. |
| 487 | @@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. | 487 | @@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED. |
| 488 | @@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED. | ||
| 489 | @@ lua_integer2str converts an integer to a string. | 488 | @@ lua_integer2str converts an integer to a string. |
| 490 | */ | 489 | */ |
| 491 | 490 | ||
| @@ -506,9 +505,6 @@ | |||
| 506 | #define LUA_UNSIGNED unsigned LUAI_UACINT | 505 | #define LUA_UNSIGNED unsigned LUAI_UACINT |
| 507 | 506 | ||
| 508 | 507 | ||
| 509 | #define LUA_UNSIGNEDBITS (sizeof(LUA_UNSIGNED) * CHAR_BIT) | ||
| 510 | |||
| 511 | |||
| 512 | /* now the variable definitions */ | 508 | /* now the variable definitions */ |
| 513 | 509 | ||
| 514 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ | 510 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ |
diff --git a/src/3rdParty/lua/lvm.c b/src/3rdParty/lua/lvm.c index c9729bc..c84a665 100644 --- a/src/3rdParty/lua/lvm.c +++ b/src/3rdParty/lua/lvm.c | |||
| @@ -766,7 +766,7 @@ lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) { | |||
| 766 | /* | 766 | /* |
| 767 | ** Shift left operation. (Shift right just negates 'y'.) | 767 | ** Shift left operation. (Shift right just negates 'y'.) |
| 768 | */ | 768 | */ |
| 769 | #define luaV_shiftr(x,y) luaV_shiftl(x,-(y)) | 769 | #define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y)) |
| 770 | 770 | ||
| 771 | lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { | 771 | lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { |
| 772 | if (y < 0) { /* shift right? */ | 772 | if (y < 0) { /* shift right? */ |
| @@ -847,10 +847,19 @@ void luaV_finishOp (lua_State *L) { | |||
| 847 | luaV_concat(L, total); /* concat them (may yield again) */ | 847 | luaV_concat(L, total); /* concat them (may yield again) */ |
| 848 | break; | 848 | break; |
| 849 | } | 849 | } |
| 850 | case OP_CLOSE: case OP_RETURN: { /* yielded closing variables */ | 850 | case OP_CLOSE: { /* yielded closing variables */ |
| 851 | ci->u.l.savedpc--; /* repeat instruction to close other vars. */ | 851 | ci->u.l.savedpc--; /* repeat instruction to close other vars. */ |
| 852 | break; | 852 | break; |
| 853 | } | 853 | } |
| 854 | case OP_RETURN: { /* yielded closing variables */ | ||
| 855 | StkId ra = base + GETARG_A(inst); | ||
| 856 | /* adjust top to signal correct number of returns, in case the | ||
| 857 | return is "up to top" ('isIT') */ | ||
| 858 | L->top = ra + ci->u2.nres; | ||
| 859 | /* repeat instruction to close other vars. and complete the return */ | ||
| 860 | ci->u.l.savedpc--; | ||
| 861 | break; | ||
| 862 | } | ||
| 854 | default: { | 863 | default: { |
| 855 | /* only these other opcodes can yield */ | 864 | /* only these other opcodes can yield */ |
| 856 | lua_assert(op == OP_TFORCALL || op == OP_CALL || | 865 | lua_assert(op == OP_TFORCALL || op == OP_CALL || |
| @@ -1156,8 +1165,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1156 | Instruction i; /* instruction being executed */ | 1165 | Instruction i; /* instruction being executed */ |
| 1157 | StkId ra; /* instruction's A register */ | 1166 | StkId ra; /* instruction's A register */ |
| 1158 | vmfetch(); | 1167 | vmfetch(); |
| 1159 | // low-level line tracing for debugging Lua | 1168 | #if 0 |
| 1160 | // printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); | 1169 | /* low-level line tracing for debugging Lua */ |
| 1170 | printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); | ||
| 1171 | #endif | ||
| 1161 | lua_assert(base == ci->func + 1); | 1172 | lua_assert(base == ci->func + 1); |
| 1162 | lua_assert(base <= L->top && L->top < L->stack_last); | 1173 | lua_assert(base <= L->top && L->top < L->stack_last); |
| 1163 | /* invalidate top for instructions not expecting it */ | 1174 | /* invalidate top for instructions not expecting it */ |
| @@ -1625,7 +1636,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1625 | updatetrap(ci); /* C call; nothing else to be done */ | 1636 | updatetrap(ci); /* C call; nothing else to be done */ |
| 1626 | else { /* Lua call: run function in this same C frame */ | 1637 | else { /* Lua call: run function in this same C frame */ |
| 1627 | ci = newci; | 1638 | ci = newci; |
| 1628 | ci->callstatus = 0; /* call re-uses 'luaV_execute' */ | ||
| 1629 | goto startfunc; | 1639 | goto startfunc; |
| 1630 | } | 1640 | } |
| 1631 | vmbreak; | 1641 | vmbreak; |
| @@ -1637,31 +1647,19 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1637 | int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; | 1647 | int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; |
| 1638 | if (b != 0) | 1648 | if (b != 0) |
| 1639 | L->top = ra + b; | 1649 | L->top = ra + b; |
| 1640 | else /* previous instruction set top */ | 1650 | /* else previous instruction set top */ |
| 1641 | b = cast_int(L->top - ra); | ||
| 1642 | savepc(ci); /* several calls here can raise errors */ | 1651 | savepc(ci); /* several calls here can raise errors */ |
| 1643 | if (TESTARG_k(i)) { | 1652 | if (TESTARG_k(i)) { |
| 1644 | luaF_closeupval(L, base); /* close upvalues from current call */ | 1653 | luaF_closeupval(L, base); /* close upvalues from current call */ |
| 1645 | lua_assert(L->tbclist < base); /* no pending tbc variables */ | 1654 | lua_assert(L->tbclist < base); /* no pending tbc variables */ |
| 1646 | lua_assert(base == ci->func + 1); | 1655 | lua_assert(base == ci->func + 1); |
| 1647 | } | 1656 | } |
| 1648 | while (!ttisfunction(s2v(ra))) { /* not a function? */ | 1657 | if (luaD_precall(L, ra, delta2retdel(delta))) /* Lua function? */ |
| 1649 | luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ | 1658 | goto startfunc; /* execute the callee */ |
| 1650 | b++; /* there is now one extra argument */ | 1659 | else { /* C function */ |
| 1651 | checkstackGCp(L, 1, ra); | ||
| 1652 | } | ||
| 1653 | if (!ttisLclosure(s2v(ra))) { /* C function? */ | ||
| 1654 | luaD_precall(L, ra, LUA_MULTRET); /* call it */ | ||
| 1655 | updatetrap(ci); | 1660 | updatetrap(ci); |
| 1656 | updatestack(ci); /* stack may have been relocated */ | ||
| 1657 | ci->func -= delta; /* restore 'func' (if vararg) */ | ||
| 1658 | luaD_poscall(L, ci, cast_int(L->top - ra)); /* finish caller */ | ||
| 1659 | updatetrap(ci); /* 'luaD_poscall' can change hooks */ | ||
| 1660 | goto ret; /* caller returns after the tail call */ | 1661 | goto ret; /* caller returns after the tail call */ |
| 1661 | } | 1662 | } |
| 1662 | ci->func -= delta; /* restore 'func' (if vararg) */ | ||
| 1663 | luaD_pretailcall(L, ci, ra, b); /* prepare call frame */ | ||
| 1664 | goto startfunc; /* execute the callee */ | ||
| 1665 | } | 1663 | } |
| 1666 | vmcase(OP_RETURN) { | 1664 | vmcase(OP_RETURN) { |
| 1667 | int n = GETARG_B(i) - 1; /* number of results */ | 1665 | int n = GETARG_B(i) - 1; /* number of results */ |
| @@ -1670,6 +1668,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1670 | n = cast_int(L->top - ra); /* get what is available */ | 1668 | n = cast_int(L->top - ra); /* get what is available */ |
| 1671 | savepc(ci); | 1669 | savepc(ci); |
| 1672 | if (TESTARG_k(i)) { /* may there be open upvalues? */ | 1670 | if (TESTARG_k(i)) { /* may there be open upvalues? */ |
| 1671 | ci->u2.nres = n; /* save number of returns */ | ||
| 1673 | if (L->top < ci->top) | 1672 | if (L->top < ci->top) |
| 1674 | L->top = ci->top; | 1673 | L->top = ci->top; |
| 1675 | luaF_close(L, base, CLOSEKTOP, 1); | 1674 | luaF_close(L, base, CLOSEKTOP, 1); |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 8e4072f..e404cd4 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -56,7 +56,7 @@ using namespace parserlib; | |||
| 56 | 56 | ||
| 57 | typedef std::list<std::string> str_list; | 57 | typedef std::list<std::string> str_list; |
| 58 | 58 | ||
| 59 | const std::string_view version = "0.7.18"sv; | 59 | const std::string_view version = "0.8.0"sv; |
| 60 | const std::string_view extension = "yue"sv; | 60 | const std::string_view extension = "yue"sv; |
| 61 | 61 | ||
| 62 | class YueCompilerImpl { | 62 | class YueCompilerImpl { |
