diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-03-27 16:29:39 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-03-27 16:29:39 -0300 |
| commit | 7ca8105a2ea7b6a0d7b55b59d273ccd271c35268 (patch) | |
| tree | 5fd0116b5e55859844c15b42f77ef3b7db89db80 /ldebug.c | |
| parent | 94689ac3ad290caf3bada21c389a991f55391987 (diff) | |
| download | lua-7ca8105a2ea7b6a0d7b55b59d273ccd271c35268.tar.gz lua-7ca8105a2ea7b6a0d7b55b59d273ccd271c35268.tar.bz2 lua-7ca8105a2ea7b6a0d7b55b59d273ccd271c35268.zip | |
More orderliness in casts of enumerations
Diffstat (limited to 'ldebug.c')
| -rw-r--r-- | ldebug.c | 29 |
1 files changed, 16 insertions, 13 deletions
| @@ -656,18 +656,19 @@ static const char *funcnamefromcall (lua_State *L, CallInfo *ci, | |||
| 656 | 656 | ||
| 657 | 657 | ||
| 658 | /* | 658 | /* |
| 659 | ** Check whether pointer 'o' points to some value in the stack | 659 | ** Check whether pointer 'o' points to some value in the stack frame of |
| 660 | ** frame of the current function. Because 'o' may not point to a | 660 | ** the current function and, if so, returns its index. Because 'o' may |
| 661 | ** value in this stack, we cannot compare it with the region | 661 | ** not point to a value in this stack, we cannot compare it with the |
| 662 | ** boundaries (undefined behaviour in ISO C). | 662 | ** region boundaries (undefined behaviour in ISO C). |
| 663 | */ | 663 | */ |
| 664 | static int isinstack (CallInfo *ci, const TValue *o) { | 664 | static int instack (CallInfo *ci, const TValue *o) { |
| 665 | StkId pos; | 665 | int pos; |
| 666 | for (pos = ci->func.p + 1; pos < ci->top.p; pos++) { | 666 | StkId base = ci->func.p + 1; |
| 667 | if (o == s2v(pos)) | 667 | for (pos = 0; base + pos < ci->top.p; pos++) { |
| 668 | return 1; | 668 | if (o == s2v(base + pos)) |
| 669 | return pos; | ||
| 669 | } | 670 | } |
| 670 | return 0; /* not found */ | 671 | return -1; /* not found */ |
| 671 | } | 672 | } |
| 672 | 673 | ||
| 673 | 674 | ||
| @@ -708,9 +709,11 @@ static const char *varinfo (lua_State *L, const TValue *o) { | |||
| 708 | const char *kind = NULL; | 709 | const char *kind = NULL; |
| 709 | if (isLua(ci)) { | 710 | if (isLua(ci)) { |
| 710 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ | 711 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ |
| 711 | if (!kind && isinstack(ci, o)) /* no? try a register */ | 712 | if (!kind) { /* not an upvalue? */ |
| 712 | kind = getobjname(ci_func(ci)->p, currentpc(ci), | 713 | int reg = instack(ci, o); /* try a register */ |
| 713 | cast_int(cast(StkId, o) - (ci->func.p + 1)), &name); | 714 | if (reg >= 0) /* is 'o' a register? */ |
| 715 | kind = getobjname(ci_func(ci)->p, currentpc(ci), reg, &name); | ||
| 716 | } | ||
| 714 | } | 717 | } |
| 715 | return formatvarinfo(L, kind, name); | 718 | return formatvarinfo(L, kind, name); |
| 716 | } | 719 | } |
