aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/ldo.c b/ldo.c
index 1d1b7a71..d63c8267 100644
--- a/ldo.c
+++ b/ldo.c
@@ -357,7 +357,6 @@ void luaD_hook (lua_State *L, int event, int line,
357 int ftransfer, int ntransfer) { 357 int ftransfer, int ntransfer) {
358 lua_Hook hook = L->hook; 358 lua_Hook hook = L->hook;
359 if (hook && L->allowhook) { /* make sure there is a hook */ 359 if (hook && L->allowhook) { /* make sure there is a hook */
360 unsigned mask = CIST_HOOKED;
361 CallInfo *ci = L->ci; 360 CallInfo *ci = L->ci;
362 ptrdiff_t top = savestack(L, L->top.p); /* preserve original 'top' */ 361 ptrdiff_t top = savestack(L, L->top.p); /* preserve original 'top' */
363 ptrdiff_t ci_top = savestack(L, ci->top.p); /* idem for 'ci->top' */ 362 ptrdiff_t ci_top = savestack(L, ci->top.p); /* idem for 'ci->top' */
@@ -365,18 +364,15 @@ void luaD_hook (lua_State *L, int event, int line,
365 ar.event = event; 364 ar.event = event;
366 ar.currentline = line; 365 ar.currentline = line;
367 ar.i_ci = ci; 366 ar.i_ci = ci;
368 if (ntransfer != 0) { 367 L->transferinfo.ftransfer = ftransfer;
369 mask |= CIST_TRAN; /* 'ci' has transfer information */ 368 L->transferinfo.ntransfer = ntransfer;
370 ci->u2.transferinfo.ftransfer = ftransfer;
371 ci->u2.transferinfo.ntransfer = ntransfer;
372 }
373 if (isLua(ci) && L->top.p < ci->top.p) 369 if (isLua(ci) && L->top.p < ci->top.p)
374 L->top.p = ci->top.p; /* protect entire activation register */ 370 L->top.p = ci->top.p; /* protect entire activation register */
375 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ 371 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
376 if (ci->top.p < L->top.p + LUA_MINSTACK) 372 if (ci->top.p < L->top.p + LUA_MINSTACK)
377 ci->top.p = L->top.p + LUA_MINSTACK; 373 ci->top.p = L->top.p + LUA_MINSTACK;
378 L->allowhook = 0; /* cannot call hooks inside a hook */ 374 L->allowhook = 0; /* cannot call hooks inside a hook */
379 ci->callstatus |= mask; 375 ci->callstatus |= CIST_HOOKED;
380 lua_unlock(L); 376 lua_unlock(L);
381 (*hook)(L, &ar); 377 (*hook)(L, &ar);
382 lua_lock(L); 378 lua_lock(L);
@@ -384,7 +380,7 @@ void luaD_hook (lua_State *L, int event, int line,
384 L->allowhook = 1; 380 L->allowhook = 1;
385 ci->top.p = restorestack(L, ci_top); 381 ci->top.p = restorestack(L, ci_top);
386 L->top.p = restorestack(L, top); 382 L->top.p = restorestack(L, top);
387 ci->callstatus &= ~mask; 383 ci->callstatus &= ~CIST_HOOKED;
388 } 384 }
389} 385}
390 386
@@ -525,7 +521,7 @@ void luaD_poscall (lua_State *L, CallInfo *ci, int nres) {
525 moveresults(L, ci->func.p, nres, fwanted); 521 moveresults(L, ci->func.p, nres, fwanted);
526 /* function cannot be in any of these cases when returning */ 522 /* function cannot be in any of these cases when returning */
527 lua_assert(!(ci->callstatus & 523 lua_assert(!(ci->callstatus &
528 (CIST_HOOKED | CIST_YPCALL | CIST_FIN | CIST_TRAN | CIST_CLSRET))); 524 (CIST_HOOKED | CIST_YPCALL | CIST_FIN | CIST_CLSRET)));
529 L->ci = ci->previous; /* back to caller (after closing variables) */ 525 L->ci = ci->previous; /* back to caller (after closing variables) */
530} 526}
531 527