diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-25 12:59:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-25 12:59:42 -0300 |
commit | 32bf6c9b277d04a35591ca6420cf1518ebc1a7f3 (patch) | |
tree | d0d2cf99489a745e5d54f9a4779629b5095c47f1 /ldebug.c | |
parent | 9c43d6a24e2612504686f9efbade264e2246bbfb (diff) | |
download | lua-32bf6c9b277d04a35591ca6420cf1518ebc1a7f3.tar.gz lua-32bf6c9b277d04a35591ca6420cf1518ebc1a7f3.tar.bz2 lua-32bf6c9b277d04a35591ca6420cf1518ebc1a7f3.zip |
functions 'traceexec', 'callTM', and 'call_binTM' moved to other
files to make 'lvm.c' a little smaller
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.89 2012/01/20 22:05:50 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.90 2012/08/16 17:34:28 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -578,3 +578,36 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { | |||
578 | luaG_errormsg(L); | 578 | luaG_errormsg(L); |
579 | } | 579 | } |
580 | 580 | ||
581 | |||
582 | void luaG_traceexec (lua_State *L) { | ||
583 | CallInfo *ci = L->ci; | ||
584 | lu_byte mask = L->hookmask; | ||
585 | int counthook = ((mask & LUA_MASKCOUNT) && L->hookcount == 0); | ||
586 | if (counthook) | ||
587 | resethookcount(L); /* reset count */ | ||
588 | if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ | ||
589 | ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ | ||
590 | return; /* do not call hook again (VM yielded, so it did not move) */ | ||
591 | } | ||
592 | if (counthook) | ||
593 | luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ | ||
594 | if (mask & LUA_MASKLINE) { | ||
595 | Proto *p = ci_func(ci)->p; | ||
596 | int npc = pcRel(ci->u.l.savedpc, p); | ||
597 | int newline = getfuncline(p, npc); | ||
598 | if (npc == 0 || /* call linehook when enter a new function, */ | ||
599 | ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ | ||
600 | newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ | ||
601 | luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ | ||
602 | } | ||
603 | L->oldpc = ci->u.l.savedpc; | ||
604 | if (L->status == LUA_YIELD) { /* did hook yield? */ | ||
605 | if (counthook) | ||
606 | L->hookcount = 1; /* undo decrement to zero */ | ||
607 | ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ | ||
608 | ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ | ||
609 | ci->func = L->top - 1; /* protect stack below results */ | ||
610 | luaD_throw(L, LUA_YIELD); | ||
611 | } | ||
612 | } | ||
613 | |||