diff options
author | Li Jin <dragon-fly@qq.com> | 2020-07-18 16:45:50 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2020-07-18 16:45:50 +0800 |
commit | 8c596dc1efa8a1267c222b168a4de9c8ba254760 (patch) | |
tree | 699c748e101a48ae267b5f7b19adbfea15f3934e /src/lua/lvm.c | |
parent | 8ab0038c09a79fa8401bb10b7a31d03ef5380417 (diff) | |
download | yuescript-8c596dc1efa8a1267c222b168a4de9c8ba254760.tar.gz yuescript-8c596dc1efa8a1267c222b168a4de9c8ba254760.tar.bz2 yuescript-8c596dc1efa8a1267c222b168a4de9c8ba254760.zip |
fix issue for using return statement with export.
Diffstat (limited to 'src/lua/lvm.c')
-rw-r--r-- | src/lua/lvm.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lua/lvm.c b/src/lua/lvm.c index e7781db..66d451b 100644 --- a/src/lua/lvm.c +++ b/src/lua/lvm.c | |||
@@ -634,7 +634,8 @@ static void copy2buff (StkId top, int n, char *buff) { | |||
634 | ** from 'L->top - total' up to 'L->top - 1'. | 634 | ** from 'L->top - total' up to 'L->top - 1'. |
635 | */ | 635 | */ |
636 | void luaV_concat (lua_State *L, int total) { | 636 | void luaV_concat (lua_State *L, int total) { |
637 | lua_assert(total >= 2); | 637 | if (total == 1) |
638 | return; /* "all" values already concatenated */ | ||
638 | do { | 639 | do { |
639 | StkId top = L->top; | 640 | StkId top = L->top; |
640 | int n = 2; /* number of elements handled in this pass (at least 2) */ | 641 | int n = 2; /* number of elements handled in this pass (at least 2) */ |
@@ -840,10 +841,8 @@ void luaV_finishOp (lua_State *L) { | |||
840 | int a = GETARG_A(inst); /* first element to concatenate */ | 841 | int a = GETARG_A(inst); /* first element to concatenate */ |
841 | int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */ | 842 | int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */ |
842 | setobjs2s(L, top - 2, top); /* put TM result in proper position */ | 843 | setobjs2s(L, top - 2, top); /* put TM result in proper position */ |
843 | if (total > 1) { /* are there elements to concat? */ | 844 | L->top = top - 1; /* top is one after last element (at top-2) */ |
844 | L->top = top - 1; /* top is one after last element (at top-2) */ | 845 | luaV_concat(L, total); /* concat them (may yield again) */ |
845 | luaV_concat(L, total); /* concat them (may yield again) */ | ||
846 | } | ||
847 | break; | 846 | break; |
848 | } | 847 | } |
849 | default: { | 848 | default: { |
@@ -1102,9 +1101,9 @@ void luaV_finishOp (lua_State *L) { | |||
1102 | /* idem, but without changing the stack */ | 1101 | /* idem, but without changing the stack */ |
1103 | #define halfProtectNT(exp) (savepc(L), (exp)) | 1102 | #define halfProtectNT(exp) (savepc(L), (exp)) |
1104 | 1103 | ||
1105 | 1104 | /* 'c' is the limit of live values in the stack */ | |
1106 | #define checkGC(L,c) \ | 1105 | #define checkGC(L,c) \ |
1107 | { luaC_condGC(L, L->top = (c), /* limit of live values */ \ | 1106 | { luaC_condGC(L, (savepc(L), L->top = (c)), \ |
1108 | updatetrap(ci)); \ | 1107 | updatetrap(ci)); \ |
1109 | luai_threadyield(L); } | 1108 | luai_threadyield(L); } |
1110 | 1109 | ||
@@ -1635,7 +1634,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1635 | while (!ttisfunction(s2v(ra))) { /* not a function? */ | 1634 | while (!ttisfunction(s2v(ra))) { /* not a function? */ |
1636 | luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ | 1635 | luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ |
1637 | b++; /* there is now one extra argument */ | 1636 | b++; /* there is now one extra argument */ |
1638 | checkstackp(L, 1, ra); | 1637 | checkstackGCp(L, 1, ra); |
1639 | } | 1638 | } |
1640 | if (!ttisLclosure(s2v(ra))) { /* C function? */ | 1639 | if (!ttisLclosure(s2v(ra))) { /* C function? */ |
1641 | luaD_call(L, ra, LUA_MULTRET); /* call it */ | 1640 | luaD_call(L, ra, LUA_MULTRET); /* call it */ |
@@ -1792,8 +1791,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1792 | vmbreak; | 1791 | vmbreak; |
1793 | } | 1792 | } |
1794 | vmcase(OP_VARARGPREP) { | 1793 | vmcase(OP_VARARGPREP) { |
1795 | luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p); | 1794 | ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p)); |
1796 | updatetrap(ci); | ||
1797 | if (trap) { | 1795 | if (trap) { |
1798 | luaD_hookcall(L, ci); | 1796 | luaD_hookcall(L, ci); |
1799 | L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */ | 1797 | L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */ |