commit 9a0f0dcc77adbde0618af1f10e5d430f42b76cc2
parent 751cd867d3e0338279fa6f3390c8b7ddc0108659
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 2 May 2002 10:05:58 -0300
precompiler may create functions without `lineinfo'
Diffstat:
5 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/ldebug.c b/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 1.109 2002/04/22 14:40:23 roberto Exp roberto $
+** $Id: ldebug.c,v 1.110 2002/04/24 20:07:46 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -48,7 +48,7 @@ static int currentline (lua_State *L, CallInfo *ci) {
if (pc < 0)
return -1; /* only active lua functions have current-line information */
else
- return ci_func(ci)->l.p->lineinfo[pc];
+ return getline(ci_func(ci)->l.p, pc);
}
diff --git a/ldebug.h b/ldebug.h
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.h,v 1.18 2002/03/25 17:47:14 roberto Exp roberto $
+** $Id: ldebug.h,v 1.19 2002/04/10 12:11:07 roberto Exp roberto $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
@@ -14,6 +14,8 @@
#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
+#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
+
void luaG_typeerror (lua_State *L, const TObject *o, const char *opname);
void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2);
diff --git a/lfunc.c b/lfunc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lfunc.c,v 1.54 2002/03/05 12:42:47 roberto Exp roberto $
+** $Id: lfunc.c,v 1.55 2002/03/25 17:47:14 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@@ -98,7 +98,8 @@ Proto *luaF_newproto (lua_State *L) {
void luaF_freeproto (lua_State *L, Proto *f) {
luaM_freearray(L, f->code, f->sizecode, Instruction);
- luaM_freearray(L, f->lineinfo, f->sizecode, int);
+ if (f->lineinfo)
+ luaM_freearray(L, f->lineinfo, f->sizecode, int);
luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
luaM_freearray(L, f->k, f->sizek, TObject);
luaM_freearray(L, f->p, f->sizep, Proto *);
diff --git a/ltests.c b/ltests.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltests.c,v 1.117 2002/04/24 20:07:46 roberto Exp roberto $
+** $Id: ltests.c,v 1.118 2002/05/01 20:40:42 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@@ -144,7 +144,7 @@ static char *buildop (Proto *p, int pc, char *buff) {
Instruction i = p->code[pc];
OpCode o = GET_OPCODE(i);
const char *name = luaP_opnames[o];
- int line = p->lineinfo[pc];
+ int line = getline(p, pc);
sprintf(buff, "(%4d) %4d - ", line, pc);
switch (getOpMode(o)) {
case iABC:
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.226 2002/04/22 14:40:23 roberto Exp roberto $
+** $Id: lvm.c,v 1.227 2002/04/24 20:07:46 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -65,11 +65,11 @@ int luaV_tostring (lua_State *L, TObject *obj) {
static void traceexec (lua_State *L) {
CallInfo *ci = L->ci;
Proto *p = ci_func(ci)->l.p;
- int newline = p->lineinfo[pcRel(*ci->pc, p)];
+ int newline = getline(p, pcRel(*ci->pc, p));
if (pcRel(*ci->pc, p) == 0) /* tracing may be starting now? */
ci->savedpc = *ci->pc; /* initialize `savedpc' */
/* calls linehook when enters a new line or jumps back (loop) */
- if (*ci->pc <= ci->savedpc || newline != p->lineinfo[pcRel(ci->savedpc, p)]) {
+ if (*ci->pc <= ci->savedpc || newline != getline(p, pcRel(ci->savedpc, p))) {
luaD_lineHook(L, newline);
ci = L->ci; /* previous call may reallocate `ci' */
}