diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-10-29 12:06:37 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-10-29 12:06:37 -0300 |
commit | 413a393e6222482f46599e138bebac162610a572 (patch) | |
tree | 181517f8ec8d56f9101de33f4891729044f244de /ldebug.c | |
parent | ba089bcb08a0efc6c26fb5c1e3c9d61c00cc012c (diff) | |
download | lua-413a393e6222482f46599e138bebac162610a572.tar.gz lua-413a393e6222482f46599e138bebac162610a572.tar.bz2 lua-413a393e6222482f46599e138bebac162610a572.zip |
Stack indices changed to union's
That will allow to change pointers to offsets while reallocating
the stack.
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 52 |
1 files changed, 26 insertions, 26 deletions
@@ -182,10 +182,10 @@ static const char *upvalname (const Proto *p, int uv) { | |||
182 | 182 | ||
183 | 183 | ||
184 | static const char *findvararg (CallInfo *ci, int n, StkId *pos) { | 184 | static const char *findvararg (CallInfo *ci, int n, StkId *pos) { |
185 | if (clLvalue(s2v(ci->func))->p->is_vararg) { | 185 | if (clLvalue(s2v(ci->func.p))->p->is_vararg) { |
186 | int nextra = ci->u.l.nextraargs; | 186 | int nextra = ci->u.l.nextraargs; |
187 | if (n >= -nextra) { /* 'n' is negative */ | 187 | if (n >= -nextra) { /* 'n' is negative */ |
188 | *pos = ci->func - nextra - (n + 1); | 188 | *pos = ci->func.p - nextra - (n + 1); |
189 | return "(vararg)"; /* generic name for any vararg */ | 189 | return "(vararg)"; /* generic name for any vararg */ |
190 | } | 190 | } |
191 | } | 191 | } |
@@ -194,7 +194,7 @@ static const char *findvararg (CallInfo *ci, int n, StkId *pos) { | |||
194 | 194 | ||
195 | 195 | ||
196 | const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { | 196 | const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { |
197 | StkId base = ci->func + 1; | 197 | StkId base = ci->func.p + 1; |
198 | const char *name = NULL; | 198 | const char *name = NULL; |
199 | if (isLua(ci)) { | 199 | if (isLua(ci)) { |
200 | if (n < 0) /* access to vararg values? */ | 200 | if (n < 0) /* access to vararg values? */ |
@@ -203,7 +203,7 @@ const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) { | |||
203 | name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); | 203 | name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); |
204 | } | 204 | } |
205 | if (name == NULL) { /* no 'standard' name? */ | 205 | if (name == NULL) { /* no 'standard' name? */ |
206 | StkId limit = (ci == L->ci) ? L->top : ci->next->func; | 206 | StkId limit = (ci == L->ci) ? L->top.p : ci->next->func.p; |
207 | if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */ | 207 | if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */ |
208 | /* generic name for any valid slot */ | 208 | /* generic name for any valid slot */ |
209 | name = isLua(ci) ? "(temporary)" : "(C temporary)"; | 209 | name = isLua(ci) ? "(temporary)" : "(C temporary)"; |
@@ -221,16 +221,16 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
221 | const char *name; | 221 | const char *name; |
222 | lua_lock(L); | 222 | lua_lock(L); |
223 | if (ar == NULL) { /* information about non-active function? */ | 223 | if (ar == NULL) { /* information about non-active function? */ |
224 | if (!isLfunction(s2v(L->top - 1))) /* not a Lua function? */ | 224 | if (!isLfunction(s2v(L->top.p - 1))) /* not a Lua function? */ |
225 | name = NULL; | 225 | name = NULL; |
226 | else /* consider live variables at function start (parameters) */ | 226 | else /* consider live variables at function start (parameters) */ |
227 | name = luaF_getlocalname(clLvalue(s2v(L->top - 1))->p, n, 0); | 227 | name = luaF_getlocalname(clLvalue(s2v(L->top.p - 1))->p, n, 0); |
228 | } | 228 | } |
229 | else { /* active function; get information through 'ar' */ | 229 | else { /* active function; get information through 'ar' */ |
230 | StkId pos = NULL; /* to avoid warnings */ | 230 | StkId pos = NULL; /* to avoid warnings */ |
231 | name = luaG_findlocal(L, ar->i_ci, n, &pos); | 231 | name = luaG_findlocal(L, ar->i_ci, n, &pos); |
232 | if (name) { | 232 | if (name) { |
233 | setobjs2s(L, L->top, pos); | 233 | setobjs2s(L, L->top.p, pos); |
234 | api_incr_top(L); | 234 | api_incr_top(L); |
235 | } | 235 | } |
236 | } | 236 | } |
@@ -245,8 +245,8 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
245 | lua_lock(L); | 245 | lua_lock(L); |
246 | name = luaG_findlocal(L, ar->i_ci, n, &pos); | 246 | name = luaG_findlocal(L, ar->i_ci, n, &pos); |
247 | if (name) { | 247 | if (name) { |
248 | setobjs2s(L, pos, L->top - 1); | 248 | setobjs2s(L, pos, L->top.p - 1); |
249 | L->top--; /* pop value */ | 249 | L->top.p--; /* pop value */ |
250 | } | 250 | } |
251 | lua_unlock(L); | 251 | lua_unlock(L); |
252 | return name; | 252 | return name; |
@@ -289,7 +289,7 @@ static int nextline (const Proto *p, int currentline, int pc) { | |||
289 | 289 | ||
290 | static void collectvalidlines (lua_State *L, Closure *f) { | 290 | static void collectvalidlines (lua_State *L, Closure *f) { |
291 | if (noLuaClosure(f)) { | 291 | if (noLuaClosure(f)) { |
292 | setnilvalue(s2v(L->top)); | 292 | setnilvalue(s2v(L->top.p)); |
293 | api_incr_top(L); | 293 | api_incr_top(L); |
294 | } | 294 | } |
295 | else { | 295 | else { |
@@ -298,7 +298,7 @@ static void collectvalidlines (lua_State *L, Closure *f) { | |||
298 | const Proto *p = f->l.p; | 298 | const Proto *p = f->l.p; |
299 | int currentline = p->linedefined; | 299 | int currentline = p->linedefined; |
300 | Table *t = luaH_new(L); /* new table to store active lines */ | 300 | Table *t = luaH_new(L); /* new table to store active lines */ |
301 | sethvalue2s(L, L->top, t); /* push it on stack */ | 301 | sethvalue2s(L, L->top.p, t); /* push it on stack */ |
302 | api_incr_top(L); | 302 | api_incr_top(L); |
303 | setbtvalue(&v); /* boolean 'true' to be the value of all indices */ | 303 | setbtvalue(&v); /* boolean 'true' to be the value of all indices */ |
304 | if (!p->is_vararg) /* regular function? */ | 304 | if (!p->is_vararg) /* regular function? */ |
@@ -388,20 +388,20 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
388 | lua_lock(L); | 388 | lua_lock(L); |
389 | if (*what == '>') { | 389 | if (*what == '>') { |
390 | ci = NULL; | 390 | ci = NULL; |
391 | func = s2v(L->top - 1); | 391 | func = s2v(L->top.p - 1); |
392 | api_check(L, ttisfunction(func), "function expected"); | 392 | api_check(L, ttisfunction(func), "function expected"); |
393 | what++; /* skip the '>' */ | 393 | what++; /* skip the '>' */ |
394 | L->top--; /* pop function */ | 394 | L->top.p--; /* pop function */ |
395 | } | 395 | } |
396 | else { | 396 | else { |
397 | ci = ar->i_ci; | 397 | ci = ar->i_ci; |
398 | func = s2v(ci->func); | 398 | func = s2v(ci->func.p); |
399 | lua_assert(ttisfunction(func)); | 399 | lua_assert(ttisfunction(func)); |
400 | } | 400 | } |
401 | cl = ttisclosure(func) ? clvalue(func) : NULL; | 401 | cl = ttisclosure(func) ? clvalue(func) : NULL; |
402 | status = auxgetinfo(L, what, ar, cl, ci); | 402 | status = auxgetinfo(L, what, ar, cl, ci); |
403 | if (strchr(what, 'f')) { | 403 | if (strchr(what, 'f')) { |
404 | setobj2s(L, L->top, func); | 404 | setobj2s(L, L->top.p, func); |
405 | api_incr_top(L); | 405 | api_incr_top(L); |
406 | } | 406 | } |
407 | if (strchr(what, 'L')) | 407 | if (strchr(what, 'L')) |
@@ -663,7 +663,7 @@ static const char *funcnamefromcall (lua_State *L, CallInfo *ci, | |||
663 | */ | 663 | */ |
664 | static int isinstack (CallInfo *ci, const TValue *o) { | 664 | static int isinstack (CallInfo *ci, const TValue *o) { |
665 | StkId pos; | 665 | StkId pos; |
666 | for (pos = ci->func + 1; pos < ci->top; pos++) { | 666 | for (pos = ci->func.p + 1; pos < ci->top.p; pos++) { |
667 | if (o == s2v(pos)) | 667 | if (o == s2v(pos)) |
668 | return 1; | 668 | return 1; |
669 | } | 669 | } |
@@ -681,7 +681,7 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, | |||
681 | LClosure *c = ci_func(ci); | 681 | LClosure *c = ci_func(ci); |
682 | int i; | 682 | int i; |
683 | for (i = 0; i < c->nupvalues; i++) { | 683 | for (i = 0; i < c->nupvalues; i++) { |
684 | if (c->upvals[i]->v == o) { | 684 | if (c->upvals[i]->v.p == o) { |
685 | *name = upvalname(c->p, i); | 685 | *name = upvalname(c->p, i); |
686 | return "upvalue"; | 686 | return "upvalue"; |
687 | } | 687 | } |
@@ -710,7 +710,7 @@ static const char *varinfo (lua_State *L, const TValue *o) { | |||
710 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ | 710 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ |
711 | if (!kind && isinstack(ci, o)) /* no? try a register */ | 711 | if (!kind && isinstack(ci, o)) /* no? try a register */ |
712 | kind = getobjname(ci_func(ci)->p, currentpc(ci), | 712 | kind = getobjname(ci_func(ci)->p, currentpc(ci), |
713 | cast_int(cast(StkId, o) - (ci->func + 1)), &name); | 713 | cast_int(cast(StkId, o) - (ci->func.p + 1)), &name); |
714 | } | 714 | } |
715 | return formatvarinfo(L, kind, name); | 715 | return formatvarinfo(L, kind, name); |
716 | } | 716 | } |
@@ -807,10 +807,10 @@ l_noret luaG_errormsg (lua_State *L) { | |||
807 | if (L->errfunc != 0) { /* is there an error handling function? */ | 807 | if (L->errfunc != 0) { /* is there an error handling function? */ |
808 | StkId errfunc = restorestack(L, L->errfunc); | 808 | StkId errfunc = restorestack(L, L->errfunc); |
809 | lua_assert(ttisfunction(s2v(errfunc))); | 809 | lua_assert(ttisfunction(s2v(errfunc))); |
810 | setobjs2s(L, L->top, L->top - 1); /* move argument */ | 810 | setobjs2s(L, L->top.p, L->top.p - 1); /* move argument */ |
811 | setobjs2s(L, L->top - 1, errfunc); /* push function */ | 811 | setobjs2s(L, L->top.p - 1, errfunc); /* push function */ |
812 | L->top++; /* assume EXTRA_STACK */ | 812 | L->top.p++; /* assume EXTRA_STACK */ |
813 | luaD_callnoyield(L, L->top - 2, 1); /* call it */ | 813 | luaD_callnoyield(L, L->top.p - 2, 1); /* call it */ |
814 | } | 814 | } |
815 | luaD_throw(L, LUA_ERRRUN); | 815 | luaD_throw(L, LUA_ERRRUN); |
816 | } | 816 | } |
@@ -826,8 +826,8 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { | |||
826 | va_end(argp); | 826 | va_end(argp); |
827 | if (isLua(ci)) { /* if Lua function, add source:line information */ | 827 | if (isLua(ci)) { /* if Lua function, add source:line information */ |
828 | luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); | 828 | luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); |
829 | setobjs2s(L, L->top - 2, L->top - 1); /* remove 'msg' from the stack */ | 829 | setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */ |
830 | L->top--; | 830 | L->top.p--; |
831 | } | 831 | } |
832 | luaG_errormsg(L); | 832 | luaG_errormsg(L); |
833 | } | 833 | } |
@@ -872,7 +872,7 @@ static int changedline (const Proto *p, int oldpc, int newpc) { | |||
872 | ** invalid; if so, use zero as a valid value. (A wrong but valid 'oldpc' | 872 | ** invalid; if so, use zero as a valid value. (A wrong but valid 'oldpc' |
873 | ** at most causes an extra call to a line hook.) | 873 | ** at most causes an extra call to a line hook.) |
874 | ** This function is not "Protected" when called, so it should correct | 874 | ** This function is not "Protected" when called, so it should correct |
875 | ** 'L->top' before calling anything that can run the GC. | 875 | ** 'L->top.p' before calling anything that can run the GC. |
876 | */ | 876 | */ |
877 | int luaG_traceexec (lua_State *L, const Instruction *pc) { | 877 | int luaG_traceexec (lua_State *L, const Instruction *pc) { |
878 | CallInfo *ci = L->ci; | 878 | CallInfo *ci = L->ci; |
@@ -895,7 +895,7 @@ int luaG_traceexec (lua_State *L, const Instruction *pc) { | |||
895 | return 1; /* do not call hook again (VM yielded, so it did not move) */ | 895 | return 1; /* do not call hook again (VM yielded, so it did not move) */ |
896 | } | 896 | } |
897 | if (!isIT(*(ci->u.l.savedpc - 1))) /* top not being used? */ | 897 | if (!isIT(*(ci->u.l.savedpc - 1))) /* top not being used? */ |
898 | L->top = ci->top; /* correct top */ | 898 | L->top.p = ci->top.p; /* correct top */ |
899 | if (counthook) | 899 | if (counthook) |
900 | luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ | 900 | luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ |
901 | if (mask & LUA_MASKLINE) { | 901 | if (mask & LUA_MASKLINE) { |