Browse Source

no more linehook field in CallInfo

v5-2
Roberto Ierusalimschy 23 years ago
parent
commit
448517e47e
  1. 4
      ldo.c
  2. 1
      lstate.h
  3. 12
      lvm.c

4
ldo.c

@ -1,5 +1,5 @@
/* /*
** $Id: ldo.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ ** $Id: ldo.c,v 1.154 2002/01/11 20:27:41 roberto Exp $
** Stack and Call structure of Lua ** Stack and Call structure of Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -148,12 +148,12 @@ StkId luaD_precall (lua_State *L, StkId func) {
if (!cl->isC) { /* Lua function? prepare its call */ if (!cl->isC) { /* Lua function? prepare its call */
StkId base = func+1; StkId base = func+1;
Proto *p = cl->p; Proto *p = cl->p;
ci->linehook = L->linehook;
ci->savedpc = p->code; /* starting point */ ci->savedpc = p->code; /* starting point */
if (p->is_vararg) /* varargs? */ if (p->is_vararg) /* varargs? */
adjust_varargs(L, base, p->numparams); adjust_varargs(L, base, p->numparams);
if (base > L->stack_last - p->maxstacksize) if (base > L->stack_last - p->maxstacksize)
luaD_stackerror(L); luaD_stackerror(L);
ci->line = 0;
ci->top = base + p->maxstacksize; ci->top = base + p->maxstacksize;
while (L->top < ci->top) while (L->top < ci->top)
setnilvalue(L->top++); setnilvalue(L->top++);

1
lstate.h

@ -82,7 +82,6 @@ typedef struct stringtable {
typedef struct CallInfo { typedef struct CallInfo {
StkId base; /* base for called function */ StkId base; /* base for called function */
const Instruction *savedpc; const Instruction *savedpc;
lua_Hook linehook;
StkId top; /* top for this function (when it's a Lua function) */ StkId top; /* top for this function (when it's a Lua function) */
const Instruction **pc; const Instruction **pc;
/* extra information for line tracing */ /* extra information for line tracing */

12
lvm.c

@ -66,11 +66,18 @@ static void traceexec (lua_State *L, lua_Hook linehook) {
int *lineinfo = ci_func(ci)->l.p->lineinfo; int *lineinfo = ci_func(ci)->l.p->lineinfo;
int pc = cast(int, *ci->pc - ci_func(ci)->l.p->code) - 1; int pc = cast(int, *ci->pc - ci_func(ci)->l.p->code) - 1;
int newline; int newline;
if (pc == 0) { /* may be first time? */ if (ci->line == -1) return; /* no linehooks for this function */
else if (ci->line == 0) { /* first linehook? */
if (pc == 0) { /* function is starting now? */
ci->line = 1; ci->line = 1;
ci->refi = 0; ci->refi = 0;
ci->lastpc = pc+1; /* make sure it will call linehook */ ci->lastpc = pc+1; /* make sure it will call linehook */
} }
else { /* function started without hooks: */
ci->line = -1; /* keep it that way */
return;
}
}
newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi); newline = luaG_getline(lineinfo, pc, ci->line, &ci->refi);
/* calls linehook when enters a new line or jumps back (loop) */ /* calls linehook when enters a new line or jumps back (loop) */
if (newline != ci->line || pc <= ci->lastpc) { if (newline != ci->line || pc <= ci->lastpc) {
@ -315,7 +322,7 @@ StkId luaV_execute (lua_State *L) {
base = L->ci->base; base = L->ci->base;
cl = &clvalue(base - 1)->l; cl = &clvalue(base - 1)->l;
k = cl->p->k; k = cl->p->k;
linehook = L->ci->linehook; linehook = L->linehook;
L->ci->pc = &pc; L->ci->pc = &pc;
pc = L->ci->savedpc; pc = L->ci->savedpc;
L->ci->savedpc = NULL; L->ci->savedpc = NULL;
@ -513,7 +520,6 @@ StkId luaV_execute (lua_State *L) {
int nresults; int nresults;
lua_assert(ttype(ci->base-1) == LUA_TFUNCTION); lua_assert(ttype(ci->base-1) == LUA_TFUNCTION);
base = ci->base; /* restore previous values */ base = ci->base; /* restore previous values */
linehook = ci->linehook;
cl = &clvalue(base - 1)->l; cl = &clvalue(base - 1)->l;
k = cl->p->k; k = cl->p->k;
pc = ci->savedpc; pc = ci->savedpc;

Loading…
Cancel
Save