summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldebug.c4
-rw-r--r--ldebug.h4
-rw-r--r--lfunc.c5
-rw-r--r--ltests.c4
-rw-r--r--lvm.c6
5 files changed, 13 insertions, 10 deletions
diff --git a/ldebug.c b/ldebug.c
index 4ee1b05f..8cb5f48b 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.109 2002/04/22 14:40:23 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.110 2002/04/24 20:07:46 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*/
@@ -48,7 +48,7 @@ static int currentline (lua_State *L, CallInfo *ci) {
48 if (pc < 0) 48 if (pc < 0)
49 return -1; /* only active lua functions have current-line information */ 49 return -1; /* only active lua functions have current-line information */
50 else 50 else
51 return ci_func(ci)->l.p->lineinfo[pc]; 51 return getline(ci_func(ci)->l.p, pc);
52} 52}
53 53
54 54
diff --git a/ldebug.h b/ldebug.h
index 4590aeba..1aafbb72 100644
--- a/ldebug.h
+++ b/ldebug.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.h,v 1.18 2002/03/25 17:47:14 roberto Exp roberto $ 2** $Id: ldebug.h,v 1.19 2002/04/10 12:11:07 roberto Exp roberto $
3** Auxiliary functions from Debug Interface module 3** Auxiliary functions from Debug Interface module
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -14,6 +14,8 @@
14 14
15#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
16 16
17#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
18
17void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); 19void luaG_typeerror (lua_State *L, const TObject *o, const char *opname);
18void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 20void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
19void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2); 21void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2);
diff --git a/lfunc.c b/lfunc.c
index 205f39b6..720fb6e4 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.54 2002/03/05 12:42:47 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.55 2002/03/25 17:47:14 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -98,7 +98,8 @@ Proto *luaF_newproto (lua_State *L) {
98 98
99void luaF_freeproto (lua_State *L, Proto *f) { 99void luaF_freeproto (lua_State *L, Proto *f) {
100 luaM_freearray(L, f->code, f->sizecode, Instruction); 100 luaM_freearray(L, f->code, f->sizecode, Instruction);
101 luaM_freearray(L, f->lineinfo, f->sizecode, int); 101 if (f->lineinfo)
102 luaM_freearray(L, f->lineinfo, f->sizecode, int);
102 luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); 103 luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
103 luaM_freearray(L, f->k, f->sizek, TObject); 104 luaM_freearray(L, f->k, f->sizek, TObject);
104 luaM_freearray(L, f->p, f->sizep, Proto *); 105 luaM_freearray(L, f->p, f->sizep, Proto *);
diff --git a/ltests.c b/ltests.c
index b4d81ada..e19cea71 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.117 2002/04/24 20:07:46 roberto Exp roberto $ 2** $Id: ltests.c,v 1.118 2002/05/01 20:40:42 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -144,7 +144,7 @@ static char *buildop (Proto *p, int pc, char *buff) {
144 Instruction i = p->code[pc]; 144 Instruction i = p->code[pc];
145 OpCode o = GET_OPCODE(i); 145 OpCode o = GET_OPCODE(i);
146 const char *name = luaP_opnames[o]; 146 const char *name = luaP_opnames[o];
147 int line = p->lineinfo[pc]; 147 int line = getline(p, pc);
148 sprintf(buff, "(%4d) %4d - ", line, pc); 148 sprintf(buff, "(%4d) %4d - ", line, pc);
149 switch (getOpMode(o)) { 149 switch (getOpMode(o)) {
150 case iABC: 150 case iABC:
diff --git a/lvm.c b/lvm.c
index 49950df6..e44bc7dd 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.226 2002/04/22 14:40:23 roberto Exp roberto $ 2** $Id: lvm.c,v 1.227 2002/04/24 20:07:46 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*/
@@ -65,11 +65,11 @@ int luaV_tostring (lua_State *L, TObject *obj) {
65static void traceexec (lua_State *L) { 65static void traceexec (lua_State *L) {
66 CallInfo *ci = L->ci; 66 CallInfo *ci = L->ci;
67 Proto *p = ci_func(ci)->l.p; 67 Proto *p = ci_func(ci)->l.p;
68 int newline = p->lineinfo[pcRel(*ci->pc, p)]; 68 int newline = getline(p, pcRel(*ci->pc, p));
69 if (pcRel(*ci->pc, p) == 0) /* tracing may be starting now? */ 69 if (pcRel(*ci->pc, p) == 0) /* tracing may be starting now? */
70 ci->savedpc = *ci->pc; /* initialize `savedpc' */ 70 ci->savedpc = *ci->pc; /* initialize `savedpc' */
71 /* calls linehook when enters a new line or jumps back (loop) */ 71 /* calls linehook when enters a new line or jumps back (loop) */
72 if (*ci->pc <= ci->savedpc || newline != p->lineinfo[pcRel(ci->savedpc, p)]) { 72 if (*ci->pc <= ci->savedpc || newline != getline(p, pcRel(ci->savedpc, p))) {
73 luaD_lineHook(L, newline); 73 luaD_lineHook(L, newline);
74 ci = L->ci; /* previous call may reallocate `ci' */ 74 ci = L->ci; /* previous call may reallocate `ci' */
75 } 75 }