From 448517e47e40814f6ee12eae8dd6c3120f1d48bb Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 18 Jan 2002 15:39:06 -0200 Subject: no more linehook field in CallInfo --- ldo.c | 4 ++-- lstate.h | 1 - lvm.c | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ldo.c b/ldo.c index e5fbc5f3..a9bb5ec1 100644 --- a/ldo.c +++ b/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 ** 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 */ StkId base = func+1; Proto *p = cl->p; - ci->linehook = L->linehook; ci->savedpc = p->code; /* starting point */ if (p->is_vararg) /* varargs? */ adjust_varargs(L, base, p->numparams); if (base > L->stack_last - p->maxstacksize) luaD_stackerror(L); + ci->line = 0; ci->top = base + p->maxstacksize; while (L->top < ci->top) setnilvalue(L->top++); diff --git a/lstate.h b/lstate.h index 978ffbc1..a90daa5f 100644 --- a/lstate.h +++ b/lstate.h @@ -82,7 +82,6 @@ typedef struct stringtable { typedef struct CallInfo { StkId base; /* base for called function */ const Instruction *savedpc; - lua_Hook linehook; StkId top; /* top for this function (when it's a Lua function) */ const Instruction **pc; /* extra information for line tracing */ diff --git a/lvm.c b/lvm.c index b51ea0e0..0a980f7d 100644 --- a/lvm.c +++ b/lvm.c @@ -66,10 +66,17 @@ static void traceexec (lua_State *L, lua_Hook linehook) { int *lineinfo = ci_func(ci)->l.p->lineinfo; int pc = cast(int, *ci->pc - ci_func(ci)->l.p->code) - 1; int newline; - if (pc == 0) { /* may be first time? */ - ci->line = 1; - ci->refi = 0; - ci->lastpc = pc+1; /* make sure it will call linehook */ + 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->refi = 0; + 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); /* calls linehook when enters a new line or jumps back (loop) */ @@ -315,7 +322,7 @@ StkId luaV_execute (lua_State *L) { base = L->ci->base; cl = &clvalue(base - 1)->l; k = cl->p->k; - linehook = L->ci->linehook; + linehook = L->linehook; L->ci->pc = &pc; pc = L->ci->savedpc; L->ci->savedpc = NULL; @@ -513,7 +520,6 @@ StkId luaV_execute (lua_State *L) { int nresults; lua_assert(ttype(ci->base-1) == LUA_TFUNCTION); base = ci->base; /* restore previous values */ - linehook = ci->linehook; cl = &clvalue(base - 1)->l; k = cl->p->k; pc = ci->savedpc; -- cgit v1.2.3-55-g6feb