diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-03 18:41:05 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-03 18:41:05 -0200 |
commit | 6bb3e40a8d2cdb64a6ac1962d8748dd638a11721 (patch) | |
tree | 4b3e6753ff5da84af6a05d0bcdde1fe15101f6cb | |
parent | 7612f7735d32e298774d5379e847afb5e2a978ad (diff) | |
download | lua-6bb3e40a8d2cdb64a6ac1962d8748dd638a11721.tar.gz lua-6bb3e40a8d2cdb64a6ac1962d8748dd638a11721.tar.bz2 lua-6bb3e40a8d2cdb64a6ac1962d8748dd638a11721.zip |
'lua_Debug' not using 'CallInfo'
-rw-r--r-- | ldebug.c | 24 | ||||
-rw-r--r-- | ldo.c | 6 | ||||
-rw-r--r-- | lua.h | 5 |
3 files changed, 20 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.137 2017/11/03 17:22:54 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.138 2017/11/03 19:33:22 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 | */ |
@@ -146,14 +146,17 @@ LUA_API int lua_gethookcount (lua_State *L) { | |||
146 | 146 | ||
147 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | 147 | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { |
148 | int status; | 148 | int status; |
149 | CallInfo *ci; | 149 | StkId func; |
150 | if (level < 0) return 0; /* invalid (negative) level */ | 150 | if (level < 0) return 0; /* invalid (negative) level */ |
151 | lua_lock(L); | 151 | lua_lock(L); |
152 | for (ci = L->ci; level > 0 && ci != &L->base_ci; ci = ci->previous) | 152 | for (func = L->func; |
153 | level > 0 && func->stkci.previous != 0; | ||
154 | func -= func->stkci.previous) | ||
153 | level--; | 155 | level--; |
154 | if (level == 0 && ci != &L->base_ci) { /* level found? */ | 156 | if (level == 0 && func->stkci.previous != 0) { /* level found? */ |
155 | status = 1; | 157 | status = 1; |
156 | ar->i_ci = ci; | 158 | ar->i_actf = func - L->stack; |
159 | ar->i_actL = L; | ||
157 | } | 160 | } |
158 | else status = 0; /* no such level */ | 161 | else status = 0; /* no such level */ |
159 | lua_unlock(L); | 162 | lua_unlock(L); |
@@ -181,9 +184,10 @@ static StkId findcalled (lua_State *L, StkId caller) { | |||
181 | } | 184 | } |
182 | 185 | ||
183 | 186 | ||
184 | static const char *findlocal (lua_State *L, StkId stkf, int n, | 187 | static const char *findlocal (lua_State *L, const lua_Debug *ar, |
185 | StkId *pos) { | 188 | int n, StkId *pos) { |
186 | const char *name = NULL; | 189 | const char *name = NULL; |
190 | StkId stkf = ar->i_actL->stack + ar->i_actf; | ||
187 | if (isLua(stkf)) { | 191 | if (isLua(stkf)) { |
188 | name = luaF_getlocalname(ci_func(stkf)->p, n, currentpc(stkf)); | 192 | name = luaF_getlocalname(ci_func(stkf)->p, n, currentpc(stkf)); |
189 | } | 193 | } |
@@ -210,7 +214,7 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
210 | } | 214 | } |
211 | else { /* active function; get information through 'ar' */ | 215 | else { /* active function; get information through 'ar' */ |
212 | StkId pos = NULL; /* to avoid warnings */ | 216 | StkId pos = NULL; /* to avoid warnings */ |
213 | name = findlocal(L, ar->i_ci->func, n, &pos); | 217 | name = findlocal(L, ar, n, &pos); |
214 | if (name) { | 218 | if (name) { |
215 | setobjs2s(L, L->top, pos); | 219 | setobjs2s(L, L->top, pos); |
216 | api_incr_top(L); | 220 | api_incr_top(L); |
@@ -225,7 +229,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
225 | StkId pos = NULL; /* to avoid warnings */ | 229 | StkId pos = NULL; /* to avoid warnings */ |
226 | const char *name; | 230 | const char *name; |
227 | lua_lock(L); | 231 | lua_lock(L); |
228 | name = findlocal(L, ar->i_ci->func, n, &pos); | 232 | name = findlocal(L, ar, n, &pos); |
229 | if (name) { | 233 | if (name) { |
230 | setobjs2s(L, pos, L->top - 1); | 234 | setobjs2s(L, pos, L->top - 1); |
231 | L->top--; /* pop value */ | 235 | L->top--; /* pop value */ |
@@ -361,7 +365,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
361 | L->top--; /* pop function */ | 365 | L->top--; /* pop function */ |
362 | } | 366 | } |
363 | else { | 367 | else { |
364 | stkf = ar->i_ci->func; | 368 | stkf = ar->i_actL->stack + ar->i_actf; |
365 | func = s2v(stkf); | 369 | func = s2v(stkf); |
366 | lua_assert(ttisfunction(func)); | 370 | lua_assert(ttisfunction(func)); |
367 | } | 371 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.166 2017/11/03 12:12:30 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.167 2017/11/03 17:22:54 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -253,14 +253,14 @@ void luaD_inctop (lua_State *L) { | |||
253 | void luaD_hook (lua_State *L, int event, int line) { | 253 | void luaD_hook (lua_State *L, int event, int line) { |
254 | lua_Hook hook = L->hook; | 254 | lua_Hook hook = L->hook; |
255 | if (hook && L->allowhook) { /* make sure there is a hook */ | 255 | if (hook && L->allowhook) { /* make sure there is a hook */ |
256 | CallInfo *ci = L->ci; | ||
257 | ptrdiff_t top = savestack(L, L->top); | 256 | ptrdiff_t top = savestack(L, L->top); |
258 | int origframesize = L->func->stkci.framesize; | 257 | int origframesize = L->func->stkci.framesize; |
259 | int tmpframesize; /* frame size to run hook */ | 258 | int tmpframesize; /* frame size to run hook */ |
260 | lua_Debug ar; | 259 | lua_Debug ar; |
261 | ar.event = event; | 260 | ar.event = event; |
262 | ar.currentline = line; | 261 | ar.currentline = line; |
263 | ar.i_ci = ci; | 262 | ar.i_actf = L->func - L->stack; |
263 | ar.i_actL = L; | ||
264 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ | 264 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
265 | tmpframesize = L->top - L->func + LUA_MINSTACK; | 265 | tmpframesize = L->top - L->func + LUA_MINSTACK; |
266 | if (tmpframesize > origframesize) /* need to grow frame? */ | 266 | if (tmpframesize > origframesize) /* need to grow frame? */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.336 2017/07/27 13:36:54 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.337 2017/11/02 11:28:56 roberto Exp roberto $ |
3 | ** Lua - A Scripting Language | 3 | ** Lua - A Scripting Language |
4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
@@ -456,7 +456,8 @@ struct lua_Debug { | |||
456 | char istailcall; /* (t) */ | 456 | char istailcall; /* (t) */ |
457 | char short_src[LUA_IDSIZE]; /* (S) */ | 457 | char short_src[LUA_IDSIZE]; /* (S) */ |
458 | /* private part */ | 458 | /* private part */ |
459 | struct CallInfo *i_ci; /* active function */ | 459 | int i_actf; /* active function */ |
460 | lua_State *i_actL; /* where active function is active */ | ||
460 | }; | 461 | }; |
461 | 462 | ||
462 | /* }====================================================================== */ | 463 | /* }====================================================================== */ |