diff options
Diffstat (limited to 'lfunc.c')
| -rw-r--r-- | lfunc.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -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) { | |||
| 35 | Proto *luaF_newproto (lua_State *L) { | 35 | Proto *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 | */ |
| 76 | const char *luaF_getlocalname (const Proto *func, | 78 | const 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; |
