aboutsummaryrefslogtreecommitdiff
path: root/lfunc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-26 16:28:31 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-26 16:28:31 -0300
commitafef009fcea199bd4eff28ea6e5206b59cda9939 (patch)
tree3954490fd4149900be8e795f630104637cd02f4b /lfunc.c
parentb69e712713785394ceefa11ab3e5f9636abea733 (diff)
downloadlua-afef009fcea199bd4eff28ea6e5206b59cda9939.tar.gz
lua-afef009fcea199bd4eff28ea6e5206b59cda9939.tar.bz2
lua-afef009fcea199bd4eff28ea6e5206b59cda9939.zip
new version of debug system
Diffstat (limited to 'lfunc.c')
-rw-r--r--lfunc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lfunc.c b/lfunc.c
index 39753bdc..cabe717f 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 1.23 2000/05/30 19:00:31 roberto Exp roberto $ 2** $Id: lfunc.c,v 1.24 2000/06/12 13:52:05 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*/
@@ -35,6 +35,7 @@ Closure *luaF_newclosure (lua_State *L, int nelems) {
35Proto *luaF_newproto (lua_State *L) { 35Proto *luaF_newproto (lua_State *L) {
36 Proto *f = luaM_new(L, Proto); 36 Proto *f = luaM_new(L, Proto);
37 f->code = NULL; 37 f->code = NULL;
38 f->lines = NULL;
38 f->lineDefined = 0; 39 f->lineDefined = 0;
39 f->source = NULL; 40 f->source = NULL;
40 f->kstr = NULL; 41 f->kstr = NULL;
@@ -59,6 +60,7 @@ void luaF_freeproto (lua_State *L, Proto *f) {
59 luaM_free(L, f->kstr); 60 luaM_free(L, f->kstr);
60 luaM_free(L, f->knum); 61 luaM_free(L, f->knum);
61 luaM_free(L, f->kproto); 62 luaM_free(L, f->kproto);
63 luaM_free(L, f->lines);
62 luaM_free(L, f); 64 luaM_free(L, f);
63} 65}
64 66
@@ -73,14 +75,13 @@ void luaF_freeclosure (lua_State *L, Closure *c) {
73** Look for n-th local variable at line `line' in function `func'. 75** Look for n-th local variable at line `line' in function `func'.
74** Returns NULL if not found. 76** Returns NULL if not found.
75*/ 77*/
76const char *luaF_getlocalname (const Proto *func, 78const char *luaF_getlocalname (const Proto *func, int local_number, int pc) {
77 int local_number, int line) {
78 int count = 0; 79 int count = 0;
79 const char *varname = NULL; 80 const char *varname = NULL;
80 LocVar *lv = func->locvars; 81 LocVar *lv = func->locvars;
81 if (lv == NULL) 82 if (lv == NULL)
82 return NULL; 83 return NULL;
83 for (; lv->line != -1 && lv->line < line; lv++) { 84 for (; lv->pc != -1 && lv->pc <= pc; lv++) {
84 if (lv->varname) { /* register */ 85 if (lv->varname) { /* register */
85 if (++count == local_number) 86 if (++count == local_number)
86 varname = lv->varname->str; 87 varname = lv->varname->str;