aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/ldebug.c b/ldebug.c
index 88f06563..4b31f458 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: $ 2** $Id: ldebug.c,v 1.1 1999/12/14 18:31:20 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*/
@@ -42,10 +42,11 @@ int lua_setdebug (lua_State *L, int debug) {
42lua_Function lua_stackedfunction (lua_State *L, int level) { 42lua_Function lua_stackedfunction (lua_State *L, int level) {
43 int i; 43 int i;
44 for (i = (L->top-1)-L->stack; i>=0; i--) { 44 for (i = (L->top-1)-L->stack; i>=0; i--) {
45 int t = L->stack[i].ttype; 45 if (is_T_MARK(L->stack[i].ttype)) {
46 if (t == LUA_T_CLMARK || t == LUA_T_PMARK || t == LUA_T_CMARK) 46 if (level == 0)
47 if (level-- == 0)
48 return L->stack+i; 47 return L->stack+i;
48 level--;
49 }
49 } 50 }
50 return LUA_NOOBJECT; 51 return LUA_NOOBJECT;
51} 52}
@@ -53,8 +54,12 @@ lua_Function lua_stackedfunction (lua_State *L, int level) {
53 54
54int lua_nups (lua_State *L, lua_Function f) { 55int lua_nups (lua_State *L, lua_Function f) {
55 UNUSED(L); 56 UNUSED(L);
56 return (!f || luaA_normalizedtype(f) != LUA_T_CLOSURE) ? 0 : 57 switch (luaA_normalizedtype(f)) {
57 f->value.cl->nelems; 58 case LUA_T_LCLOSURE: case LUA_T_CCLOSURE:
59 return f->value.cl->nelems;
60 default:
61 return 0;
62 }
58} 63}
59 64
60 65
@@ -66,7 +71,7 @@ int lua_currentline (lua_State *L, lua_Function f) {
66lua_Object lua_getlocal (lua_State *L, lua_Function f, int local_number, 71lua_Object lua_getlocal (lua_State *L, lua_Function f, int local_number,
67 const char **name) { 72 const char **name) {
68 /* check whether `f' is a Lua function */ 73 /* check whether `f' is a Lua function */
69 if (lua_tag(L, f) != LUA_T_PROTO) 74 if (lua_tag(L, f) != LUA_T_LPROTO)
70 return LUA_NOOBJECT; 75 return LUA_NOOBJECT;
71 else { 76 else {
72 TProtoFunc *fp = luaA_protovalue(f)->value.tf; 77 TProtoFunc *fp = luaA_protovalue(f)->value.tf;
@@ -84,7 +89,7 @@ lua_Object lua_getlocal (lua_State *L, lua_Function f, int local_number,
84 89
85int lua_setlocal (lua_State *L, lua_Function f, int local_number) { 90int lua_setlocal (lua_State *L, lua_Function f, int local_number) {
86 /* check whether `f' is a Lua function */ 91 /* check whether `f' is a Lua function */
87 if (lua_tag(L, f) != LUA_T_PROTO) 92 if (lua_tag(L, f) != LUA_T_LPROTO)
88 return 0; 93 return 0;
89 else { 94 else {
90 TProtoFunc *fp = luaA_protovalue(f)->value.tf; 95 TProtoFunc *fp = luaA_protovalue(f)->value.tf;
@@ -110,7 +115,7 @@ void lua_funcinfo (lua_State *L, lua_Object func,
110 lua_error(L, "API error - `funcinfo' called with a non-function value"); 115 lua_error(L, "API error - `funcinfo' called with a non-function value");
111 else { 116 else {
112 const TObject *f = luaA_protovalue(func); 117 const TObject *f = luaA_protovalue(func);
113 if (luaA_normalizedtype(f) == LUA_T_PROTO) { 118 if (luaA_normalizedtype(f) == LUA_T_LPROTO) {
114 *source = tfvalue(f)->source->str; 119 *source = tfvalue(f)->source->str;
115 *linedefined = tfvalue(f)->lineDefined; 120 *linedefined = tfvalue(f)->lineDefined;
116 } 121 }