diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-28 14:57:04 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-28 14:57:04 -0300 |
commit | 9fdf73bc9a6b4c6afbfff1d8181fface6b1c6761 (patch) | |
tree | da8d97d954e5ffabf9ff275df725f1e0a3a5b3e6 /ldebug.c | |
parent | f1fd9b5c2c21f24d25d7813f431a3495702ebea6 (diff) | |
download | lua-9fdf73bc9a6b4c6afbfff1d8181fface6b1c6761.tar.gz lua-9fdf73bc9a6b4c6afbfff1d8181fface6b1c6761.tar.bz2 lua-9fdf73bc9a6b4c6afbfff1d8181fface6b1c6761.zip |
first version for new API
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 40 |
1 files changed, 21 insertions, 19 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.35 2000/08/14 17:59:20 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.36 2000/08/15 18:28:48 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 | */ |
@@ -144,26 +144,28 @@ static Proto *getluaproto (StkId f) { | |||
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | int lua_getlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v) { | 147 | const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int localnum) { |
148 | const char *name; | ||
148 | StkId f = ar->_func; | 149 | StkId f = ar->_func; |
149 | Proto *fp = getluaproto(f); | 150 | Proto *fp = getluaproto(f); |
150 | if (!fp) return 0; /* `f' is not a Lua function? */ | 151 | if (!fp) return NULL; /* `f' is not a Lua function? */ |
151 | v->name = luaF_getlocalname(fp, v->index, lua_currentpc(f)); | 152 | name = luaF_getlocalname(fp, localnum, lua_currentpc(f)); |
152 | if (!v->name) return 0; | 153 | if (!name) return NULL; |
153 | v->value = luaA_putluaObject(L, (f+1)+(v->index-1)); | 154 | luaA_pushobject(L, (f+1)+(localnum-1)); /* push value */ |
154 | return 1; | 155 | return name; |
155 | } | 156 | } |
156 | 157 | ||
157 | 158 | ||
158 | int lua_setlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v) { | 159 | const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int localnum) { |
160 | const char *name; | ||
159 | StkId f = ar->_func; | 161 | StkId f = ar->_func; |
160 | Proto *fp = getluaproto(f); | 162 | Proto *fp = getluaproto(f); |
161 | UNUSED(L); | 163 | UNUSED(L); |
162 | if (!fp) return 0; /* `f' is not a Lua function? */ | 164 | if (!fp) return NULL; /* `f' is not a Lua function? */ |
163 | v->name = luaF_getlocalname(fp, v->index, lua_currentpc(f)); | 165 | name = luaF_getlocalname(fp, localnum, lua_currentpc(f)); |
164 | if (!v->name || v->name[0] == '*') return 0; /* `*' starts private locals */ | 166 | if (!name || name[0] == '*') return NULL; /* `*' starts private locals */ |
165 | *((f+1)+(v->index-1)) = *v->value; | 167 | *((f+1)+(localnum-1)) = *(--L->top); |
166 | return 1; | 168 | return name; |
167 | } | 169 | } |
168 | 170 | ||
169 | 171 | ||
@@ -236,7 +238,7 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
236 | func = ar->_func; | 238 | func = ar->_func; |
237 | else { | 239 | else { |
238 | what++; /* skip the '>' */ | 240 | what++; /* skip the '>' */ |
239 | func = ar->func; | 241 | func = L->top - 1; |
240 | } | 242 | } |
241 | for (; *what; what++) { | 243 | for (; *what; what++) { |
242 | switch (*what) { | 244 | switch (*what) { |
@@ -260,13 +262,13 @@ int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
260 | } | 262 | } |
261 | case 'f': { | 263 | case 'f': { |
262 | setnormalized(L->top, func); | 264 | setnormalized(L->top, func); |
263 | incr_top; | 265 | incr_top; /* push function */ |
264 | ar->func = lua_pop(L); | ||
265 | break; | 266 | break; |
266 | } | 267 | } |
267 | default: return 0; /* invalid option */ | 268 | default: return 0; /* invalid option */ |
268 | } | 269 | } |
269 | } | 270 | } |
271 | if (!isactive) L->top--; /* pop function */ | ||
270 | return 1; | 272 | return 1; |
271 | } | 273 | } |
272 | 274 | ||
@@ -420,7 +422,7 @@ static const char *getfuncname (lua_State *L, StkId f, const char **name) { | |||
420 | void luaG_typeerror (lua_State *L, StkId o, const char *op) { | 422 | void luaG_typeerror (lua_State *L, StkId o, const char *op) { |
421 | const char *name; | 423 | const char *name; |
422 | const char *kind = getobjname(L, o, &name); | 424 | const char *kind = getobjname(L, o, &name); |
423 | const char *t = lua_type(L, o); | 425 | const char *t = luaO_typename(o); |
424 | if (kind) | 426 | if (kind) |
425 | luaL_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", | 427 | luaL_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", |
426 | op, kind, name, t); | 428 | op, kind, name, t); |
@@ -437,8 +439,8 @@ void luaG_binerror (lua_State *L, StkId p1, lua_Type t, const char *op) { | |||
437 | 439 | ||
438 | 440 | ||
439 | void luaG_ordererror (lua_State *L, StkId top) { | 441 | void luaG_ordererror (lua_State *L, StkId top) { |
440 | const char *t1 = lua_type(L, top-2); | 442 | const char *t1 = luaO_typename(top-2); |
441 | const char *t2 = lua_type(L, top-1); | 443 | const char *t2 = luaO_typename(top-1); |
442 | if (t1[2] == t2[2]) | 444 | if (t1[2] == t2[2]) |
443 | luaL_verror(L, "attempt to compare two %.10s values", t1); | 445 | luaL_verror(L, "attempt to compare two %.10s values", t1); |
444 | else | 446 | else |