diff options
Diffstat (limited to '')
| -rw-r--r-- | spec/inputs/macro-todo.yue | 13 | ||||
| -rw-r--r-- | spec/inputs/macro.yue | 15 | ||||
| -rw-r--r-- | spec/outputs/macro-todo.lua | 2 | ||||
| -rw-r--r-- | spec/outputs/macro.lua | 2 | ||||
| -rw-r--r-- | src/3rdParty/lua/lauxlib.h | 2 | ||||
| -rw-r--r-- | src/3rdParty/lua/lcorolib.c | 4 | ||||
| -rw-r--r-- | src/3rdParty/lua/ldebug.c | 9 | ||||
| -rw-r--r-- | src/3rdParty/lua/ldo.c | 125 | ||||
| -rw-r--r-- | src/3rdParty/lua/ldo.h | 2 | ||||
| -rw-r--r-- | src/3rdParty/lua/lstate.c | 4 | ||||
| -rw-r--r-- | src/3rdParty/lua/lvm.c | 19 |
11 files changed, 114 insertions, 83 deletions
diff --git a/spec/inputs/macro-todo.yue b/spec/inputs/macro-todo.yue new file mode 100644 index 0000000..8477e5a --- /dev/null +++ b/spec/inputs/macro-todo.yue | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | export macro todoInner = (module, line, msg)-> | ||
| 2 | print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" | ||
| 3 | { | ||
| 4 | code: "-- TODO#{msg and ': ' .. msg or ''}" | ||
| 5 | type: "lua" | ||
| 6 | } | ||
| 7 | |||
| 8 | export macro todo = (msg)-> | ||
| 9 | if msg | ||
| 10 | "$todoInner $MODULE, $LINE, #{msg}" | ||
| 11 | else | ||
| 12 | "$todoInner $MODULE, $LINE" | ||
| 13 | |||
diff --git a/spec/inputs/macro.yue b/spec/inputs/macro.yue index 366a3d9..2742bd0 100644 --- a/spec/inputs/macro.yue +++ b/spec/inputs/macro.yue | |||
| @@ -6,6 +6,8 @@ import "macro-export" as { | |||
| 6 | $config:$myconfig, -- rename macro $config to $myconfig | 6 | $config:$myconfig, -- rename macro $config to $myconfig |
| 7 | } | 7 | } |
| 8 | 8 | ||
| 9 | import "macro-todo" as $ | ||
| 10 | |||
| 9 | $asserts item == nil | 11 | $asserts item == nil |
| 10 | 12 | ||
| 11 | $myconfig false | 13 | $myconfig false |
| @@ -258,19 +260,6 @@ print $tb[1], $tb.a, ($tb)!, $tb! | |||
| 258 | 260 | ||
| 259 | print "current line: #{ $LINE }" | 261 | print "current line: #{ $LINE }" |
| 260 | 262 | ||
| 261 | macro todoInner = (module, line, msg)-> | ||
| 262 | print "TODO#{msg and ': ' .. msg or ''} in file #{module}, at line #{line}" | ||
| 263 | { | ||
| 264 | code: "-- TODO#{msg and ': ' .. msg or ''}" | ||
| 265 | type: "lua" | ||
| 266 | } | ||
| 267 | |||
| 268 | macro todo = (msg)-> | ||
| 269 | if msg | ||
| 270 | "$todoInner $MODULE, $LINE, #{msg}" | ||
| 271 | else | ||
| 272 | "$todoInner $MODULE, $LINE" | ||
| 273 | |||
| 274 | $todo | 263 | $todo |
| 275 | 264 | ||
| 276 | macro implicitReturnMacroIsAllowed = -> "print 'abc'\n123" | 265 | macro implicitReturnMacroIsAllowed = -> "print 'abc'\n123" |
diff --git a/spec/outputs/macro-todo.lua b/spec/outputs/macro-todo.lua new file mode 100644 index 0000000..b5a63f8 --- /dev/null +++ b/spec/outputs/macro-todo.lua | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | local _module_0 = { } | ||
| 2 | return _module_0 | ||
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua index 7812182..9f04216 100644 --- a/spec/outputs/macro.lua +++ b/spec/outputs/macro.lua | |||
| @@ -258,7 +258,7 @@ print((setmetatable({ | |||
| 258 | return 998 | 258 | return 998 |
| 259 | end | 259 | end |
| 260 | })) | 260 | })) |
| 261 | print("current line: " .. tostring(259)) | 261 | print("current line: " .. tostring(261)); |
| 262 | -- TODO | 262 | -- TODO |
| 263 | print('abc') | 263 | print('abc') |
| 264 | return 123 | 264 | return 123 |
diff --git a/src/3rdParty/lua/lauxlib.h b/src/3rdParty/lua/lauxlib.h index 6f9695e..5b977e2 100644 --- a/src/3rdParty/lua/lauxlib.h +++ b/src/3rdParty/lua/lauxlib.h | |||
| @@ -102,7 +102,7 @@ LUALIB_API lua_State *(luaL_newstate) (void); | |||
| 102 | 102 | ||
| 103 | LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); | 103 | LUALIB_API lua_Integer (luaL_len) (lua_State *L, int idx); |
| 104 | 104 | ||
| 105 | LUALIB_API void luaL_addgsub (luaL_Buffer *b, const char *s, | 105 | LUALIB_API void (luaL_addgsub) (luaL_Buffer *b, const char *s, |
| 106 | const char *p, const char *r); | 106 | const char *p, const char *r); |
| 107 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, | 107 | LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, |
| 108 | const char *p, const char *r); | 108 | const char *p, const char *r); |
diff --git a/src/3rdParty/lua/lcorolib.c b/src/3rdParty/lua/lcorolib.c index fedbebe..785a1e8 100644 --- a/src/3rdParty/lua/lcorolib.c +++ b/src/3rdParty/lua/lcorolib.c | |||
| @@ -78,7 +78,7 @@ static int luaB_auxwrap (lua_State *L) { | |||
| 78 | if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ | 78 | if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ |
| 79 | stat = lua_resetthread(co); /* close its tbc variables */ | 79 | stat = lua_resetthread(co); /* close its tbc variables */ |
| 80 | lua_assert(stat != LUA_OK); | 80 | lua_assert(stat != LUA_OK); |
| 81 | lua_xmove(co, L, 1); /* copy error message */ | 81 | lua_xmove(co, L, 1); /* move error message to the caller */ |
| 82 | } | 82 | } |
| 83 | if (stat != LUA_ERRMEM && /* not a memory error and ... */ | 83 | if (stat != LUA_ERRMEM && /* not a memory error and ... */ |
| 84 | lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ | 84 | lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */ |
| @@ -179,7 +179,7 @@ static int luaB_close (lua_State *L) { | |||
| 179 | } | 179 | } |
| 180 | else { | 180 | else { |
| 181 | lua_pushboolean(L, 0); | 181 | lua_pushboolean(L, 0); |
| 182 | lua_xmove(co, L, 1); /* copy error message */ | 182 | lua_xmove(co, L, 1); /* move error message */ |
| 183 | return 2; | 183 | return 2; |
| 184 | } | 184 | } |
| 185 | } | 185 | } |
diff --git a/src/3rdParty/lua/ldebug.c b/src/3rdParty/lua/ldebug.c index dde4669..30a2882 100644 --- a/src/3rdParty/lua/ldebug.c +++ b/src/3rdParty/lua/ldebug.c | |||
| @@ -301,7 +301,14 @@ static void collectvalidlines (lua_State *L, Closure *f) { | |||
| 301 | sethvalue2s(L, L->top, t); /* push it on stack */ | 301 | sethvalue2s(L, L->top, t); /* push it on stack */ |
| 302 | api_incr_top(L); | 302 | api_incr_top(L); |
| 303 | setbtvalue(&v); /* boolean 'true' to be the value of all indices */ | 303 | setbtvalue(&v); /* boolean 'true' to be the value of all indices */ |
| 304 | for (i = 0; i < p->sizelineinfo; i++) { /* for all instructions */ | 304 | if (!p->is_vararg) /* regular function? */ |
| 305 | i = 0; /* consider all instructions */ | ||
| 306 | else { /* vararg function */ | ||
| 307 | lua_assert(p->code[0] == OP_VARARGPREP); | ||
| 308 | currentline = nextline(p, currentline, 0); | ||
| 309 | i = 1; /* skip first instruction (OP_VARARGPREP) */ | ||
| 310 | } | ||
| 311 | for (; i < p->sizelineinfo; i++) { /* for each instruction */ | ||
| 305 | currentline = nextline(p, currentline, i); /* get its line */ | 312 | currentline = nextline(p, currentline, i); /* get its line */ |
| 306 | luaH_setint(L, t, currentline, &v); /* table[line] = true */ | 313 | luaH_setint(L, t, currentline, &v); /* table[line] = true */ |
| 307 | } | 314 | } |
diff --git a/src/3rdParty/lua/ldo.c b/src/3rdParty/lua/ldo.c index 88b20f9..f282a77 100644 --- a/src/3rdParty/lua/ldo.c +++ b/src/3rdParty/lua/ldo.c | |||
| @@ -388,9 +388,10 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) { | |||
| 388 | ** an error if there is no '__call' metafield. | 388 | ** an error if there is no '__call' metafield. |
| 389 | */ | 389 | */ |
| 390 | StkId luaD_tryfuncTM (lua_State *L, StkId func) { | 390 | StkId luaD_tryfuncTM (lua_State *L, StkId func) { |
| 391 | const TValue *tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); | 391 | const TValue *tm; |
| 392 | StkId p; | 392 | StkId p; |
| 393 | checkstackGCp(L, 1, func); /* space for metamethod */ | 393 | checkstackGCp(L, 1, func); /* space for metamethod */ |
| 394 | tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */ | ||
| 394 | if (l_unlikely(ttisnil(tm))) | 395 | if (l_unlikely(ttisnil(tm))) |
| 395 | luaG_callerror(L, s2v(func)); /* nothing to call */ | 396 | luaG_callerror(L, s2v(func)); /* nothing to call */ |
| 396 | for (p = L->top; p > func; p--) /* open space for metamethod */ | 397 | for (p = L->top; p > func; p--) /* open space for metamethod */ |
| @@ -475,30 +476,6 @@ void luaD_poscall (lua_State *L, CallInfo *ci, int nres) { | |||
| 475 | #define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L)) | 476 | #define next_ci(L) (L->ci->next ? L->ci->next : luaE_extendCI(L)) |
| 476 | 477 | ||
| 477 | 478 | ||
| 478 | /* | ||
| 479 | ** Prepare a function for a tail call, building its call info on top | ||
| 480 | ** of the current call info. 'narg1' is the number of arguments plus 1 | ||
| 481 | ** (so that it includes the function itself). | ||
| 482 | */ | ||
| 483 | void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1) { | ||
| 484 | Proto *p = clLvalue(s2v(func))->p; | ||
| 485 | int fsize = p->maxstacksize; /* frame size */ | ||
| 486 | int nfixparams = p->numparams; | ||
| 487 | int i; | ||
| 488 | for (i = 0; i < narg1; i++) /* move down function and arguments */ | ||
| 489 | setobjs2s(L, ci->func + i, func + i); | ||
| 490 | checkstackGC(L, fsize); | ||
| 491 | func = ci->func; /* moved-down function */ | ||
| 492 | for (; narg1 <= nfixparams; narg1++) | ||
| 493 | setnilvalue(s2v(func + narg1)); /* complete missing arguments */ | ||
| 494 | ci->top = func + 1 + fsize; /* top for new function */ | ||
| 495 | lua_assert(ci->top <= L->stack_last); | ||
| 496 | ci->u.l.savedpc = p->code; /* starting point */ | ||
| 497 | ci->callstatus |= CIST_TAIL; | ||
| 498 | L->top = func + narg1; /* set top */ | ||
| 499 | } | ||
| 500 | |||
| 501 | |||
| 502 | l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret, | 479 | l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret, |
| 503 | int mask, StkId top) { | 480 | int mask, StkId top) { |
| 504 | CallInfo *ci = L->ci = next_ci(L); /* new frame */ | 481 | CallInfo *ci = L->ci = next_ci(L); /* new frame */ |
| @@ -511,6 +488,73 @@ l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret, | |||
| 511 | 488 | ||
| 512 | 489 | ||
| 513 | /* | 490 | /* |
| 491 | ** precall for C functions | ||
| 492 | */ | ||
| 493 | l_sinline int precallC (lua_State *L, StkId func, int nresults, | ||
| 494 | lua_CFunction f) { | ||
| 495 | int n; /* number of returns */ | ||
| 496 | CallInfo *ci; | ||
| 497 | checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ | ||
| 498 | L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, | ||
| 499 | L->top + LUA_MINSTACK); | ||
| 500 | lua_assert(ci->top <= L->stack_last); | ||
| 501 | if (l_unlikely(L->hookmask & LUA_MASKCALL)) { | ||
| 502 | int narg = cast_int(L->top - func) - 1; | ||
| 503 | luaD_hook(L, LUA_HOOKCALL, -1, 1, narg); | ||
| 504 | } | ||
| 505 | lua_unlock(L); | ||
| 506 | n = (*f)(L); /* do the actual call */ | ||
| 507 | lua_lock(L); | ||
| 508 | api_checknelems(L, n); | ||
| 509 | luaD_poscall(L, ci, n); | ||
| 510 | return n; | ||
| 511 | } | ||
| 512 | |||
| 513 | |||
| 514 | /* | ||
| 515 | ** Prepare a function for a tail call, building its call info on top | ||
| 516 | ** of the current call info. 'narg1' is the number of arguments plus 1 | ||
| 517 | ** (so that it includes the function itself). Return the number of | ||
| 518 | ** results, if it was a C function, or -1 for a Lua function. | ||
| 519 | */ | ||
| 520 | int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, | ||
| 521 | int narg1, int delta) { | ||
| 522 | retry: | ||
| 523 | switch (ttypetag(s2v(func))) { | ||
| 524 | case LUA_VCCL: /* C closure */ | ||
| 525 | return precallC(L, func, LUA_MULTRET, clCvalue(s2v(func))->f); | ||
| 526 | case LUA_VLCF: /* light C function */ | ||
| 527 | return precallC(L, func, LUA_MULTRET, fvalue(s2v(func))); | ||
| 528 | case LUA_VLCL: { /* Lua function */ | ||
| 529 | Proto *p = clLvalue(s2v(func))->p; | ||
| 530 | int fsize = p->maxstacksize; /* frame size */ | ||
| 531 | int nfixparams = p->numparams; | ||
| 532 | int i; | ||
| 533 | ci->func -= delta; /* restore 'func' (if vararg) */ | ||
| 534 | for (i = 0; i < narg1; i++) /* move down function and arguments */ | ||
| 535 | setobjs2s(L, ci->func + i, func + i); | ||
| 536 | checkstackGC(L, fsize); | ||
| 537 | func = ci->func; /* moved-down function */ | ||
| 538 | for (; narg1 <= nfixparams; narg1++) | ||
| 539 | setnilvalue(s2v(func + narg1)); /* complete missing arguments */ | ||
| 540 | ci->top = func + 1 + fsize; /* top for new function */ | ||
| 541 | lua_assert(ci->top <= L->stack_last); | ||
| 542 | ci->u.l.savedpc = p->code; /* starting point */ | ||
| 543 | ci->callstatus |= CIST_TAIL; | ||
| 544 | L->top = func + narg1; /* set top */ | ||
| 545 | return -1; | ||
| 546 | } | ||
| 547 | default: { /* not a function */ | ||
| 548 | func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ | ||
| 549 | /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */ | ||
| 550 | narg1++; | ||
| 551 | goto retry; /* try again */ | ||
| 552 | } | ||
| 553 | } | ||
| 554 | } | ||
| 555 | |||
| 556 | |||
| 557 | /* | ||
| 514 | ** Prepares the call to a function (C or Lua). For C functions, also do | 558 | ** Prepares the call to a function (C or Lua). For C functions, also do |
| 515 | ** the call. The function to be called is at '*func'. The arguments | 559 | ** the call. The function to be called is at '*func'. The arguments |
| 516 | ** are on the stack, right after the function. Returns the CallInfo | 560 | ** are on the stack, right after the function. Returns the CallInfo |
| @@ -519,32 +563,14 @@ l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret, | |||
| 519 | ** original function position. | 563 | ** original function position. |
| 520 | */ | 564 | */ |
| 521 | CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | 565 | CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { |
| 522 | lua_CFunction f; | ||
| 523 | retry: | 566 | retry: |
| 524 | switch (ttypetag(s2v(func))) { | 567 | switch (ttypetag(s2v(func))) { |
| 525 | case LUA_VCCL: /* C closure */ | 568 | case LUA_VCCL: /* C closure */ |
| 526 | f = clCvalue(s2v(func))->f; | 569 | precallC(L, func, nresults, clCvalue(s2v(func))->f); |
| 527 | goto Cfunc; | 570 | return NULL; |
| 528 | case LUA_VLCF: /* light C function */ | 571 | case LUA_VLCF: /* light C function */ |
| 529 | f = fvalue(s2v(func)); | 572 | precallC(L, func, nresults, fvalue(s2v(func))); |
| 530 | Cfunc: { | ||
| 531 | int n; /* number of returns */ | ||
| 532 | CallInfo *ci; | ||
| 533 | checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ | ||
| 534 | L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, | ||
| 535 | L->top + LUA_MINSTACK); | ||
| 536 | lua_assert(ci->top <= L->stack_last); | ||
| 537 | if (l_unlikely(L->hookmask & LUA_MASKCALL)) { | ||
| 538 | int narg = cast_int(L->top - func) - 1; | ||
| 539 | luaD_hook(L, LUA_HOOKCALL, -1, 1, narg); | ||
| 540 | } | ||
| 541 | lua_unlock(L); | ||
| 542 | n = (*f)(L); /* do the actual call */ | ||
| 543 | lua_lock(L); | ||
| 544 | api_checknelems(L, n); | ||
| 545 | luaD_poscall(L, ci, n); | ||
| 546 | return NULL; | 573 | return NULL; |
| 547 | } | ||
| 548 | case LUA_VLCL: { /* Lua function */ | 574 | case LUA_VLCL: { /* Lua function */ |
| 549 | CallInfo *ci; | 575 | CallInfo *ci; |
| 550 | Proto *p = clLvalue(s2v(func))->p; | 576 | Proto *p = clLvalue(s2v(func))->p; |
| @@ -561,6 +587,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | |||
| 561 | } | 587 | } |
| 562 | default: { /* not a function */ | 588 | default: { /* not a function */ |
| 563 | func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ | 589 | func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ |
| 590 | /* return luaD_precall(L, func, nresults); */ | ||
| 564 | goto retry; /* try again with metamethod */ | 591 | goto retry; /* try again with metamethod */ |
| 565 | } | 592 | } |
| 566 | } | 593 | } |
| @@ -733,11 +760,10 @@ static void resume (lua_State *L, void *ud) { | |||
| 733 | StkId firstArg = L->top - n; /* first argument */ | 760 | StkId firstArg = L->top - n; /* first argument */ |
| 734 | CallInfo *ci = L->ci; | 761 | CallInfo *ci = L->ci; |
| 735 | if (L->status == LUA_OK) /* starting a coroutine? */ | 762 | if (L->status == LUA_OK) /* starting a coroutine? */ |
| 736 | ccall(L, firstArg - 1, LUA_MULTRET, 1); /* just call its body */ | 763 | ccall(L, firstArg - 1, LUA_MULTRET, 0); /* just call its body */ |
| 737 | else { /* resuming from previous yield */ | 764 | else { /* resuming from previous yield */ |
| 738 | lua_assert(L->status == LUA_YIELD); | 765 | lua_assert(L->status == LUA_YIELD); |
| 739 | L->status = LUA_OK; /* mark that it is running (again) */ | 766 | L->status = LUA_OK; /* mark that it is running (again) */ |
| 740 | luaE_incCstack(L); /* control the C stack */ | ||
| 741 | if (isLua(ci)) { /* yielded inside a hook? */ | 767 | if (isLua(ci)) { /* yielded inside a hook? */ |
| 742 | L->top = firstArg; /* discard arguments */ | 768 | L->top = firstArg; /* discard arguments */ |
| 743 | luaV_execute(L, ci); /* just continue running Lua code */ | 769 | luaV_execute(L, ci); /* just continue running Lua code */ |
| @@ -788,6 +814,9 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, | |||
| 788 | else if (L->status != LUA_YIELD) /* ended with errors? */ | 814 | else if (L->status != LUA_YIELD) /* ended with errors? */ |
| 789 | return resume_error(L, "cannot resume dead coroutine", nargs); | 815 | return resume_error(L, "cannot resume dead coroutine", nargs); |
| 790 | L->nCcalls = (from) ? getCcalls(from) : 0; | 816 | L->nCcalls = (from) ? getCcalls(from) : 0; |
| 817 | if (getCcalls(L) >= LUAI_MAXCCALLS) | ||
| 818 | return resume_error(L, "C stack overflow", nargs); | ||
| 819 | L->nCcalls++; | ||
| 791 | luai_userstateresume(L, nargs); | 820 | luai_userstateresume(L, nargs); |
| 792 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); | 821 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); |
| 793 | status = luaD_rawrunprotected(L, resume, &nargs); | 822 | status = luaD_rawrunprotected(L, resume, &nargs); |
diff --git a/src/3rdParty/lua/ldo.h b/src/3rdParty/lua/ldo.h index 9fb772f..911e67f 100644 --- a/src/3rdParty/lua/ldo.h +++ b/src/3rdParty/lua/ldo.h | |||
| @@ -58,7 +58,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, | 58 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, |
| 59 | int fTransfer, int nTransfer); | 59 | int fTransfer, int nTransfer); |
| 60 | LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); | 60 | 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); | 61 | LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1, int delta); |
| 62 | LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); | 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); | 63 | 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); | 64 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); |
diff --git a/src/3rdParty/lua/lstate.c b/src/3rdParty/lua/lstate.c index bfc5902..5cb0847 100644 --- a/src/3rdParty/lua/lstate.c +++ b/src/3rdParty/lua/lstate.c | |||
| @@ -166,7 +166,7 @@ void luaE_checkcstack (lua_State *L) { | |||
| 166 | if (getCcalls(L) == LUAI_MAXCCALLS) | 166 | if (getCcalls(L) == LUAI_MAXCCALLS) |
| 167 | luaG_runerror(L, "C stack overflow"); | 167 | luaG_runerror(L, "C stack overflow"); |
| 168 | else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11)) | 168 | else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11)) |
| 169 | luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ | 169 | luaD_throw(L, LUA_ERRERR); /* error while handling stack error */ |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | 172 | ||
| @@ -330,13 +330,13 @@ int luaE_resetthread (lua_State *L, int status) { | |||
| 330 | ci->callstatus = CIST_C; | 330 | ci->callstatus = CIST_C; |
| 331 | if (status == LUA_YIELD) | 331 | if (status == LUA_YIELD) |
| 332 | status = LUA_OK; | 332 | status = LUA_OK; |
| 333 | L->status = LUA_OK; /* so it can run __close metamethods */ | ||
| 333 | status = luaD_closeprotected(L, 1, status); | 334 | status = luaD_closeprotected(L, 1, status); |
| 334 | if (status != LUA_OK) /* errors? */ | 335 | if (status != LUA_OK) /* errors? */ |
| 335 | luaD_seterrorobj(L, status, L->stack + 1); | 336 | luaD_seterrorobj(L, status, L->stack + 1); |
| 336 | else | 337 | else |
| 337 | L->top = L->stack + 1; | 338 | L->top = L->stack + 1; |
| 338 | ci->top = L->top + LUA_MINSTACK; | 339 | ci->top = L->top + LUA_MINSTACK; |
| 339 | L->status = cast_byte(status); | ||
| 340 | luaD_reallocstack(L, cast_int(ci->top - L->stack), 0); | 340 | luaD_reallocstack(L, cast_int(ci->top - L->stack), 0); |
| 341 | return status; | 341 | return status; |
| 342 | } | 342 | } |
diff --git a/src/3rdParty/lua/lvm.c b/src/3rdParty/lua/lvm.c index 49ed3dd..2ec3440 100644 --- a/src/3rdParty/lua/lvm.c +++ b/src/3rdParty/lua/lvm.c | |||
| @@ -1643,6 +1643,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1643 | } | 1643 | } |
| 1644 | vmcase(OP_TAILCALL) { | 1644 | vmcase(OP_TAILCALL) { |
| 1645 | int b = GETARG_B(i); /* number of arguments + 1 (function) */ | 1645 | int b = GETARG_B(i); /* number of arguments + 1 (function) */ |
| 1646 | int n; /* number of results when calling a C function */ | ||
| 1646 | int nparams1 = GETARG_C(i); | 1647 | int nparams1 = GETARG_C(i); |
| 1647 | /* delta is virtual 'func' - real 'func' (vararg functions) */ | 1648 | /* delta is virtual 'func' - real 'func' (vararg functions) */ |
| 1648 | int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; | 1649 | int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0; |
| @@ -1656,24 +1657,14 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
| 1656 | lua_assert(L->tbclist < base); /* no pending tbc variables */ | 1657 | lua_assert(L->tbclist < base); /* no pending tbc variables */ |
| 1657 | lua_assert(base == ci->func + 1); | 1658 | lua_assert(base == ci->func + 1); |
| 1658 | } | 1659 | } |
| 1659 | while (!ttisfunction(s2v(ra))) { /* not a function? */ | 1660 | if ((n = luaD_pretailcall(L, ci, ra, b, delta)) < 0) /* Lua function? */ |
| 1660 | ra = luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ | 1661 | goto startfunc; /* execute the callee */ |
| 1661 | b++; /* there is now one extra argument */ | 1662 | else { /* C function? */ |
| 1662 | } | ||
| 1663 | if (!ttisLclosure(s2v(ra))) { /* C function? */ | ||
| 1664 | luaD_precall(L, ra, LUA_MULTRET); /* call it */ | ||
| 1665 | updatetrap(ci); | ||
| 1666 | updatestack(ci); /* stack may have been relocated */ | ||
| 1667 | ci->func -= delta; /* restore 'func' (if vararg) */ | 1663 | ci->func -= delta; /* restore 'func' (if vararg) */ |
| 1668 | luaD_poscall(L, ci, cast_int(L->top - ra)); /* finish caller */ | 1664 | luaD_poscall(L, ci, n); /* finish caller */ |
| 1669 | updatetrap(ci); /* 'luaD_poscall' can change hooks */ | 1665 | updatetrap(ci); /* 'luaD_poscall' can change hooks */ |
| 1670 | goto ret; /* caller returns after the tail call */ | 1666 | goto ret; /* caller returns after the tail call */ |
| 1671 | } | 1667 | } |
| 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 | } | ||
| 1677 | } | 1668 | } |
| 1678 | vmcase(OP_RETURN) { | 1669 | vmcase(OP_RETURN) { |
| 1679 | int n = GETARG_B(i) - 1; /* number of results */ | 1670 | int n = GETARG_B(i) - 1; /* number of results */ |
