aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/lua/ldebug.c
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2024-10-19 00:35:11 +0800
committerLi Jin <dragon-fly@qq.com>2024-10-19 00:35:11 +0800
commit1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0 (patch)
tree8bd3fbeb396fd2fce6e5b34c3ee10f4923feca72 /src/3rdParty/lua/ldebug.c
parent05da3cbfa3689e6c229c41156d0dd08ab554cd77 (diff)
downloadyuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.tar.gz
yuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.tar.bz2
yuescript-1334c0ae67fdf4cb1377e0e7a3ef291f5cf694c0.zip
Fixed issue #174.
Diffstat (limited to 'src/3rdParty/lua/ldebug.c')
-rw-r--r--src/3rdParty/lua/ldebug.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/3rdParty/lua/ldebug.c b/src/3rdParty/lua/ldebug.c
index b1f16ac..591b352 100644
--- a/src/3rdParty/lua/ldebug.c
+++ b/src/3rdParty/lua/ldebug.c
@@ -31,7 +31,7 @@
31 31
32 32
33 33
34#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_VCCL) 34#define LuaClosure(f) ((f) != NULL && (f)->c.tt == LUA_VLCL)
35 35
36 36
37static const char *funcnamefromcall (lua_State *L, CallInfo *ci, 37static const char *funcnamefromcall (lua_State *L, CallInfo *ci,
@@ -254,7 +254,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
254 254
255 255
256static void funcinfo (lua_Debug *ar, Closure *cl) { 256static void funcinfo (lua_Debug *ar, Closure *cl) {
257 if (noLuaClosure(cl)) { 257 if (!LuaClosure(cl)) {
258 ar->source = "=[C]"; 258 ar->source = "=[C]";
259 ar->srclen = LL("=[C]"); 259 ar->srclen = LL("=[C]");
260 ar->linedefined = -1; 260 ar->linedefined = -1;
@@ -288,29 +288,31 @@ static int nextline (const Proto *p, int currentline, int pc) {
288 288
289 289
290static void collectvalidlines (lua_State *L, Closure *f) { 290static void collectvalidlines (lua_State *L, Closure *f) {
291 if (noLuaClosure(f)) { 291 if (!LuaClosure(f)) {
292 setnilvalue(s2v(L->top.p)); 292 setnilvalue(s2v(L->top.p));
293 api_incr_top(L); 293 api_incr_top(L);
294 } 294 }
295 else { 295 else {
296 int i;
297 TValue v;
298 const Proto *p = f->l.p; 296 const Proto *p = f->l.p;
299 int currentline = p->linedefined; 297 int currentline = p->linedefined;
300 Table *t = luaH_new(L); /* new table to store active lines */ 298 Table *t = luaH_new(L); /* new table to store active lines */
301 sethvalue2s(L, L->top.p, t); /* push it on stack */ 299 sethvalue2s(L, L->top.p, t); /* push it on stack */
302 api_incr_top(L); 300 api_incr_top(L);
303 setbtvalue(&v); /* boolean 'true' to be the value of all indices */ 301 if (p->lineinfo != NULL) { /* proto with debug information? */
304 if (!p->is_vararg) /* regular function? */ 302 int i;
305 i = 0; /* consider all instructions */ 303 TValue v;
306 else { /* vararg function */ 304 setbtvalue(&v); /* boolean 'true' to be the value of all indices */
307 lua_assert(GET_OPCODE(p->code[0]) == OP_VARARGPREP); 305 if (!p->is_vararg) /* regular function? */
308 currentline = nextline(p, currentline, 0); 306 i = 0; /* consider all instructions */
309 i = 1; /* skip first instruction (OP_VARARGPREP) */ 307 else { /* vararg function */
310 } 308 lua_assert(GET_OPCODE(p->code[0]) == OP_VARARGPREP);
311 for (; i < p->sizelineinfo; i++) { /* for each instruction */ 309 currentline = nextline(p, currentline, 0);
312 currentline = nextline(p, currentline, i); /* get its line */ 310 i = 1; /* skip first instruction (OP_VARARGPREP) */
313 luaH_setint(L, t, currentline, &v); /* table[line] = true */ 311 }
312 for (; i < p->sizelineinfo; i++) { /* for each instruction */
313 currentline = nextline(p, currentline, i); /* get its line */
314 luaH_setint(L, t, currentline, &v); /* table[line] = true */
315 }
314 } 316 }
315 } 317 }
316} 318}
@@ -339,7 +341,7 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
339 } 341 }
340 case 'u': { 342 case 'u': {
341 ar->nups = (f == NULL) ? 0 : f->c.nupvalues; 343 ar->nups = (f == NULL) ? 0 : f->c.nupvalues;
342 if (noLuaClosure(f)) { 344 if (!LuaClosure(f)) {
343 ar->isvararg = 1; 345 ar->isvararg = 1;
344 ar->nparams = 0; 346 ar->nparams = 0;
345 } 347 }
@@ -925,12 +927,12 @@ int luaG_traceexec (lua_State *L, const Instruction *pc) {
925 } 927 }
926 pc++; /* reference is always next instruction */ 928 pc++; /* reference is always next instruction */
927 ci->u.l.savedpc = pc; /* save 'pc' */ 929 ci->u.l.savedpc = pc; /* save 'pc' */
928 counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT)); 930 counthook = (mask & LUA_MASKCOUNT) && (--L->hookcount == 0);
929 if (counthook) 931 if (counthook)
930 resethookcount(L); /* reset count */ 932 resethookcount(L); /* reset count */
931 else if (!(mask & LUA_MASKLINE)) 933 else if (!(mask & LUA_MASKLINE))
932 return 1; /* no line hook and count != 0; nothing to be done now */ 934 return 1; /* no line hook and count != 0; nothing to be done now */
933 if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ 935 if (ci->callstatus & CIST_HOOKYIELD) { /* hook yielded last time? */
934 ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ 936 ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */
935 return 1; /* do not call hook again (VM yielded, so it did not move) */ 937 return 1; /* do not call hook again (VM yielded, so it did not move) */
936 } 938 }
@@ -952,7 +954,6 @@ int luaG_traceexec (lua_State *L, const Instruction *pc) {
952 if (L->status == LUA_YIELD) { /* did hook yield? */ 954 if (L->status == LUA_YIELD) { /* did hook yield? */
953 if (counthook) 955 if (counthook)
954 L->hookcount = 1; /* undo decrement to zero */ 956 L->hookcount = 1; /* undo decrement to zero */
955 ci->u.l.savedpc--; /* undo increment (resume will increment it again) */
956 ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ 957 ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */
957 luaD_throw(L, LUA_YIELD); 958 luaD_throw(L, LUA_YIELD);
958 } 959 }