summaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-11-18 13:24:11 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-11-18 13:24:11 -0200
commit9bab2cf55d9b151d730c1461e3882a5fbc7d790d (patch)
treec264480215e163b96fe1d44d874648ee39cc3cfa /lvm.c
parentc4ae00a3d107a27d80bd157a135ef115104f98f0 (diff)
downloadlua-9bab2cf55d9b151d730c1461e3882a5fbc7d790d.tar.gz
lua-9bab2cf55d9b151d730c1461e3882a5fbc7d790d.tar.bz2
lua-9bab2cf55d9b151d730c1461e3882a5fbc7d790d.zip
support for yield inside hooks
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lvm.c b/lvm.c
index e9f122d0..29dcc56d 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.261 2002/11/14 16:15:53 roberto Exp roberto $ 2** $Id: lvm.c,v 1.262 2002/11/18 11:01:55 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -393,8 +393,14 @@ StkId luaV_execute (lua_State *L) {
393 const Instruction i = *pc++; 393 const Instruction i = *pc++;
394 StkId ra; 394 StkId ra;
395 if (L->hookmask >= LUA_MASKLINE && 395 if (L->hookmask >= LUA_MASKLINE &&
396 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) 396 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
397 traceexec(L); 397 traceexec(L);
398 if (L->ci->state & CI_YIELD) { /* did hook yield? */
399 L->ci->u.l.savedpc = pc - 1;
400 L->ci->state |= CI_SAVEDPC;
401 return NULL;
402 }
403 }
398 /* warning!! several calls may realloc the stack and invalidate `ra' */ 404 /* warning!! several calls may realloc the stack and invalidate `ra' */
399 ra = RA(i); 405 ra = RA(i);
400 lua_assert(L->top <= L->stack + L->stacksize && L->top >= L->ci->base); 406 lua_assert(L->top <= L->stack + L->stacksize && L->top >= L->ci->base);
@@ -595,8 +601,7 @@ StkId luaV_execute (lua_State *L) {
595 if (firstResult) { 601 if (firstResult) {
596 if (firstResult > L->top) { /* yield? */ 602 if (firstResult > L->top) { /* yield? */
597 (L->ci - 1)->u.l.savedpc = pc; 603 (L->ci - 1)->u.l.savedpc = pc;
598 (L->ci - 1)->state = CI_SAVEDPC; 604 (L->ci - 1)->state |= CI_SAVEDPC;
599 L->ci->state |= CI_YIELD;
600 return NULL; 605 return NULL;
601 } 606 }
602 /* it was a C function (`precall' called it); adjust results */ 607 /* it was a C function (`precall' called it); adjust results */